-
Notifications
You must be signed in to change notification settings - Fork 274
Supports history variables in function contracts #6025
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
Conversation
04c723d
to
1e3ec73
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6025 +/- ##
===========================================
- Coverage 75.68% 74.22% -1.47%
===========================================
Files 1447 1446 -1
Lines 157837 157540 -297
===========================================
- Hits 119465 116936 -2529
- Misses 38372 40604 +2232
Continue to review full report at Codecov.
|
1e3ec73
to
11441e8
Compare
47dcd1c
to
f72a9ca
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.
The PR overall looks good. I list several comments regarding simplifying the code and clarifying the regression tests.
One meta comment about regression tests: you only check for exit code and verification success and failure. Could you please also add some regexes in the test.desc
files to check if the contracts are actually being processed? They must be generating some additional assertions, for which we should have regexes.
c8409a5
to
ed1689e
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.
The regexes you added to test.desc
files look good and now we're checking that contracts are actually working as expected.
I have only 2 comments:
ed1689e
to
41293a0
Compare
e5d7738
to
3019897
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.
LGTM! Thanks for all the changes.
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.
01b8dcd
to
9bc4ee7
Compare
Hi @kroening @tautschnig could you review this PR? It's missing code owner approval. |
While it's conceivable that other languages may eventually offer a similar mechanism, may I suggest to add |
9bc4ee7
to
e64e670
Compare
@kroening Thanks for the comment, I have made the required changes. |
d5537ac
to
b565a29
Compare
f55dca2
to
113f83a
Compare
This adds support for history variables in function contracts. History variables are (1) declared and (2) assigned to the value that their corresponding variable has at function call time. Currently, only pointers are supported.
113f83a
to
6ce96c7
Compare
This PR adds support for history variables in
__CPROVER_ensures
contracts. Specifically, users may now access the pre-function call state of a variable within the post-condition.Let us consider the following example. Semantically, this example shows a case where the post-condition of a function call ensures that ( the post-call value of
x
) is greater than ( the pre-call value ofx
+ 2 ).In this case, the variable that we are interested in is
x
, which is modified by the call tofoo(int *x)
. The pre-condition contract (__CPROVER_requires
) may only access the pre-state of the variablex
(this is done through the inclusion of*x
). However, the post-condition (__CPROVER_ensures
) accesses both the post-state ofx
(through*x
) and the pre-state ofx
(through__CPROVER_old(*x)
)Note:
We currently only support pointers within the
__CPROVER_old()
construct. In the near future, we plan to add support for symbols and struct members.