Skip to content

Commit c123d90

Browse files
committed
Disable clang-format for quantifier regression tests
Several of them use implication (==>), which clang-format does not know how to deal with as is isn't a native C/C++ operator. Line numbers in the test.desc files are updated given the comment lines have been inserted.
1 parent ab81ffc commit c123d90

File tree

15 files changed

+49
-13
lines changed

15 files changed

+49
-13
lines changed

regression/cbmc/Quantifiers-assertion/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ int main()
77
c[1][0]=1;
88
c[1][1]=2;
99

10+
// clang-format off
11+
// clang-format would rewrite the "==>" as "== >"
1012
__CPROVER_assert(__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_exists{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "Exists-Exists: successful");
1113

1214
__CPROVER_assert(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (!__CPROVER_exists{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotExists-NotExists: successful");
@@ -18,6 +20,7 @@ int main()
1820
__CPROVER_assert(!__CPROVER_forall { int i; (i>=0 && i<2) ==> (__CPROVER_forall{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotForall-Forall: successful");
1921

2022
__CPROVER_assert(!__CPROVER_forall { int i; (i>=0 && i<2) ==> (!__CPROVER_forall{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotForall-NotForall: successful");
23+
// clang-format on
2124

2225
return 0;
2326
}

regression/cbmc/Quantifiers-assignment/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ int main()
44
a[0]=1;
55
a[1]=2;
66

7+
// clang-format off
8+
// clang-format would rewrite the "==>" as "== >"
79
int x=__CPROVER_forall { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<=10 };
810
int y=__CPROVER_forall { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<2 };
911
int z1=__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<1.5 };
1012
int z2=__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<2*10 };
13+
// clang-format on
1114

1215
assert(x);
1316
assert(y);

regression/cbmc/Quantifiers-copy/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ int main()
99
a[3]=3;
1010
a[4]=4;
1111

12+
// clang-format off
13+
// clang-format would rewrite the "==>" as "== >"
1214
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<5) ==> b[i]==a[i]});
15+
// clang-format on
1316

1417
assert(b[0]==0);
1518
assert(b[1]==1);

regression/cbmc/Quantifiers-if/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ int main()
44
a[0]=1;
55
a[1]=2;
66

7+
// clang-format off
8+
// clang-format would rewrite the "==>" as "== >"
79
if(__CPROVER_forall { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<=10 })
810
__CPROVER_assert(0, "failure 1");
911

@@ -18,6 +20,7 @@ int main()
1820

1921
if(__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=5 && a[i]<=10 })
2022
__CPROVER_assert(0, "success 2");
23+
// clang-format on
2124

2225
return 0;
2326
}

regression/cbmc/Quantifiers-initialisation/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ int main()
22
{
33
int a[5];
44

5+
// clang-format off
6+
// clang-format would rewrite the "==>" as "== >"
57
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<5) ==> a[i]==i+1});
8+
// clang-format on
69

710
assert(a[0]==1);
811
assert(a[1]==2);

regression/cbmc/Quantifiers-initialisation2/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ int main()
33
int a[10];
44
int c[10];
55

6+
// clang-format off
7+
// clang-format would rewrite the "==>" as "== >"
68
// C# style
79
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<9+1) ==> a[i]>=1 && a[i]<=10 });
810
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<10) ==> __CPROVER_forall{int j; (j>i && j<10) ==> a[j]>a[i]} });
@@ -14,5 +16,6 @@ int main()
1416
assert(a[2]>a[3]);
1517
__CPROVER_assert(__CPROVER_forall {unsigned i; (i>=1 && i<10) ==> c[i-1]<=c[i]}, "forall c[]");
1618
assert(c[3]>=c[1]);
19+
// clang-format on
1720
return 0;
1821
}

regression/cbmc/Quantifiers-invalid-var-range/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ int main()
22
{
33

44
int a[3][3];
5+
// clang-format off
6+
// clang-format would rewrite the "==>" as "== >"
57
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<5) ==> __CPROVER_exists{int j; (j>=i && j<3) ==> a[i][j]==10} });
8+
// clang-format on
69

710
assert(a[0][0]==10||a[0][1]==10||a[0][2]==10);
811

regression/cbmc/Quantifiers-not-exists/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ int main()
66
int c[2][2];
77
int d[2][2];
88

9+
// clang-format off
10+
// clang-format would rewrite the "==>" as "== >"
911
__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_exists{int j; (j>=0 && j<2) ==> a[i][j]<=10}) });
1012

1113
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<2) ==> (!__CPROVER_exists{int j; (j>=0 && j<2) ==> b[i][j]>=1 && b[i][j]<=10}) });
1214

1315
__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (!__CPROVER_exists{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) });
1416

1517
__CPROVER_assume(!__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_forall{int j; (j>=0 && j<2) ==> d[i][j]>=1 && d[i][j]<=10}) });
18+
// clang-format on
1619

1720

1821
assert(a[0][0]>10);

regression/cbmc/Quantifiers-not-exists/test.desc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ CORE
22
main.c
33

