Skip to content

Commit 54dfa09

Browse files
committed
stack depth instrumentation: __CPROVER_initialize may be empty
Do not attempt to use information from the first instruction in __CPROVER_initialize as there need not be any such instruction.
1 parent e6a9127 commit 54dfa09

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/goto-instrument/stack_depth.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,17 @@ void stack_depth(
9292

9393
const exprt depth_expr(from_integer(depth, sym.type()));
9494

95+
const irep_idt init_name=CPROVER_PREFIX "initialize";
96+
9597
Forall_goto_functions(f_it, goto_model.goto_functions)
9698
if(f_it->second.body_available() &&
97-
f_it->first!=CPROVER_PREFIX "initialize" &&
98-
f_it->first!=goto_functionst::entry_point())
99+
f_it->first!=init_name &&
100+
f_it->first!=goto_functionst::entry_point())
99101
stack_depth(f_it->second.body, sym, depth, depth_expr);
100102

101103
// initialize depth to 0
102104
goto_functionst::function_mapt::iterator
103-
i_it=goto_model.goto_functions.function_map.find(
104-
CPROVER_PREFIX "initialize");
105+
i_it=goto_model.goto_functions.function_map.find(init_name);
105106
DATA_INVARIANT(
106107
i_it!=goto_model.goto_functions.function_map.end(),
107108
"__CPROVER_initialize must exist");
@@ -111,8 +112,8 @@ void stack_depth(
111112
goto_programt::targett it=init.insert_before(first);
112113
it->make_assignment();
113114
it->code=code_assignt(sym, from_integer(0, sym.type()));
114-
it->source_location=first->source_location;
115-
it->function=first->function;
115+
// no suitable value for source location -- omitted
116+
it->function=init_name;
116117

117118
// update counters etc.
118119
goto_model.goto_functions.update();

0 commit comments

Comments
 (0)