Add DiagnosticsEngineRAII#849
Conversation
| // ~SynthesizingCodeRAII() {} // TODO: implement | ||
| }; | ||
|
|
||
| class DiagnosticsEngineRAII { |
There was a problem hiding this comment.
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]
class DiagnosticsEngineRAII {
^|
|
||
| class DiagnosticsEngineRAII { | ||
| private: | ||
| clang::DiagnosticsEngine& diags; |
There was a problem hiding this comment.
warning: member 'diags' of type 'clang::DiagnosticsEngine &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]
clang::DiagnosticsEngine& diags;
^| clang::DiagnosticsEngine& diags; | ||
|
|
||
| public: | ||
| bool reset_condition; // additional condition to reset diagnostics |
There was a problem hiding this comment.
warning: member variable 'reset_condition' has public visibility [cppcoreguidelines-non-private-member-variables-in-classes]
bool reset_condition; // additional condition to reset diagnostics
^
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #849 +/- ##
==========================================
+ Coverage 79.72% 79.74% +0.02%
==========================================
Files 11 11
Lines 4025 4029 +4
==========================================
+ Hits 3209 3213 +4
Misses 816 816
🚀 New features to boost your workflow:
|
120803e to
96d3edd
Compare
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
Can you check if clang's SFINAETrap (Ref: https://clang.llvm.org/doxygen/classclang_1_1Sema_1_1SFINAETrap.html#details) does the necessary trick? i.e. can we replace our custom logic with this object instead?
@Vipul-Cariappa I spent some time reading up on a few things. From what I've found, this is my understanding:
Sources:
|
96d3edd to
fadf560
Compare
|
cling builds and git-clang-format precheck are failing. will push fixes soon. edit: done. all checks passed. |
c2897ef to
72eed5a
Compare
| #endif | ||
| } | ||
|
|
||
| class DiagnosticsEngineRAII { |
There was a problem hiding this comment.
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]
class DiagnosticsEngineRAII {
^|
|
||
| class DiagnosticsEngineRAII { | ||
| private: | ||
| clang::DiagnosticsEngine& diags; |
There was a problem hiding this comment.
warning: member 'diags' of type 'clang::DiagnosticsEngine &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]
clang::DiagnosticsEngine& diags;
^| clang::DiagnosticsEngine& diags; | ||
|
|
||
| public: | ||
| bool reset_condition; // additional condition to reset diagnostics |
There was a problem hiding this comment.
warning: member variable 'reset_condition' has public visibility [cppcoreguidelines-non-private-member-variables-in-classes]
bool reset_condition; // additional condition to reset diagnostics
^72eed5a to
fec15ed
Compare
|
@Vipul-Cariappa hello, would appreciate feedback about this, thanks. |
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
The way this is implemented, it looks more like a function call instead of a RAII object (Look at the way reset_condition is used). But I don't know if a simple function call is better or a RAII object is better...
Wasn't the point here to use |
Please refer to my analysis in this comment: #849 (comment) |
Did you try to implement it and how does it fail? |
Description
Fixes
FIXME: this can go into a RAII object. Reference:CppInterOp/lib/CppInterOp/CppInterOp.cpp
Line 311 in 852f6d4
Implementation details-
I added a RAII class (
compat::DiagnosticsEngineRAII) that automatically checks if it should reset the DiagnosticsEngine before the RAII object goes out of scope. It checks fordiags.hasErrorOccurred()and a user-provided booleanreset_condition.Type of change
Please tick all options which are relevant.
Testing
Checklist