Skip to content

Commit fcf61ad

Browse files
authored
Merge pull request #7232 from qinheping/crangler-loop-invariant
Crangler: support full loop contracts
2 parents dbd826f + a9a27fe commit fcf61ad

File tree

14 files changed

+126
-72
lines changed

14 files changed

+126
-72
lines changed

doc/man/crangler.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ The supported transformations are:
1515
.IP
1616
Add a contract (pre/post/assigns) to a named C function.
1717
.IP
18-
Add a loop invariant to a loop identified by the name of the function its in and
19-
a loop number.
18+
Add a loop contract to a loop identified by the name of the function containing
19+
the loop and a loop number.
2020
.IP
2121
Remove the
2222
.B static

regression/crangler/loop-invariant-01/test.desc renamed to regression/crangler/loop-contract-01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
test.json
33

4-
^\s+while\(i \< 2\) \_\_CPROVER\_loop\_invariant
4+
^\s+while\(i \< 2\) \_\_CPROVER\_assigns.*\_\_CPROVER\_loop\_invariant.*\_\_CPROVER_decreases
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"sources": [
3+
"main.c"
4+
],
5+
"functions": [
6+
{
7+
"foo": [
8+
"while 1 invariant i >= 0",
9+
"while 1 assigns i, __CPROVER_POINTER_OBJECT(arr)",
10+
"while 1 decreases 2-i"
11+
]
12+
}
13+
],
14+
"output": "stdout"
15+
}

regression/crangler/loop-invariant-02/test.desc renamed to regression/crangler/loop-contract-02/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
test.json
33

4-
^\s+for\(int i = 0; i \< 2; i\+\+\) \_\_CPROVER\_loop\_invariant
4+
^\s+for\(int i = 0; i \< 2; i\+\+\) \_\_CPROVER\_assigns.*\_\_CPROVER\_loop\_invariant.*\_\_CPROVER_decreases
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"sources": [
3+
"main.c"
4+
],
5+
"functions": [
6+
{
7+
"foo": [
8+
"for 1 invariant i >= 0",
9+
"for 1 assigns i, __CPROVER_POINTER_OBJECT(arr)",
10+
"for 1 decreases 2-i"
11+
]
12+
}
13+
],
14+
"output": "stdout"
15+
}

regression/crangler/loop-invariant-03/test.desc renamed to regression/crangler/loop-contract-03/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
test.json
33

4-
^\s+while\(i \< 2\) \_\_CPROVER\_loop\_invariant
4+
^\s+while\(i \< 2\) \_\_CPROVER\_assigns.*\_\_CPROVER\_loop\_invariant.*\_\_CPROVER_decreases
55
^EXIT=0$
66
^SIGNAL=0$
77
--
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"sources": [
3+
"main.c"
4+
],
5+
"functions": [
6+
{
7+
"foo": [
8+
"loop 2 assigns i, __CPROVER_POINTER_OBJECT(arr)",
9+
"loop 2 invariant i>=0",
10+
"loop 2 decreases 2-i"
11+
]
12+
}
13+
],
14+
"output": "stdout"
15+
}

0 commit comments

Comments
 (0)