Skip to content

Commit 74e21ce

Browse files
author
Daniel Kroening
authored
Merge pull request #998 from peterschrammel/label-properties-before-full-slice
Label properties before using property slicer
2 parents e2afe93 + 40983dd commit 74e21ce

File tree

6 files changed

+139
-12
lines changed

6 files changed

+139
-12
lines changed

regression/cbmc/full_slice1/main.c

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <assert.h>
2+
3+
typedef enum {
4+
A,
5+
B,
6+
C
7+
} node_t;
8+
9+
void doit(node_t *node);
10+
11+
static inline void foo(node_t *node) { }
12+
static inline void bar(node_t *node) { }
13+
14+
void doit(node_t *node)
15+
{
16+
switch (*node)
17+
{
18+
case A:
19+
foo(node);
20+
*node=B;
21+
bar(node);
22+
return;
23+
case C:
24+
*node=B;
25+
bar(node);
26+
return;
27+
}
28+
}
29+
30+
int main()
31+
{
32+
node_t node=A;
33+
34+
char count=0;
35+
while(count++<10)
36+
{
37+
char c;
38+
39+
doit(&node);
40+
41+
static char q=0;
42+
q=0;
43+
44+
if(c==0)
45+
{
46+
assert(node == A);
47+
}
48+
}
49+
50+
return 0;
51+
}

regression/cbmc/full_slice1/test.desc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--full-slice --property main.assertion.1 --unwind 1
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED
7+
--
8+
^warning: ignoring

regression/cbmc/full_slice2/main.c

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <assert.h>
2+
3+
typedef enum {
4+
A,
5+
B,
6+
C
7+
} node_t;
8+
9+
void doit(node_t *node);
10+
11+
static inline void foo(node_t *node) { }
12+
static inline void bar(node_t *node) { }
13+
14+
void doit(node_t *node)
15+
{
16+
switch (*node)
17+
{
18+
case A:
19+
foo(node);
20+
*node=B;
21+
bar(node);
22+
return;
23+
case C:
24+
*node=B;
25+
bar(node);
26+
return;
27+
}
28+
}
29+
30+
int main()
31+
{
32+
node_t node=A;
33+
34+
assert(&node);
35+
36+
char count=0;
37+
while(count++<10)
38+
{
39+
char c;
40+
41+
doit(&node);
42+
43+
static char q=0;
44+
q=0;
45+
46+
if(c==0)
47+
{
48+
assert(node==A);
49+
}
50+
}
51+
52+
return 0;
53+
}

regression/cbmc/full_slice2/test.desc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--full-slice --property main.assertion.2 --unwind 1
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED
7+
--
8+
^warning: ignoring
9+
--
10+
Tests whether properties are not relabelled after slicing.

src/cbmc/cbmc_parse_options.cpp

+17-9
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,6 @@ int cbmc_parse_optionst::doit()
456456
if(get_goto_program_ret!=-1)
457457
return get_goto_program_ret;
458458

459-
label_properties(goto_functions);
460-
461459
if(cmdline.isset("show-claims") || // will go away
462460
cmdline.isset("show-properties")) // use this one
463461
{
@@ -801,13 +799,6 @@ bool cbmc_parse_optionst::process_goto_program(
801799
status() << "Generic Property Instrumentation" << eom;
802800
goto_check(ns, options, goto_functions);
803801

804-
// full slice?
805-
if(cmdline.isset("full-slice"))
806-
{
807-
status() << "Performing a full slice" << eom;
808-
full_slicer(goto_functions, ns);
809-
}
810-
811802
// checks don't know about adjusted float expressions
812803
adjust_float_expressions(goto_functions, ns);
813804

@@ -857,6 +848,23 @@ bool cbmc_parse_optionst::process_goto_program(
857848
return true;
858849
}
859850

851+
// label the assertions
852+
// This must be done after adding assertions and
853+
// before using the argument of the "property" option.
854+
// Do not re-label after using the property slicer because
855+
// this would cause the property identifiers to change.
856+
label_properties(goto_functions);
857+
858+
// full slice?
859+
if(cmdline.isset("full-slice"))
860+
{
861+
status() << "Performing a full slice" << eom;
862+
if(cmdline.isset("property"))
863+
property_slicer(goto_functions, ns, cmdline.get_values("property"));
864+
else
865+
full_slicer(goto_functions, ns);
866+
}
867+
860868
// remove skips
861869
remove_skip(goto_functions);
862870
goto_functions.update();

src/goto-instrument/goto_instrument_parse_options.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -1417,9 +1417,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
14171417
full_slicer(goto_functions, ns);
14181418
}
14191419

1420-
// label the assertions
1421-
label_properties(goto_functions);
1422-
14231420
// recalculate numbers, etc.
14241421
goto_functions.update();
14251422
}

0 commit comments

Comments
 (0)