Skip to content

Commit c3abda7

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 da63652 commit c3abda7

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/goto-instrument/stack_depth.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,21 @@ 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)
96-
if(f_it->second.body_available() &&
97-
f_it->first!=CPROVER_PREFIX "initialize" &&
98-
f_it->first!=goto_functionst::entry_point())
98+
{
99+
if(
100+
f_it->second.body_available() && f_it->first != init_name &&
101+
f_it->first != goto_functionst::entry_point())
102+
{
99103
stack_depth(f_it->second.body, sym, depth, depth_expr);
104+
}
105+
}
100106

101107
// initialize depth to 0
102-
goto_functionst::function_mapt::iterator
103-
i_it=goto_model.goto_functions.function_map.find(
104-
CPROVER_PREFIX "initialize");
108+
goto_functionst::function_mapt::iterator i_it =
109+
goto_model.goto_functions.function_map.find(init_name);
105110
DATA_INVARIANT(
106111
i_it!=goto_model.goto_functions.function_map.end(),
107112
"__CPROVER_initialize must exist");
@@ -111,8 +116,8 @@ void stack_depth(
111116
goto_programt::targett it=init.insert_before(first);
112117
it->make_assignment();
113118
it->code=code_assignt(sym, from_integer(0, sym.type()));
114-
it->source_location=first->source_location;
115-
it->function=first->function;
119+
// no suitable value for source location -- omitted
120+
it->function = init_name;
116121

117122
// update counters etc.
118123
goto_model.goto_functions.update();

0 commit comments

Comments
 (0)