Skip to content

Commit f9233a7

Browse files
tautschnigpolgreen
authored andcommitted
Fix reachability slicer when used with recursive or unreachable functions
1 parent 2ebbb24 commit f9233a7

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--reachability-slice --show-goto-functions
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
main\(\)
7+
--
8+
^warning: ignoring

src/goto-instrument/reachability_slicer.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ void reachability_slicert::fixedpoint_to_assertions(
7474
const auto caller_is_known = stack.back().caller_is_known;
7575
stack.pop_back();
7676

77-
if(node.reaches_assertion)
77+
if(
78+
node.reaches_assertion.is_true() ||
79+
(caller_is_known && node.reaches_assertion.is_unknown()))
80+
{
7881
continue;
79-
node.reaches_assertion = true;
82+
}
83+
node.reaches_assertion = caller_is_known ? tvt::unknown() : tvt(true);
8084

8185
for(const auto &edge : node.in)
8286
{
@@ -195,7 +199,7 @@ void reachability_slicert::slice(goto_functionst &goto_functions)
195199
{
196200
const cfgt::nodet &e=cfg[cfg.entry_map[i_it]];
197201
if(
198-
!e.reaches_assertion && !e.reachable_from_assertion &&
202+
e.reaches_assertion.is_false() && !e.reachable_from_assertion &&
199203
!i_it->is_end_function())
200204
i_it->make_assumption(false_exprt());
201205
}

src/goto-instrument/reachability_slicer_class.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ class reachability_slicert
3838
protected:
3939
struct slicer_entryt
4040
{
41-
slicer_entryt() : reaches_assertion(false), reachable_from_assertion(false)
41+
slicer_entryt()
42+
: reaches_assertion(tvt(false)), reachable_from_assertion(false)
4243
{
4344
}
4445

45-
bool reaches_assertion;
46+
tvt reaches_assertion;
4647
bool reachable_from_assertion;
4748
};
4849

0 commit comments

Comments
 (0)