-
Notifications
You must be signed in to change notification settings - Fork 274
[CONTRACTS] DFCC loop assigns infererence with functions inlined #8490
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
regression/contracts-dfcc/loop_assigns_inference-01/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
KNOWNBUG | ||
CORE dfcc-only | ||
main.c | ||
--dfcc main --apply-loop-contracts | ||
--dfcc main --apply-loop-contracts _ --no-standard-checks | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^\[body_1.assigns.\d+\] .* Check that j is assignable: SUCCESS$ | ||
^\[body_2.assigns.\d+\] .* Check that \*i is assignable: SUCCESS$ | ||
^\[body_3.assigns.\d+\] .* Check that \*i is assignable: SUCCESS$ | ||
^\[incr.assigns.\d+\] .* Check that \*i is assignable: SUCCESS$ | ||
^\[main.\d+\] .* Check loop invariant before entry: SUCCESS$ | ||
^\[main.\d+\] .* Check that loop invariant is preserved: SUCCESS$ | ||
^\[main.loop_invariant_base.\d+\] line \d+ Check invariant before entry for loop .*: SUCCESS$ | ||
^\[main.loop_invariant_step.\d+\] line \d+ Check invariant after step for loop .*: SUCCESS$ | ||
^\[main.loop_step_unwinding.\d+\] line \d+ Check step was unwound for loop .*: SUCCESS$ | ||
^\[main.assertion.\d+\] .* assertion j == 9: SUCCESS$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- | ||
This test checks loop locals are correctly removed during assigns inference so | ||
that the assign clause is correctly inferred. | ||
This test failed when using dfcc for loop contracts. |
22 changes: 22 additions & 0 deletions
22
regression/contracts-dfcc/loop_assigns_inference-04/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
struct hole | ||
{ | ||
int pos; | ||
}; | ||
|
||
void set_len(struct hole *h, unsigned long int new_len) | ||
{ | ||
h->pos = new_len; | ||
} | ||
|
||
int main() | ||
{ | ||
int i = 0; | ||
struct hole h; | ||
h.pos = 0; | ||
for(i = 0; i < 5; i++) | ||
// __CPROVER_assigns(h.pos, i) | ||
__CPROVER_loop_invariant(h.pos == i) | ||
{ | ||
set_len(&h, h.pos + 1); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
regression/contracts-dfcc/loop_assigns_inference-04/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CORE dfcc-only | ||
main.c | ||
--dfcc main --apply-loop-contracts | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^\[main.loop_invariant_base.\d+\] line \d+ Check invariant before entry for loop .*: SUCCESS$ | ||
^\[main.loop_invariant_base.\d+\] line \d+ Check invariant before entry for loop .*: SUCCESS$ | ||
^\[main.loop_invariant_step.\d+\] line \d+ Check invariant after step for loop .*: SUCCESS$ | ||
^\[main.loop_step_unwinding.\d+\] line \d+ Check step was unwound for loop .*: SUCCESS$ | ||
^\[set_len.assigns.\d+\] line \d+ Check that h\-\>pos is assignable: SUCCESS | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- | ||
This test checks assigns h->pos is inferred correctly. |
17 changes: 17 additions & 0 deletions
17
regression/contracts-dfcc/loop_assigns_inference-05/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdlib.h> | ||
|
||
#define SIZE 8 | ||
|
||
int main() | ||
{ | ||
int i = 0; | ||
int *j = malloc(SIZE * sizeof(int)); | ||
for(i = 0; i < SIZE; i++) | ||
// __CPROVER_assigns(h.pos, i) | ||
__CPROVER_loop_invariant(0 <= i && i <= SIZE) | ||
{ | ||
int *k; | ||
k = j + i; | ||
*k = 1; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
regression/contracts-dfcc/loop_assigns_inference-05/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CORE dfcc-only | ||
main.c | ||
--no-malloc-may-fail --dfcc main --apply-loop-contracts | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^\[main.loop_invariant_base.\d+\] line \d+ Check invariant before entry for loop .*: SUCCESS$ | ||
^\[main.loop_invariant_base.\d+\] line \d+ Check invariant before entry for loop .*: SUCCESS$ | ||
^\[main.loop_invariant_step.\d+\] line \d+ Check invariant after step for loop .*: SUCCESS$ | ||
^\[main.loop_step_unwinding.\d+\] line \d+ Check step was unwound for loop .*: SUCCESS$ | ||
^\[main.assigns.\d+\] line \d+ Check that \*k is assignable: SUCCESS | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- | ||
This test checks assigns __CPROVER_object_whole(k) is inferred correctly, | ||
which requires widening *k to the whole object. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this change now strictly necessary given the additional widening?
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.
Yes, new addition widening will infer
object_whole(data), i
which is not accurate for this test.