-
Notifications
You must be signed in to change notification settings - Fork 273
CONTRACTS: Support bounded user defined memory-predicates #7401
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 bounded user defined memory-predicates #7401
Conversation
030f804
to
bf18bd4
Compare
f84fdc9
to
1ace3d4
Compare
Codecov ReportBase: 78.38% // Head: 78.41% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #7401 +/- ##
===========================================
+ Coverage 78.38% 78.41% +0.03%
===========================================
Files 1651 1655 +4
Lines 190045 190264 +219
===========================================
+ Hits 148961 149201 +240
+ Misses 41084 41063 -21
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
3815192
to
0d242c2
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.
Only some minor changes before approval.
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.h
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.h
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.h
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.h
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.h
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/doc/developer/contracts-dev-spec-memory-predicates-rewriting.md
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/doc/developer/contracts-dev-spec-memory-predicates-rewriting.md
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/doc/user/contracts-memory-predicates.md
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/doc/user/contracts-memory-predicates.md
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.cpp
Show resolved
Hide resolved
4929b83
to
2dda6a0
Compare
2dda6a0
to
eda68f4
Compare
Will fix. EDIT: Right now the front-end maps @tautschnig is currently working on moving the lowering of built-ins to the back end #7395, which would solve my problem by keeping The best I can do for the moment is to temporarily rename my I'll update my code to @kroening Would that work for you ? |
eda68f4
to
cf6fd73
Compare
regression/contracts-dfcc/memory-predicates-is-in-range-requires/test.desc
Outdated
Show resolved
Hide resolved
regression/contracts-dfcc/memory-predicates-is-fresh-requires-max-malloc-size/test.desc
Outdated
Show resolved
Hide resolved
regression/contracts-dfcc/memory-predicates-is-in-range-several-targets/main.c
Outdated
Show resolved
Hide resolved
src/ansi-c/c_typecheck_expr.cpp
Outdated
else if(identifier == CPROVER_PREFIX "is_in_range") | ||
{ | ||
// same as pointer_in_range with experimental feature for DFCC contracts | ||
// -- do not use | ||
if(expr.arguments().size() != 3) | ||
{ | ||
throw invalid_source_file_exceptiont{ | ||
"is_in_range expects three arguments", expr.source_location()}; | ||
} | ||
|
||
for(const auto &arg : expr.arguments()) | ||
{ | ||
if(arg.type().id() != ID_pointer) | ||
{ | ||
throw invalid_source_file_exceptiont{ | ||
"is_in_range expects pointer-typed arguments", arg.source_location()}; | ||
} | ||
} | ||
return nil_exprt(); | ||
} |
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 this (and any other support for __CPROVER_is_in_range
) please go in a commit of its own? #7395 should make it completely unnecessary.
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 this would be in line with what's suggested in #7401 (comment) (except it would make the follow-up work very easy to identify).
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 moved all pointer_in_range related code to a separate commit
src/goto-instrument/contracts/doc/developer/contracts-dev-spec-memory-predicates-rewriting.md
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.cpp
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.cpp
Outdated
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.cpp
Show resolved
Hide resolved
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.h
Outdated
Show resolved
Hide resolved
7d57611
to
e0643b4
Compare
src/goto-instrument/contracts/dynamic-frames/dfcc_lift_memory_predicates.h
Outdated
Show resolved
Hide resolved
e0643b4
to
3618d8a
Compare
Users can now write their own pointer predicates in terms of: - __CPROVER_is_fresh(ptr, size) - __CPROVER_obeys_contract(ptr, target) A rewriting pass lifts these user-defined pointer predicates into predicates that take pointers by reference and can make the predicates hold in assumption contexts using side-effects, and check the predicates in assertion contexts. Limitiations: User-defined predicates can be self-recursive but not mutually recursive, and their evaluation needs to be terminate, i.e. they can only describe bounded data structures.
3618d8a
to
df1551e
Compare
@feliperodri all requested changes were applied |
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
regression/contracts-dfcc/memory-predicates-pointer-in-range-requires/test.desc
Outdated
Show resolved
Hide resolved
df1551e
to
2653d78
Compare
Adds support for pointer_in_range_dfcc in ensures and requires clauses and user-defined predicates. This is a temporary workaround to the fact that pointer_in_range is lowered by the front-end.
2653d78
to
c144993
Compare
CBMC 5.72.1 point release for #7401
Fixes #7194.
Users can now write their own pointer predicates in terms of:
A rewriting pass lifts these user-defined pointer predicates
into predicates that take pointer by reference and can
make the predicates hold in assumption contexts
using side-effects, and check the predicates in assertion
contexts.
Limitiations:
User-defined predicates can be self-recursive but not mutually
recursive, and their evaluation needs to be terminate, i.e. they
can only describe bounded data structures.
The doxygen user and developer manuals and has been updated to describe the feature and its implementation.
Tests were added, and existing tests cleaned-up.