-
Notifications
You must be signed in to change notification settings - Fork 277
CONTRACTS: Support object slices in assigns clauses #6814
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: Support object slices in assigns clauses #6814
Conversation
0a184c6
to
4d0d4f3
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6814 +/- ##
========================================
Coverage 77.00% 77.01%
========================================
Files 1594 1594
Lines 184345 184413 +68
========================================
+ Hits 141957 142020 +63
- Misses 42388 42393 +5
Continue to review full report at Codecov.
|
4d0d4f3
to
384dd30
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.
Please fold the second commit into the first one to ensure bisectability.
src/ansi-c/c_typecheck_code.cpp
Outdated
if(has_subexpr(target, ID_side_effect)) | ||
{ | ||
error().source_location = target.source_location(); | ||
error() << "side-effects not allowed in assigns clause targets" << eom; | ||
throw 0; | ||
} | ||
if(has_subexpr(target, ID_if)) | ||
{ | ||
error().source_location = target.source_location(); | ||
error() << "ternary expressions not allowed in assigns " | ||
"clause targets" | ||
<< eom; | ||
throw 0; | ||
} |
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 repeats multiple times and might be worth factoring out into a static
function.
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.
factored it using a local lambda
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.
LGTM.
05710dd
to
2a53c59
Compare
Introduces __CPROVER_object_from and __CPROVER_object_slice target expression in assigns clauses. Both get compiled to __CPROVER_havoc_slice for contract replacement.
2a53c59
to
0bb6993
Compare
Adds support the following targets in assigns clauses:
__CPROVER_object_from(ptr)
: allows to assign all remaining bytes of the object, starting at the given address.__CPROVER_object_slice(ptr, size)
: allows to assign size bytes of the object starting at the given address.Both targets are translated to
__CPROVER_havoc_slice
for contract replacement.