Skip to content

Slice with respect to select properties #21

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 1 commit into from
Apr 2, 2016
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
21 changes: 21 additions & 0 deletions src/goto-instrument/full_slicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,27 @@ void full_slicer(

/*******************************************************************\

Function: property_slicer

Inputs:

Outputs:

Purpose:

\*******************************************************************/

void property_slicer(
goto_functionst &goto_functions,
const namespacet &ns,
const std::list<std::string> &properties)
{
properties_criteriont p(properties);
full_slicert()(goto_functions, ns, p);
}

/*******************************************************************\

Function: slicing_criteriont::~slicing_criteriont

Inputs:
Expand Down
5 changes: 5 additions & 0 deletions src/goto-instrument/full_slicer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ void full_slicer(
goto_functionst &goto_functions,
const namespacet &ns);

void property_slicer(
goto_functionst &goto_functions,
const namespacet &ns,
const std::list<std::string> &properties);

class slicing_criteriont
{
public:
Expand Down
31 changes: 31 additions & 0 deletions src/goto-instrument/full_slicer_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,35 @@ class assert_criteriont:public slicing_criteriont
}
};

class properties_criteriont:public slicing_criteriont
{
public:
explicit properties_criteriont(
const std::list<std::string> &properties):
property_ids(properties)
{
}

virtual bool operator()(goto_programt::const_targett target)
{
if(!target->is_assert())
return false;

const std::string &p_id=
id2string(target->source_location.get_property_id());

for(std::list<std::string>::const_iterator
it=property_ids.begin();
it!=property_ids.end();
++it)
if(p_id==*it)
return true;

return false;
}

protected:
const std::list<std::string> &property_ids;
};

#endif
9 changes: 8 additions & 1 deletion src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,9 @@ void goto_instrument_parse_optionst::instrument_goto_program()
// add loop ids
goto_functions.compute_loop_numbers();

// label the assertions
label_properties(goto_functions);

// nondet volatile?
if(cmdline.isset("nondet-volatile"))
{
Expand All @@ -1238,7 +1241,10 @@ void goto_instrument_parse_optionst::instrument_goto_program()
symbol_table, goto_functions, cmdline.isset("pointer-check"));

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

// label the assertions
Expand Down Expand Up @@ -1339,6 +1345,7 @@ void goto_instrument_parse_optionst::help()
"Slicing:\n"
" --reachability-slice slice away instructions that can't reach assertions\n"
" --full-slice slice away instructions that don't affect assertions\n"
" --property id slice with respect to specific property only\n"
"\n"
"Further transformations:\n"
" --constant-propagator propagate constants and simplify expressions\n"
Expand Down
2 changes: 1 addition & 1 deletion src/goto-instrument/goto_instrument_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Author: Daniel Kroening, [email protected]
"(show-uninitialized)(show-locations)" \
"(full-slice)(reachability-slice)" \
"(inline)" \
"(show-claims)(show-properties)" \
"(show-claims)(show-properties)(property):" \
"(show-symbol-table)(show-points-to)(show-rw-set)" \
"(cav11)" \
"(show-natural-loops)(accelerate)(havoc-loops)" \
Expand Down