44
^\*\* Results:$
5-
^\[main.assertion.1\] line 18 assertion a\[.*\]\[.*\] > 10: SUCCESS$
6-
^\[main.assertion.2\] line 20 assertion tmp_if_expr\$\d+: SUCCESS$
7-
^\[main.assertion.3\] line 21 assertion tmp_if_expr\$\d+: SUCCESS$
8-
^\[main.assertion.4\] line 23 assertion tmp_if_expr\$\d+: SUCCESS$
9-
^\[main.assertion.5\] line 25 assertion tmp_if_expr\$\d+: SUCCESS$
10-
^\[main.assertion.6\] line 26 assertion tmp_if_expr\$\d+: SUCCESS$
5+
^\[main.assertion.1\] line 21 assertion a\[.*\]\[.*\] > 10: SUCCESS$
6+
^\[main.assertion.2\] line 23 assertion tmp_if_expr\$\d+: SUCCESS$
7+
^\[main.assertion.3\] line 24 assertion tmp_if_expr\$\d+: SUCCESS$
8+
^\[main.assertion.4\] line 26 assertion tmp_if_expr\$\d+: SUCCESS$
9+
^\[main.assertion.5\] line 28 assertion tmp_if_expr\$\d+: SUCCESS$
10+
^\[main.assertion.6\] line 29 assertion tmp_if_expr\$\d+: SUCCESS$
1111
^\*\* 0 of 6 failed
1212
^VERIFICATION SUCCESSFUL$
1313
^EXIT=0$

regression/cbmc/Quantifiers-not/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ int main()
44
a[0]=1;
55
a[1]=2;
66

7+
// clang-format off
8+
// clang-format would rewrite the "==>" as "== >"
79
if(!__CPROVER_forall { int i; (i>=0 && i<2) ==> a[i]>=1 && a[i]<=10 })
810
__CPROVER_assert(0, "success 1");
911

@@ -18,6 +20,7 @@ int main()
1820

1921
if(!__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=5 && a[i]<=10 })
2022
__CPROVER_assert(0, "failure 2");
23+
// clang-format on
2124

2225
return 0;
2326
}

regression/cbmc/Quantifiers-two-dimension-array/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ int main()
33
int a[2][2];
44
int b[2][2];
55

6+
// clang-format off
7+
// clang-format would rewrite the "==>" as "== >"
68
__CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<2) ==> (__CPROVER_forall{int j; (j>=0 && j<2) ==> a[i][j]==i+j}) });
79
__CPROVER_assume(__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_exists{int j; (j>=0 && j<2) ==> b[i][j]==i+j+1}) });
10+
// clang-format on
811

912
assert(a[0][0]==0);
1013
assert(a[0][1]==1);

regression/cbmc/Quantifiers-two-dimension-array/test.desc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ CORE
22
main.c
33

44
^\*\* Results:$
5-
^\[main.assertion.1\] line 9 assertion a\[.*\]\[.*\] == 0: SUCCESS$
6-
^\[main.assertion.2\] line 10 assertion a\[.*\]\[.*\] == 1: SUCCESS$
7-
^\[main.assertion.3\] line 11 assertion a\[.*\]\[.*\] == 1: SUCCESS$
8-
^\[main.assertion.4\] line 12 assertion a\[.*\]\[.*\] == 2: SUCCESS$
9-
^\[main.assertion.5\] line 13 assertion tmp_if_expr\$\d+: SUCCESS$
5+
^\[main.assertion.1\] line 12 assertion a\[.*\]\[.*\] == 0: SUCCESS$
6+
^\[main.assertion.2\] line 13 assertion a\[.*\]\[.*\] == 1: SUCCESS$
7+
^\[main.assertion.3\] line 14 assertion a\[.*\]\[.*\] == 1: SUCCESS$
8+
^\[main.assertion.4\] line 15 assertion a\[.*\]\[.*\] == 2: SUCCESS$
9+
^\[main.assertion.5\] line 16 assertion tmp_if_expr\$\d+: SUCCESS$
1010
^\*\* 0 of 5 failed
1111
^VERIFICATION SUCCESSFUL$
1212
^EXIT=0$

regression/cbmc/Quantifiers-type/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ int main()
33
int a[2];
44
int b[2];
55

6+
// clang-format off
7+
// clang-format would rewrite the "==>" as "== >"
68
__CPROVER_assume( __CPROVER_forall { float i; (i>=0 && i<2) ==> a[i]>=10 && a[i]<=10 } );
79
__CPROVER_assume( __CPROVER_forall { char i; (i>=0 && i<2) ==> b[i]>=10 && b[i]<=10 } );
10+
// clang-format on
811

912
assert(a[0]==10 && a[1]==10);
1013
assert(b[0]==10 && b[1]==10);

regression/cbmc/Quantifiers-type/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ CORE
22
main.c
33

44
^\*\* Results:$
5-
^\[main.assertion.1\] line 9 assertion tmp_if_expr(\$\d+)?: FAILURE$
6-
^\[main.assertion.2\] line 10 assertion tmp_if_expr\$\d+: SUCCESS$
5+
^\[main.assertion.1\] line 12 assertion tmp_if_expr(\$\d+)?: FAILURE$
6+
^\[main.assertion.2\] line 13 assertion tmp_if_expr\$\d+: SUCCESS$
77
^\*\* 1 of 2 failed
88
^VERIFICATION FAILED$
99
^EXIT=10$

regression/cbmc/Quantifiers1/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ int zero_array[10];
22

33
int main()
44
{
5+
// clang-format off
6+
// clang-format would rewrite the "==>" as "== >"
57
// C# style
68
assert(__CPROVER_forall { int i; (i>=0 && i<10) ==> zero_array[i]==0 });
79

@@ -20,4 +22,5 @@ int main()
2022

2123
assert(__CPROVER_forall {unsigned i; i>9 || c[i]==i});
2224
return 0;
25+
// clang-format on
2326
}

0 commit comments

Comments
 (0)