Skip to content

Commit 7ddee5f

Browse files
author
Daniel Kroening
authored
Merge pull request #732 from tautschnig/reachability-slice
Support --property with --reachability-slice
2 parents 57f9fa6 + 21d1bfa commit 7ddee5f

7 files changed

+52
-15
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
5.8
22
===
33

4+
* GOTO-INSTRUMENT: --reachability-slice can be used with --property to slice
5+
down to a single property only.
46
* GOTO-INSTRUMENT: New option --list-calls-args
57
* GOTO-INSTRUMENT: New option --print-path-lenghts
68
* GOTO-ANALYZER: New option --unreachable-functions, --reachable-functions

src/goto-instrument/full_slicer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <goto-programs/remove_skip.h>
1515

16-
#include <analyses/dependence_graph.h>
17-
18-
#include "full_slicer.h"
1916
#include "full_slicer_class.h"
2017

2118
/*******************************************************************\

src/goto-instrument/full_slicer_class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Author: Daniel Kroening, [email protected]
1616
#include <goto-programs/goto_functions.h>
1717
#include <goto-programs/cfg.h>
1818

19-
#include <analyses/cfg_dominators.h>
19+
#include <analyses/dependence_graph.h>
20+
21+
#include "full_slicer.h"
2022

2123
// #define DEBUG_FULL_SLICERT
2224
#if 0
@@ -30,8 +32,6 @@ echo 'digraph g {' > c.dot ; cat c.goto | \
3032
dot -Tpdf -oc-red.pdf c-red.dot
3133
#endif
3234

33-
class dependence_grapht;
34-
3535
/*******************************************************************\
3636
3737
Class: full_slicert

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,10 @@ void goto_instrument_parse_optionst::instrument_goto_program()
15021502
if(cmdline.isset("reachability-slice"))
15031503
{
15041504
status() << "Performing a reachability slice" << eom;
1505-
reachability_slicer(goto_functions);
1505+
if(cmdline.isset("property"))
1506+
reachability_slicer(goto_functions, cmdline.get_values("property"));
1507+
else
1508+
reachability_slicer(goto_functions);
15061509
}
15071510

15081511
// full slice?

src/goto-instrument/reachability_slicer.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
#include <goto-programs/remove_unreachable.h>
1414
#include <goto-programs/cfg.h>
1515

16+
#include "full_slicer_class.h"
1617
#include "reachability_slicer.h"
1718
#include "reachability_slicer_class.h"
1819

@@ -29,15 +30,16 @@ Function: reachability_slicert::fixedpoint_assertions
2930
\*******************************************************************/
3031

3132
void reachability_slicert::fixedpoint_assertions(
32-
const is_threadedt &is_threaded)
33+
const is_threadedt &is_threaded,
34+
slicing_criteriont &criterion)
3335
{
3436
queuet queue;
3537

3638
for(cfgt::entry_mapt::iterator
3739
e_it=cfg.entry_map.begin();
3840
e_it!=cfg.entry_map.end();
3941
e_it++)
40-
if(e_it->first->is_assert() ||
42+
if(criterion(e_it->first) ||
4143
is_threaded(e_it->first))
4244
queue.push(e_it->second);
4345

@@ -77,7 +79,7 @@ Function: reachability_slicert::slice
7779
void reachability_slicert::slice(goto_functionst &goto_functions)
7880
{
7981
// now replace those instructions that do not reach any assertions
80-
// by self-loops
82+
// by assume(false)
8183

8284
Forall_goto_functions(f_it, goto_functions)
8385
if(f_it->second.body_available())
@@ -87,7 +89,7 @@ void reachability_slicert::slice(goto_functionst &goto_functions)
8789
const cfgt::nodet &e=cfg[cfg.entry_map[i_it]];
8890
if(!e.reaches_assertion &&
8991
!i_it->is_end_function())
90-
i_it->make_goto(i_it);
92+
i_it->make_assumption(false_exprt());
9193
}
9294

9395
// replace unreachable code by skip
@@ -113,5 +115,28 @@ Function: reachability_slicer
113115

114116
void reachability_slicer(goto_functionst &goto_functions)
115117
{
116-
reachability_slicert()(goto_functions);
118+
reachability_slicert s;
119+
assert_criteriont a;
120+
s(goto_functions, a);
121+
}
122+
123+
/*******************************************************************\
124+
125+
Function: reachability_slicer
126+
127+
Inputs:
128+
129+
Outputs:
130+
131+
Purpose:
132+
133+
\*******************************************************************/
134+
135+
void reachability_slicer(
136+
goto_functionst &goto_functions,
137+
const std::list<std::string> &properties)
138+
{
139+
reachability_slicert s;
140+
properties_criteriont p(properties);
141+
s(goto_functions, p);
117142
}

src/goto-instrument/reachability_slicer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ Author: Daniel Kroening, [email protected]
1313

1414
void reachability_slicer(goto_functionst &goto_functions);
1515

16+
void reachability_slicer(
17+
goto_functionst &goto_functions,
18+
const std::list<std::string> &properties);
19+
1620
#endif // CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_H

src/goto-instrument/reachability_slicer_class.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <analyses/is_threaded.h>
1616

17+
class slicing_criteriont;
18+
1719
/*******************************************************************\
1820
1921
Class: reachability_slicert
@@ -25,11 +27,13 @@ Author: Daniel Kroening, [email protected]
2527
class reachability_slicert
2628
{
2729
public:
28-
void operator()(goto_functionst &goto_functions)
30+
void operator()(
31+
goto_functionst &goto_functions,
32+
slicing_criteriont &criterion)
2933
{
3034
cfg(goto_functions);
3135
is_threadedt is_threaded(goto_functions);
32-
fixedpoint_assertions(is_threaded);
36+
fixedpoint_assertions(is_threaded, criterion);
3337
slice(goto_functions);
3438
}
3539

@@ -48,7 +52,9 @@ class reachability_slicert
4852

4953
typedef std::stack<cfgt::entryt> queuet;
5054

51-
void fixedpoint_assertions(const is_threadedt &is_threaded);
55+
void fixedpoint_assertions(
56+
const is_threadedt &is_threaded,
57+
slicing_criteriont &criterion);
5258

5359
void slice(goto_functionst &goto_functions);
5460
};

0 commit comments

Comments
 (0)