-
Notifications
You must be signed in to change notification settings - Fork 274
Invariant with diagnostics #2906
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
hannes-steffenhagen-diffblue
merged 3 commits into
diffblue:develop
from
hannes-steffenhagen-diffblue:invariant-with-diagnostics
Sep 7, 2018
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CORE | ||
dummy_parameter.c | ||
invariant-with-lots-of-diagnostics | ||
^EXIT=(0|127|134|137)$ | ||
^SIGNAL=0$ | ||
--- begin invariant violation report --- | ||
Invariant check failed | ||
diagnostic 1 | ||
diagnostic 2 | ||
diagnostic 3 | ||
diagnostic 4 |
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,9 @@ | ||
CORE | ||
dummy_parameter.c | ||
invariant-with-custom-diagnostics | ||
^EXIT=(0|127|134|137)$ | ||
^SIGNAL=0$ | ||
--- begin invariant violation report --- | ||
Invariant check failed | ||
Diagnostic A | ||
Diagnostic B |
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 |
---|---|---|
|
@@ -142,11 +142,6 @@ class invariant_with_diagnostics_failedt : public invariant_failedt | |
#else | ||
#define CBMC_NORETURN | ||
#endif | ||
// The macros MACRO<n> (e.g., INVARIANT2) are for internal use in this file | ||
// only. The corresponding macros that take a variable number of arguments (see | ||
// further below) should be used instead, which in turn call those with a fixed | ||
// number of arguments. For example, if INVARIANT(...) is called with two | ||
// arguments, it calls INVARIANT2(). | ||
|
||
#if defined(CPROVER_INVARIANT_CPROVER_ASSERT) | ||
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. In the following we should also add the new macro 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. Done, thanks! |
||
// Used to allow CPROVER to check itself | ||
|
@@ -321,17 +316,17 @@ inline void write_rest_diagnostics(std::ostream &) | |
template <typename T, typename... Ts> | ||
void write_rest_diagnostics(std::ostream &out, T &&next, Ts &&... rest) | ||
{ | ||
out << ", " << diagnostic_as_string(std::forward<T>(next)); | ||
out << "\n" << diagnostic_as_string(std::forward<T>(next)); | ||
write_rest_diagnostics(out, std::forward<Ts>(rest)...); | ||
} | ||
|
||
template <typename T, typename... Ts> | ||
std::string assemble_diagnostics(T &&first, Ts &&... rest) | ||
template <typename... Diagnostics> | ||
std::string assemble_diagnostics(Diagnostics &&... args) | ||
{ | ||
std::ostringstream out; | ||
out << "[ " << diagnostic_as_string(std::forward<T>(first)); | ||
write_rest_diagnostics(out, std::forward<Ts>(rest)...); | ||
out << " ]"; | ||
out << "\n<< EXTRA DIAGNOSTICS >>"; | ||
write_rest_diagnostics(out, std::forward<Diagnostics>(args)...); | ||
out << "\n<< END EXTRA DIAGNOSTICS >>"; | ||
return out.str(); | ||
} | ||
} // namespace detail | ||
|
@@ -457,18 +452,14 @@ CBMC_NORETURN void report_invariant_failure( | |
#define CHECK_RETURN_STRUCTURED(CONDITION, TYPENAME, ...) \ | ||
EXPAND_MACRO(INVARIANT_STRUCTURED(CONDITION, TYPENAME, __VA_ARGS__)) | ||
|
||
// This should be used to mark dead code | ||
/// This should be used to mark dead code | ||
#define UNREACHABLE INVARIANT(false, "Unreachable") | ||
#define UNREACHABLE_STRUCTURED(TYPENAME, ...) \ | ||
EXPAND_MACRO(INVARIANT_STRUCTURED(false, TYPENAME, __VA_ARGS__)) | ||
|
||
// This condition should be used to document that assumptions that are | ||
// made on goto_functions, goto_programs, exprts, etc. being well formed. | ||
// "The data structure is not corrupt or malformed" | ||
#define DATA_INVARIANT2(CONDITION, REASON) INVARIANT2(CONDITION, REASON) | ||
#define DATA_INVARIANT3(CONDITION, REASON, DIAGNOSTICS) \ | ||
INVARIANT3(CONDITION, REASON, DIAGNOSTICS) | ||
|
||
/// This condition should be used to document that assumptions that are | ||
/// made on goto_functions, goto_programs, exprts, etc. being well formed. | ||
/// "The data structure is not corrupt or malformed" | ||
#define DATA_INVARIANT(CONDITION, REASON) INVARIANT(CONDITION, REASON) | ||
#define DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON, ...) \ | ||
INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON, __VA_ARGS__) | ||
|
@@ -482,6 +473,6 @@ CBMC_NORETURN void report_invariant_failure( | |
// to migrate documentation and "error handling" in older code. | ||
#define TODO INVARIANT(false, "Todo") | ||
#define UNIMPLEMENTED INVARIANT(false, "Unimplemented") | ||
#define UNHANDLED_CASE INVARIANT2(false, "Unhandled case") | ||
#define UNHANDLED_CASE INVARIANT(false, "Unhandled case") | ||
|
||
#endif // CPROVER_UTIL_INVARIANT_H |
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
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.
Uh oh!
There was an error while loading. Please reload this page.