Skip to content

Commit 045aeb7

Browse files
author
Daniel Kroening
committed
Merge pull request #21 from tautschnig/property-specific-slicing
Slice with respect to select properties
2 parents 7c271af + 9b34522 commit 045aeb7

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed

src/goto-instrument/full_slicer.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,27 @@ void full_slicer(
473473

474474
/*******************************************************************\
475475
476+
Function: property_slicer
477+
478+
Inputs:
479+
480+
Outputs:
481+
482+
Purpose:
483+
484+
\*******************************************************************/
485+
486+
void property_slicer(
487+
goto_functionst &goto_functions,
488+
const namespacet &ns,
489+
const std::list<std::string> &properties)
490+
{
491+
properties_criteriont p(properties);
492+
full_slicert()(goto_functions, ns, p);
493+
}
494+
495+
/*******************************************************************\
496+
476497
Function: slicing_criteriont::~slicing_criteriont
477498
478499
Inputs:

src/goto-instrument/full_slicer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ void full_slicer(
1515
goto_functionst &goto_functions,
1616
const namespacet &ns);
1717

18+
void property_slicer(
19+
goto_functionst &goto_functions,
20+
const namespacet &ns,
21+
const std::list<std::string> &properties);
22+
1823
class slicing_criteriont
1924
{
2025
public:

src/goto-instrument/full_slicer_class.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,35 @@ class assert_criteriont:public slicing_criteriont
118118
}
119119
};
120120

121+
class properties_criteriont:public slicing_criteriont
122+
{
123+
public:
124+
explicit properties_criteriont(
125+
const std::list<std::string> &properties):
126+
property_ids(properties)
127+
{
128+
}
129+
130+
virtual bool operator()(goto_programt::const_targett target)
131+
{
132+
if(!target->is_assert())
133+
return false;
134+
135+
const std::string &p_id=
136+
id2string(target->source_location.get_property_id());
137+
138+
for(std::list<std::string>::const_iterator
139+
it=property_ids.begin();
140+
it!=property_ids.end();
141+
++it)
142+
if(p_id==*it)
143+
return true;
144+
145+
return false;
146+
}
147+
148+
protected:
149+
const std::list<std::string> &property_ids;
150+
};
151+
121152
#endif

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,9 @@ void goto_instrument_parse_optionst::instrument_goto_program()
12241224
// add loop ids
12251225
goto_functions.compute_loop_numbers();
12261226

1227+
// label the assertions
1228+
label_properties(goto_functions);
1229+
12271230
// nondet volatile?
12281231
if(cmdline.isset("nondet-volatile"))
12291232
{
@@ -1246,7 +1249,10 @@ void goto_instrument_parse_optionst::instrument_goto_program()
12461249
symbol_table, goto_functions, cmdline.isset("pointer-check"));
12471250

12481251
status() << "Performing a full slice" << eom;
1249-
full_slicer(goto_functions, ns);
1252+
if(cmdline.isset("property"))
1253+
property_slicer(goto_functions, ns, cmdline.get_values("property"));
1254+
else
1255+
full_slicer(goto_functions, ns);
12501256
}
12511257

12521258
// label the assertions
@@ -1347,6 +1353,7 @@ void goto_instrument_parse_optionst::help()
13471353
"Slicing:\n"
13481354
" --reachability-slice slice away instructions that can't reach assertions\n"
13491355
" --full-slice slice away instructions that don't affect assertions\n"
1356+
" --property id slice with respect to specific property only\n"
13501357
"\n"
13511358
"Further transformations:\n"
13521359
" --constant-propagator propagate constants and simplify expressions\n"

src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Author: Daniel Kroening, [email protected]
4949
"(show-uninitialized)(show-locations)" \
5050
"(full-slice)(reachability-slice)" \
5151
"(inline)" \
52-
"(show-claims)(show-properties)" \
52+
"(show-claims)(show-properties)(property):" \
5353
"(show-symbol-table)(show-points-to)(show-rw-set)" \
5454
"(cav11)" \
5555
"(show-natural-loops)(accelerate)(havoc-loops)" \

0 commit comments

Comments
 (0)