File tree Expand file tree Collapse file tree 4 files changed +61
-5
lines changed
regression/cbmc/reachability-slice-interproc2 Expand file tree Collapse file tree 4 files changed +61
-5
lines changed Original file line number Diff line number Diff line change
1
+ void b ();
2
+
3
+ void c ()
4
+ {
5
+ __CPROVER_assert (0 , "" );
6
+ b ();
7
+ }
8
+
9
+ void b ()
10
+ {
11
+ a ();
12
+ c ();
13
+ }
14
+
15
+ void a ()
16
+ {
17
+ c ();
18
+ }
19
+
20
+ int main ()
21
+ {
22
+ a ();
23
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --reachability-slice --show-goto-functions
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ main\(\)
7
+ --
8
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -74,9 +74,18 @@ void reachability_slicert::fixedpoint_to_assertions(
74
74
const auto caller_is_known = stack.back ().caller_is_known ;
75
75
stack.pop_back ();
76
76
77
- if (node.reaches_assertion )
77
+ if (
78
+ node.reaches_assertion ==
79
+ slicer_entryt::dfs_statust::BODY_AND_CALLERS_SEEN ||
80
+ (caller_is_known &&
81
+ node.reaches_assertion == slicer_entryt::dfs_statust::BODY_SEEN))
82
+ {
78
83
continue ;
79
- node.reaches_assertion = true ;
84
+ }
85
+ node.reaches_assertion =
86
+ caller_is_known ?
87
+ slicer_entryt::dfs_statust::BODY_SEEN :
88
+ slicer_entryt::dfs_statust::BODY_AND_CALLERS_SEEN;
80
89
81
90
for (const auto &edge : node.in )
82
91
{
@@ -195,9 +204,12 @@ void reachability_slicert::slice(goto_functionst &goto_functions)
195
204
{
196
205
const cfgt::nodet &e=cfg[cfg.entry_map [i_it]];
197
206
if (
198
- !e.reaches_assertion && !e.reachable_from_assertion &&
207
+ e.reaches_assertion == slicer_entryt::dfs_statust::NOT_SEEN &&
208
+ !e.reachable_from_assertion &&
199
209
!i_it->is_end_function ())
210
+ {
200
211
i_it->make_assumption (false_exprt ());
212
+ }
201
213
}
202
214
203
215
// replace unreachable code by skip
Original file line number Diff line number Diff line change @@ -38,11 +38,24 @@ class reachability_slicert
38
38
protected:
39
39
struct slicer_entryt
40
40
{
41
- slicer_entryt () : reaches_assertion(false ), reachable_from_assertion(false )
41
+ slicer_entryt ()
42
+ : reaches_assertion(dfs_statust::NOT_SEEN),
43
+ reachable_from_assertion (false )
42
44
{
43
45
}
44
46
45
- bool reaches_assertion;
47
+ // / The status of each node during backwards depth-first traversal:
48
+ // / initially NOT_SEEN, and then BODY_SEEN if the callers of the function
49
+ // / the node belongs to will not be explored (implying that the node may
50
+ // / need to be visited again such that its callers are explored), and then
51
+ // / possibly BODY_AND_CALLERS_SEEN. At that point the node need no longer be
52
+ // / re-visited.
53
+ enum class dfs_statust
54
+ {
55
+ NOT_SEEN,
56
+ BODY_SEEN,
57
+ BODY_AND_CALLERS_SEEN
58
+ } reaches_assertion;
46
59
bool reachable_from_assertion;
47
60
};
48
61
You can’t perform that action at this time.
0 commit comments