-
Notifications
You must be signed in to change notification settings - Fork 274
CONTRACTS: Front-end: frees clause improvements #7087
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: Front-end: frees clause improvements #7087
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #7087 +/- ##
===========================================
- Coverage 77.85% 77.84% -0.01%
===========================================
Files 1574 1574
Lines 181235 181435 +200
===========================================
+ Hits 141099 141246 +147
- Misses 40136 40189 +53
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
7edced4
to
62a0609
Compare
Add new functions to specify assignable targets in assigns clauses: - add type __CPROVER_assignable_t - add builtin __CPROVER_assignable - add builtin __CPROVER_whole_object - add builtin __CPROVER_object_upto - add builtin __CPROVER_typed_target - allow function call expressions as assigns clause targets as long as they have the return type __CPROVER_assignable_t and are one of the built-ins. Add support for `__CPROVER_frees()` clauses to the contract language to let users specify the pointers a function (or loop) is allowed to free.
626fac5
to
133116d
Compare
Add the following to the front-end: - add `__CPROVER_freeable_t` built-in type - add `__CPROVER_freeable` built-in function - allow calls to `__CPROVER_freeable_t` functions in frees clauses - add `__CPROVER_is_freeable` built-in predicate - add `__CPROVER_is_freed` built-in predicate The predicates are not yet supported in the back-end.
133116d
to
eeb0728
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.
Left a few comments, but I will get another review after merging previous PR (or moving all frees clauses code over here and kill dependency).
error().source_location = expr.source_location(); | ||
error() << id2string(id) + " is not allowed in preconditions." << 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.
I guess the previous PR contains this test case, right?
if(code.find(ID_C_spec_frees).is_not_nil()) | ||
{ | ||
typecheck_spec_frees( | ||
static_cast<unary_exprt &>(code.add(ID_C_spec_frees)).op().operands()); |
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 no coverage here?
{ | ||
error().source_location = target.source_location(); | ||
error() << "function pointer calls not allowed in frees clauses" << 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.
Why no coverage?
bool has_freeable_type = | ||
(type.id() == ID_empty) && | ||
(type.get(ID_C_typedef) == CPROVER_PREFIX "freeable_t"); | ||
if(!has_freeable_type) |
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.
bool has_freeable_type = | |
(type.id() == ID_empty) && | |
(type.get(ID_C_typedef) == CPROVER_PREFIX "freeable_t"); | |
if(!has_freeable_type) | |
if((type.id() == ID_empty) && | |
(type.get(ID_C_typedef) == CPROVER_PREFIX "freeable_t")) |
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 like naming what is being checked to make the intent more explicit.
const std::function<void(exprt &)> typecheck_target = [&](exprt &target) { | ||
typecheck_spec_frees_target(target); | ||
}; | ||
typecheck_conditional_targets(targets, typecheck_target, "frees"); |
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.
Should "frees" and "assigns" be a macro?
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.
what is wrong with std::function ?
{ | ||
$$=$1; | ||
set($$, ID_C_spec_frees); | ||
parser_stack($$).add_to_operands(exprt(ID_target_list)); |
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.
No coverage?
Superseded by #7091 |
Depends on #7086.
The first commit in this PR is from #7086, please do not read.
The second commit adds the following to the front-end:
__CPROVER_freeable_t
built-in type__CPROVER_freeable
built-in function__CPROVER_freeable_t
functions in frees clauses__CPROVER_is_freeable
built-in predicate__CPROVER_is_freed
built-in predicateThe predicates are not yet supported in the back-end and behave as nondet functions
The build fails with ubuntu 18.04 and I am not sure why, since no error is visible on the output.