-
Notifications
You must be signed in to change notification settings - Fork 274
CONTRACTS: Handle all 4 inlining warning types in inlining_decoratort
#7083
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
CONTRACTS: Handle all 4 inlining warning types in inlining_decoratort
#7083
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #7083 +/- ##
===========================================
- Coverage 77.85% 77.85% -0.01%
===========================================
Files 1574 1576 +2
Lines 181245 181301 +56
===========================================
+ Hits 141109 141143 +34
- Misses 40136 40158 +22
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
14a0433
to
3c0369b
Compare
void print(unsigned level, const std::string &message) override | ||
{ | ||
parse_message(message); | ||
wrapped.print(level, message); | ||
} | ||
|
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.
Is this only for debugging purposes? Why no coverage in none of the print methods?
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.
This class is used to collect the names of functions that cause inlining warnings and turn them into hard errors.
The inlining_decoratort
class is a decorator for the message_handlert
class so it both extends message_handlert
and wraps a preexistingmessage_handlert
object.
The decorator has to implement all message_handlert
methods.
This one intercepts messages sent by the inlining class to the message_handlert
to extract the names of functions involved in inlining warnings and is essential to how this class works.
All other methods are implemented by redirecting calls to the wrapped object assuming that whatever it does is already the right thing.
return wrapped.get_message_count(level); | ||
} | ||
|
||
std::string command(unsigned i) const override |
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.
Same as before. Why no coverage?
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.
No coverage because the decorator design pattern requires to implement all methods of messaget_handlert
, but this decorator only gets used with the GOTO inlining class which does itself not use the whole message_handlert
interface. Since all these methods do is to call the same method on the wrapped object code review could be sufficient to validate this class.
missing_function_set.insert(ss.str()); | ||
} |
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.
Shall we include at least one test to cover these branches?
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.
These methods are used by the new contracts implementation so they will get covered in a later PR
{ | ||
std::smatch sm; | ||
std::regex_match(message, sm, missing_function_regex); | ||
if(sm.size() == 2) |
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.
Why 2? The size will return "number of capturing groups plus one", so I guess you need at least one(i.e., sm.size() > 1
), right?
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.
I think the "plus one" is the whole substring, no? Seems like there should be a better way to check this.
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.
The first match is the whole regex match and the following matches are for the groups within the regex if any. Since my regexes have 1 group this results in two matches for a successful match.
{ | ||
std::smatch sm; | ||
std::regex_match(message, sm, missing_function_regex); | ||
if(sm.size() == 2) |
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.
I think the "plus one" is the whole substring, no? Seems like there should be a better way to check this.
3c0369b
to
09bfc72
Compare
Added more documentation and implemented requested changes |
The |
{ | ||
for(auto it : no_body_set) | ||
{ | ||
log.error() << "inlining_decoratort: no body for '" << it |
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.
⛏️ Do you really want to have inlining_decoratort:
as part of the output?
09bfc72
to
441bee5
Compare
inlining_decoratort
improvementsinlining_decoratort
bdd3f95
to
784554f
Compare
Modifications: - move the class from contracts.cpp to its own file - use regexes to track all 4 types of warnings - add getter methods to inspect functions involved in warnings - add methods to throw errors after warnings
784554f
to
664a7ac
Compare
Modifications:
No behaviour or performance impact.