Skip to content

Label properties before using property slicer #998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions regression/cbmc/full_slice1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <assert.h>

typedef enum {
A,
B,
C
} node_t;

void doit(node_t *node);

static inline void foo(node_t *node) { }
static inline void bar(node_t *node) { }

void doit(node_t *node)
{
switch (*node)
{
case A:
foo(node);
*node=B;
bar(node);
return;
case C:
*node=B;
bar(node);
return;
}
}

int main()
{
node_t node=A;

char count=0;
while(count++<10)
{
char c;

doit(&node);

static char q=0;
q=0;

if(c==0)
{
assert(node == A);
}
}

return 0;
}
8 changes: 8 additions & 0 deletions regression/cbmc/full_slice1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.c
--full-slice --property main.assertion.1 --unwind 1
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED
--
^warning: ignoring
53 changes: 53 additions & 0 deletions regression/cbmc/full_slice2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <assert.h>

typedef enum {
A,
B,
C
} node_t;

void doit(node_t *node);

static inline void foo(node_t *node) { }
static inline void bar(node_t *node) { }

void doit(node_t *node)
{
switch (*node)
{
case A:
foo(node);
*node=B;
bar(node);
return;
case C:
*node=B;
bar(node);
return;
}
}

int main()
{
node_t node=A;

assert(&node);

char count=0;
while(count++<10)
{
char c;

doit(&node);

static char q=0;
q=0;

if(c==0)
{
assert(node==A);
}
}

return 0;
}
10 changes: 10 additions & 0 deletions regression/cbmc/full_slice2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
main.c
--full-slice --property main.assertion.2 --unwind 1
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED
--
^warning: ignoring
--
Tests whether properties are not relabelled after slicing.
26 changes: 17 additions & 9 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,6 @@ int cbmc_parse_optionst::doit()
if(get_goto_program_ret!=-1)
return get_goto_program_ret;

label_properties(goto_functions);

if(cmdline.isset("show-claims") || // will go away
cmdline.isset("show-properties")) // use this one
{
Expand Down Expand Up @@ -801,13 +799,6 @@ bool cbmc_parse_optionst::process_goto_program(
status() << "Generic Property Instrumentation" << eom;
goto_check(ns, options, goto_functions);

// full slice?
if(cmdline.isset("full-slice"))
{
status() << "Performing a full slice" << eom;
full_slicer(goto_functions, ns);
}

// checks don't know about adjusted float expressions
adjust_float_expressions(goto_functions, ns);

Expand Down Expand Up @@ -857,6 +848,23 @@ bool cbmc_parse_optionst::process_goto_program(
return true;
}

// label the assertions
// This must be done after adding assertions and
// before using the argument of the "property" option.
// Do not re-label after using the property slicer because
// this would cause the property identifiers to change.
label_properties(goto_functions);

// full slice?
if(cmdline.isset("full-slice"))
{
status() << "Performing a full slice" << eom;
if(cmdline.isset("property"))
property_slicer(goto_functions, ns, cmdline.get_values("property"));
else
full_slicer(goto_functions, ns);
}

// remove skips
remove_skip(goto_functions);
goto_functions.update();
Expand Down
3 changes: 0 additions & 3 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,9 +1417,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
full_slicer(goto_functions, ns);
}

// label the assertions
label_properties(goto_functions);

// recalculate numbers, etc.
goto_functions.update();
}
Expand Down