Skip to content

[GSoC] Refactor DiagnosticEngine to use YAML files #32239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 17, 2020

Conversation

HassanElDesouky
Copy link
Contributor

@HassanElDesouky HassanElDesouky commented Jun 8, 2020

In this PR, I modified the current DiagnosticEngine class to be able to parse diagnostic messages from YAML files in the future.

Summary of changes:

  • Created a DiagnosticNode struct to hold the objects of the YAML files.
  • Defined the YAML format for DiagnosticNode
  • Created a CMakeLists.txt file to handle where the YAML diagnostic files will be in the toolchain.
  • Refactored DiagnosticEngine::diagnosticStringFor to handle returning the diagnostics messages from YAML files and handle fall-backs if the diagnostic message isn't present in the current YAML file.

Next steps after this PR gets merged:

  • Retrieve the diagnostic messages path from the compiler toolchain.
  • Create a -locale compiler frontend flag for choosing the language.
  • Create a -diagnostic-messages-path compiler frontend flag to provide a path for the YAML files (to use in testing).
  • Write tests.

cc @xedin

@xedin xedin self-requested a review June 11, 2020 00:44
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great, definitely heading in the right direction! I have left some comments inline which we need to tackle before merging.

@HassanElDesouky HassanElDesouky requested a review from xedin June 11, 2020 15:07
@HassanElDesouky HassanElDesouky requested a review from xedin June 15, 2020 14:23
@HassanElDesouky
Copy link
Contributor Author

@xedin I renamed the diag_id to just id

@HassanElDesouky HassanElDesouky force-pushed the GSoC-DiagEngineRefactor branch from 85dc806 to 4e29883 Compare June 17, 2020 18:27
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@xedin
Copy link
Contributor

xedin commented Jun 17, 2020

@swift-ci please smoke test

xedin and others added 2 commits June 17, 2020 13:13
Co-authored-by: Suyash Srijan <suyashsrijan@outlook.com>
Co-authored-by: Suyash Srijan <suyashsrijan@outlook.com>
@xedin
Copy link
Contributor

xedin commented Jun 17, 2020

@swift-ci please smoke test

@HassanElDesouky
Copy link
Contributor Author

@xedin Tests passed! 🥳

@xedin xedin merged commit a332156 into swiftlang:master Jun 17, 2020
@davezarzycki
Copy link
Contributor

This pull request is using undefined behavior. Can we fix this any time soon?

lib/AST/DiagnosticEngine.cpp:1093:12: warning: address of stack memory associated with local variable 'localizedMessage' returned [-Wreturn-stack-address]
    return localizedMessage.c_str();
           ^~~~~~~~~~~~~~~~

@HassanElDesouky
Copy link
Contributor Author

@davezarzycki I'll fix it in the upcoming PR if that's okay?

@compnerd
Copy link
Member

This seems to have caused other issues. This breaks when building with lld due to multiple definitions of the data types. enum classes are not COMDATed it seems, and this cause multiple conflicting definitions. Could you please fix that soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants