Skip to content

Commit 0c727f3

Browse files
author
klaas
committed
Reworks checking of code contracts
This commit completes the work started in the previous commit by revising the existing contract-handling code into the new pass --check-code-contracts, which first applies all contracts and then checks them. By applying the contracts before checking begins, this checks the relative correctness of each function/loop with respect to the functions called by/loops contained in it. Since there can be no infinite sequence of nested functions/loops, these relative correctness results together imply the correctness of the overall program. We take this approach rather than checking entirely without using contracts because it allows significant reuse of results --- a function that is called many times only needs to be checked once, and all of its invocations will be abstracted out by the contract application.
1 parent 94cd8be commit 0c727f3

File tree

12 files changed

+379
-67
lines changed

12 files changed

+379
-67
lines changed
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
CORE
22
main.c
3-
--apply-code-contracts
3+
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
--check-code-contracts not implemented yet.
10-
--apply-code-contracts is the current name for the flag. This should be
11-
updated as the flag changes.
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
main.c
3-
--apply-code-contracts
3+
--check-code-contracts
44
^\[main.assertion.1\] assertion x == 0: SUCCESS$
55
^\[foo.1\] : FAILURE$
66
^VERIFICATION FAILED$
77
--
88
--
9-
--check-code-contracts not implemented yet.
10-
--apply-code-contracts is the current name for the flag. This should be
11-
updated as the flag changes.

regression/contracts/function_check_mem_01/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void foo(bar *x)
3333
__CPROVER_requires(__CPROVER_VALID_MEM(x, sizeof(bar)))
3434
{
3535
x->x += 1;
36-
return
36+
return;
3737
}
3838

3939
int main()

regression/contracts/function_check_mem_01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--check-code-contracts
44
^EXIT=0$
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
main.c
3-
--apply-code-contracts
3+
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
--check-code-contracts not implemented yet.
10-
--apply-code-contracts is the current name for the flag. This should be
11-
updated as the flag changes.
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
main.c
3-
--apply-code-contracts
3+
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
--check-code-contracts not implemented yet.
10-
--apply-code-contracts is the current name for the flag. This should be
11-
updated as the flag changes.
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
main.c
3-
--apply-code-contracts
3+
--check-code-contracts
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
77
--
88
--
9-
--check-code-contracts not implemented yet.
10-
--apply-code-contracts is the current name for the flag. This should be
11-
updated as the flag changes.
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
KNOWNBUG
1+
CORE
22
main.c
3-
--apply-code-contracts
3+
--check-code-contracts
44
^\[main.1\] Loop invariant violated before entry: SUCCESS$
55
^\[main.2\] Loop invariant not preserved: SUCCESS$
66
^\[main.assertion.1\] assertion r == 0: FAILURE$
77
^VERIFICATION FAILED$
88
--
99
--
10-
--check-code-contracts not implemented yet.
11-
--apply-code-contracts is the current name for the flag. This should be
12-
updated as the flag changes.

0 commit comments

Comments
 (0)