Skip to content

Commit 424e30e

Browse files
Petr BauchPetr Bauch
Petr Bauch
authored and
Petr Bauch
committed
Fix based on comments
1 parent f2e65c5 commit 424e30e

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

regression/goto-instrument/fp-reachability-slice1/test.desc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ main.c
33
--fp-reachability-slice c
44
^EXIT=0$
55
^SIGNAL=0$
6+
1: ASSUME FALSE
7+
dead e;
8+
dead d;
69
--
710
^warning: ignoring
811
dead f;

regression/goto-instrument/fp-reachability-slice3/test.desc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ main.c
33
--fp-reachability-slice b,c
44
^EXIT=0$
55
^SIGNAL=0$
6+
1 file main.c line 34
67
--
78
^warning: ignoring
89
dead d;
10+
dead e;
911
dead f;

src/goto-instrument/reachability_slicer.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ void reachability_slicert::fixedpoint_to_assertions(
8989
{
9090
// This is an end-of-function -> successor-of-callsite edge.
9191
// Queue both the caller and the end of the callee.
92-
if(std::prev(node.PC)->is_function_call())
93-
{
94-
stack.emplace_back(edge.first, true);
95-
stack.emplace_back(
96-
cfg.entry_map[std::prev(node.PC)], caller_is_known);
97-
}
92+
INVARIANT(
93+
std::prev(node.PC)->is_function_call(),
94+
"all function return edges should point to the successor of a "
95+
"FUNCTION_CALL instruction");
96+
stack.emplace_back(edge.first, true);
97+
stack.emplace_back(cfg.entry_map[std::prev(node.PC)], caller_is_known);
9898
}
9999
else if(pred_node.PC->is_function_call())
100100
{
@@ -200,7 +200,6 @@ void reachability_slicert::slice(goto_functionst &goto_functions)
200200
!e.reaches_assertion && !e.reachable_from_assertion &&
201201
!i_it->is_end_function())
202202
i_it->make_assumption(false_exprt());
203-
e.reaches_assertion = e.reachable_from_assertion = false;
204203
}
205204

206205
// replace unreachable code by skip
@@ -245,21 +244,20 @@ void reachability_slicer(
245244

246245
/// Perform reachability slicing on goto_model for selected functions.
247246
/// \param goto_model Goto program to slice
248-
/// \param functions The functions relevant for the slicing (i.e. starting
247+
/// \param functions_list The functions relevant for the slicing (i.e. starting
249248
/// point for the search in the cfg). Anything that is reachable in the CFG
250249
/// starting from these functions will be kept.
251250
void function_path_reachability_slicer(
252251
goto_modelt &goto_model,
253252
const std::string &functions_list)
254253
{
255-
reachability_slicert s;
256-
257-
std::istringstream multiple_functions(functions_list);
254+
std::istringstream functions_stream(functions_list);
258255
std::string single_function;
259-
while(std::getline(multiple_functions, single_function, ','))
256+
while(std::getline(functions_stream, single_function, ','))
260257
{
261-
in_function_criteriont p(single_function);
262-
s(goto_model.goto_functions, p, true);
258+
in_function_criteriont matching_criterion(single_function);
259+
reachability_slicert slicer;
260+
slicer(goto_model.goto_functions, matching_criterion, true);
263261
}
264262

265263
remove_calls_no_bodyt remove_calls_no_body;

0 commit comments

Comments
 (0)