Skip to content

Commit 702bbd9

Browse files
author
Remi Delmas
committed
formatting
1 parent 6dbdf3f commit 702bbd9

File tree

8 files changed

+42
-27
lines changed

8 files changed

+42
-27
lines changed

doc/cprover-manual/properties.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,21 @@ As all of these checks apply across the entire input program, we may wish to
134134
disable them for selected statements in the program. For example, unsigned
135135
overflows can be expected and acceptable in certain instructions even when
136136
elsewhere we do not expect them. As of version 5.12, CBMC supports selectively
137-
disabling or enabling automatically generated properties using pragmas.
137+
disabling or enabling automatically generated properties using pragmas.
138138
139139
140140
CPROVER pragmas are handled using a stack:
141141
- `#pragma CPROVER check push` pushes a new level on the pragma stack
142-
- `#pragma CPROVER check disable "<name_of_check>"` adds a disable pragma at the top of the stack
143-
- `#pragma CPROVER check enable "<name_of_check>"` adds a enable pragma at the top of the stack
144-
- an `enable` or `disable` pragma for a given check present at the top level of the stack shadows other pragmas for the same in lower levels of the stack
145-
- adding both `enable` and `disable` pragmas for a same check in a same level of the stack creates a PARSING_ERROR.
146-
- `#pragma CPROVER check pop` pops a level in the stack and restores the state of pragmas at the sub level
142+
- `#pragma CPROVER check disable "<name_of_check>"` adds a disable pragma
143+
at the top of the stack
144+
- `#pragma CPROVER check enable "<name_of_check>"` adds a enable pragma
145+
at the top of the stack
146+
- an `enable` or `disable` pragma for a given check present at the top level
147+
of the stack shadows other pragmas for the same in lower levels of the stack
148+
- adding both `enable` and `disable` pragmas for a same check in a same level
149+
of the stack creates a PARSING_ERROR.
150+
- `#pragma CPROVER check pop` pops a level in the stack and restores the state
151+
of pragmas at the sub level
147152
148153
For example, for unsigned overflow checks, use
149154
@@ -152,9 +157,11 @@ unsigned foo(unsigned x)
152157
{
153158
#pragma CPROVER check push
154159
#pragma CPROVER check enable "unsigned-overflow"
155-
x = x + 1; // immediately follows the pragma, unsigned overflow check apply here
160+
// unsigned overflow check apply here
161+
x = x + 1;
156162
#pragma CPROVER check pop
157-
x = x + 2; // unsigned overflow checks do not apply here
163+
// unsigned overflow checks do not apply here
164+
x = x + 2;
158165
```
159166
160167
```
@@ -163,14 +170,18 @@ unsigned foo(unsigned x)
163170
#pragma CPROVER check push
164171
#pragma CPROVER check enable "unsigned-overflow"
165172
#pragma CPROVER check enable "signed-overflow"
166-
x = x + 1; // unsigned and signed overflow check apply here
173+
// unsigned and signed overflow check apply here
174+
x = x + 1;
167175
#pragma CPROVER check push
168176
#pragma CPROVER check disable "unsigned-overflow"
169-
x = x + 2; // only signed overflow check apply here
177+
// only signed overflow check apply here
178+
x = x + 2;
170179
#pragma CPROVER check pop
171-
x = x + 3; // unsigned and signed overflow check apply here
180+
// unsigned and signed overflow check apply here
181+
x = x + 3;
172182
#pragma CPROVER check pop
173-
x = x + 2; // unsigned overflow checks do not apply here
183+
// unsigned overflow checks do not apply here
184+
x = x + 2;
174185
```
175186
176187
```
@@ -179,19 +190,19 @@ unsigned foo(unsigned x)
179190
#pragma CPROVER check push
180191
#pragma CPROVER check enable "unsigned-overflow"
181192
#pragma CPROVER check enable "signed-overflow"
182-
x = x + 1; // unsigned and signed overflow check apply here
193+
// unsigned and signed overflow check apply here
194+
x = x + 1;
183195
#pragma CPROVER check push
184196
#pragma CPROVER check disable "unsigned-overflow"
185-
#pragma CPROVER check enable "unsigned-overflow"
186-
// PARSING_ERROR ... Found enable and disable pragmas for unsigned-overflow-check
197+
#pragma CPROVER check enable "unsigned-overflow"
198+
// PARSING_ERROR Found enable and disable pragmas for unsigned-overflow-check
187199
x = x + 2;
188200
#pragma CPROVER check pop
189201
x = x + 3;
190202
#pragma CPROVER check pop
191203
x = x + 2;
192204
```
193205
194-
195206
#### Flag --nan-check limitations
196207
197208
Please note that `--nan-check` flag is adding not-a-number checks only for

regression/cbmc/pragma_cprover_enable1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ main.c
99
^SIGNAL=0$
1010
--
1111
--
12-
Checks that we can selectively activate checks using pragmas.
12+
Checks that we can selectively activate checks using pragmas.

regression/cbmc/pragma_cprover_enable3/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ main.c
1414
^EXIT=10$
1515
^SIGNAL=0$
1616
--
17-
^\[main.pointer_primitives.\d+\] line 17
17+
^\[main.pointer_primitives.\d+\] line 17
1818
--

regression/cbmc/pragma_cprover_enable_disable_global_off/test.desc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ main.c
3030
^EXIT=10$
3131
^SIGNAL=0$
3232
--
33-
^\[main.pointer_primitives.\d+\] line 17
34-
^\[main.pointer_primitives.\d+\] line 28
35-
^\[main.pointer_primitives.\d+\] line 38
33+
^\[main.pointer_primitives.\d+\] line 17
34+
^\[main.pointer_primitives.\d+\] line 28
35+
^\[main.pointer_primitives.\d+\] line 38
3636
--

regression/cbmc/pragma_cprover_enable_disable_global_on/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ main.c
3838
^EXIT=10$
3939
^SIGNAL=0$
4040
--
41-
^\[main.pointer_primitives.\d+\] line 17
42-
^\[main.pointer_primitives.\d+\] line 28
41+
^\[main.pointer_primitives.\d+\] line 17
42+
^\[main.pointer_primitives.\d+\] line 28
4343
--

src/analyses/goto_check.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,8 +1917,7 @@ void goto_checkt::goto_check(
19171917
const auto &pragmas = i.source_location().get_pragmas();
19181918
for(const auto &d : pragmas)
19191919
{
1920-
auto err_msg = [&]()
1921-
{
1920+
auto err_msg = [&]() {
19221921
return "Found enable and disable pragmas for " + id2string(d.first) +
19231922
" at \n" + i.source_location().pretty();
19241923
};
@@ -2041,8 +2040,7 @@ void goto_checkt::goto_check(
20412040
// safety
20422041
{
20432042
flag_resett no_enum_check_flag_resetter;
2044-
auto err_msg = [&]()
2045-
{
2043+
auto err_msg = [&]() {
20462044
return "no_enum_check flag disabled and enabled at \n" +
20472045
i.source_location().pretty();
20482046
};

src/ansi-c/ansi_c_parser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*******************************************************************\
2+
23
Module:
4+
35
Author: Daniel Kroening, [email protected]
6+
47
\*******************************************************************/
58

69
#include "ansi_c_parser.h"

src/ansi-c/ansi_c_parser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*******************************************************************\
2+
23
Module:
4+
35
Author: Daniel Kroening, [email protected]
6+
47
\*******************************************************************/
58

69

0 commit comments

Comments
 (0)