-
Notifications
You must be signed in to change notification settings - Fork 57
Add DiagnosticsEngineRAII #849
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -430,6 +430,7 @@ class SynthesizingCodeRAII { | |
| SynthesizingCodeRAII(Interpreter* i) : m_Interpreter(i) {} | ||
| // ~SynthesizingCodeRAII() {} // TODO: implement | ||
| }; | ||
|
|
||
| } // namespace compat | ||
|
|
||
| #endif // CPPINTEROP_USE_REPL | ||
|
|
@@ -466,6 +467,25 @@ inline void InstantiateClassTemplateSpecialization( | |
| /*PrimaryHasMatchedPackOnParmToNonPackOnArg=*/false); | ||
| #endif | ||
| } | ||
|
|
||
| class DiagnosticsEngineRAII { | ||
| private: | ||
| clang::DiagnosticsEngine& diags; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member 'diags' of type 'clang::DiagnosticsEngine &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members] clang::DiagnosticsEngine& diags;
^ |
||
|
|
||
| public: | ||
| bool reset_condition; // additional condition to reset diagnostics | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member variable 'reset_condition' has public visibility [cppcoreguidelines-non-private-member-variables-in-classes] bool reset_condition; // additional condition to reset diagnostics
^ |
||
|
|
||
| DiagnosticsEngineRAII(clang::DiagnosticsEngine& d, bool c = true) | ||
| : diags(d), reset_condition(c) {} | ||
| ~DiagnosticsEngineRAII() { | ||
| if (diags.hasErrorOccurred() && reset_condition) { | ||
| // instantiation failed, need to reset DiagnosticsEngine | ||
| diags.Reset(/*soft=*/true); | ||
| diags.getClient()->clear(); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| } // namespace compat | ||
|
|
||
| #endif // CPPINTEROP_COMPATIBILITY_H | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: class 'DiagnosticsEngineRAII' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]