-
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
Merged
remi-delmas-3000
merged 1 commit into
diffblue:develop
from
remi-delmas-3000:inlining-decoratort-improvements
Sep 1, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
regression/contracts/function-calls-04-1/test-enf-f2_out.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Utility functions for code contracts. | ||
|
||
Author: Remi Delmas, [email protected] | ||
|
||
Date: August 2022 | ||
|
||
\*******************************************************************/ | ||
|
||
#include "inlining_decorator.h" | ||
|
||
inlining_decoratort::inlining_decoratort(message_handlert &_wrapped) | ||
: wrapped(_wrapped), | ||
no_body_regex(std::regex(".*no body for function '(.*)'.*")), | ||
missing_function_regex( | ||
std::regex(".*missing function '(.*)' is ignored.*")), | ||
recursive_call_regex( | ||
std::regex(".*recursion is ignored on call to '(.*)'.*")), | ||
not_enough_arguments_regex( | ||
std::regex(".*call to '(.*)': not enough arguments.*")) | ||
{ | ||
} | ||
|
||
void inlining_decoratort::match_no_body_warning(const std::string &message) | ||
{ | ||
std::smatch sm; | ||
std::regex_match(message, sm, no_body_regex); | ||
if(sm.size() == 2) | ||
no_body_set.insert(sm.str(1)); | ||
} | ||
|
||
void inlining_decoratort::match_missing_function_warning( | ||
const std::string &message) | ||
{ | ||
std::smatch sm; | ||
std::regex_match(message, sm, missing_function_regex); | ||
if(sm.size() == 2) | ||
missing_function_set.insert(sm.str(1)); | ||
} | ||
|
||
void inlining_decoratort::match_recursive_call_warning( | ||
const std::string &message) | ||
{ | ||
std::smatch sm; | ||
std::regex_match(message, sm, recursive_call_regex); | ||
if(sm.size() == 2) | ||
recursive_call_set.insert(sm.str(1)); | ||
} | ||
|
||
void inlining_decoratort::match_not_enough_arguments_warning( | ||
const std::string &message) | ||
{ | ||
std::smatch sm; | ||
std::regex_match(message, sm, not_enough_arguments_regex); | ||
if(sm.size() == 2) | ||
not_enough_arguments_set.insert(sm.str(1)); | ||
} | ||
|
||
void inlining_decoratort::parse_message(const std::string &message) | ||
{ | ||
match_no_body_warning(message); | ||
match_missing_function_warning(message); | ||
match_recursive_call_warning(message); | ||
match_not_enough_arguments_warning(message); | ||
} | ||
|
||
void inlining_decoratort::throw_on_no_body(messaget &log, const int error_code) | ||
feliperodri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if(no_body_set.size() != 0) | ||
{ | ||
for(auto it : no_body_set) | ||
{ | ||
log.error() << "No body for '" << it << "' during inlining" | ||
<< messaget::eom; | ||
} | ||
throw error_code; | ||
} | ||
} | ||
|
||
void inlining_decoratort::throw_on_recursive_calls( | ||
messaget &log, | ||
const int error_code) | ||
{ | ||
if(recursive_call_set.size() != 0) | ||
{ | ||
for(auto it : recursive_call_set) | ||
{ | ||
log.error() << "Recursive call to '" << it << "' during inlining" | ||
<< messaget::eom; | ||
} | ||
throw error_code; | ||
} | ||
} | ||
|
||
void inlining_decoratort::throw_on_missing_function( | ||
feliperodri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
messaget &log, | ||
const int error_code) | ||
{ | ||
if(missing_function_set.size() != 0) | ||
{ | ||
for(auto it : missing_function_set) | ||
{ | ||
log.error() << "Missing function '" << it << "' during inlining" | ||
<< messaget::eom; | ||
} | ||
throw error_code; | ||
} | ||
} | ||
|
||
void inlining_decoratort::throw_on_not_enough_arguments( | ||
feliperodri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
messaget &log, | ||
const int error_code) | ||
{ | ||
if(not_enough_arguments_set.size() != 0) | ||
{ | ||
for(auto it : not_enough_arguments_set) | ||
{ | ||
log.error() << "Not enough arguments for '" << it << "' during inlining" | ||
<< messaget::eom; | ||
} | ||
throw error_code; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.