-
Notifications
You must be signed in to change notification settings - Fork 273
CONTRACTS: Add goto-level loop-contract annotation #7788
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: Add goto-level loop-contract annotation #7788
Conversation
9eb93d8
to
69d05d1
Compare
69d05d1
to
22ad623
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #7788 +/- ##
===========================================
+ Coverage 78.58% 78.65% +0.07%
===========================================
Files 1693 1699 +6
Lines 193381 193857 +476
===========================================
+ Hits 151962 152477 +515
+ Misses 41419 41380 -39
☔ View full report in Codecov by Sentry. |
22ad623
to
47bccae
Compare
8286ec0
to
188d439
Compare
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.
Several minor issues.
@@ -0,0 +1,9 @@ | |||
CORE gcc-only |
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.
Could you elaborate as to why this test is GCC-specific?
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.
We use void pointer in this benchmark. Typechecking void pointer will trigger the error https://github.com/diffblue/cbmc/blob/develop/src/ansi-c/c_typecheck_expr.cpp#L4152 under VISUAL_STUDIO.
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.
Can we just use a char pointer instead?
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.
Actually, using char pointers will lead to a bug of DFCC.
156: File: D:\a\cbmc\cbmc\src\goto-instrument\contracts\dynamic-frames\dfcc_instrument.cpp:330 function: dfcc_instrumentt::instrument_function
156: Condition: Precondition
156: Reason: found != goto_model.goto_functions.function_map.end()
156: << EXTRA DIAGNOSTICS >>
156: Function '_errno' must exist in the model.
156: << END EXTRA DIAGNOSTICS >>
There is a function _errno
in the symbol table but not in the function map. I will keep this test as gcc-only and open an issue to track this bug.
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.
d84e62d
to
84d83cc
Compare
ea4d440
to
d7f4ba1
Compare
d7f4ba1
to
6cc179a
Compare
This commit allows us to parse and annotate loop contracts from JSON files to GOTO models. We first parse the JSON file to get the configuration. Function configurations consist of function id (regex) and a list of loop-contract configurations. Loop-contract configurations consist of: Loop number of the loop we are annotating to. Loop invariants as strings. (optional) Loop assigns as strings. (optional) Loop decreases as strings. (optional) A symbol map that map symbol names in the loop contracts strings to their name in the symbol table of the goto model. Loop contracts mangling consists of four steps. Construct a fake function with a fake loop that contains the loop contracts for parsing the contracts. Parse the fake function and extract the contracts as exprt. Substitute symbols in the extracted exprt with the symbols in the symbol table of the goto model according to the symbol map provided by the user. Typecheck all contract exprt. Annotate all contract exprt to the corresponding loop.
6cc179a
to
b543536
Compare
This PR allows us to parse and annotate loop contracts from JSON files to GOTO models.
We first parse the JSON file to get the configuration.
Loop contracts mangling consists of four steps.