Skip to content

Commit 7a3f2e6

Browse files
committed
Invoke goto_functions.update() after inlining
Inlining will alter location (instruction) numbers, which need to be updated to once again be globally unique.
1 parent 1a1245e commit 7a3f2e6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/goto-instrument/contracts/contracts.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,14 +682,23 @@ void code_contractst::apply_loop_contract(
682682
const irep_idt &function_name,
683683
goto_functionst::goto_functiont &goto_function)
684684
{
685-
local_may_aliast local_may_alias(goto_function);
686-
natural_loops_mutablet natural_loops(goto_function.body);
685+
const bool may_have_loops = std::any_of(
686+
goto_function.body.instructions.begin(),
687+
goto_function.body.instructions.end(),
688+
[](const goto_programt::instructiont &instruction)
689+
{
690+
return instruction.is_backwards_goto();
691+
});
687692

688-
if(!natural_loops.loop_map.size())
693+
if(!may_have_loops)
689694
return;
690695

691696
goto_function_inline(
692697
goto_functions, function_name, ns, log.get_message_handler());
698+
goto_functions.update();
699+
700+
local_may_aliast local_may_alias(goto_function);
701+
natural_loops_mutablet natural_loops(goto_function.body);
693702

694703
// A graph node type that stores information about a loop.
695704
// We create a DAG representing nesting of various loops in goto_function,
@@ -1008,6 +1017,7 @@ bool code_contractst::check_frame_conditions_function(const irep_idt &function)
10081017
// Inline all function calls.
10091018
goto_function_inline(
10101019
goto_functions, function_obj->first, ns, log.get_message_handler());
1020+
goto_functions.update();
10111021

10121022
// Insert write set inclusion checks.
10131023
check_frame_conditions(

0 commit comments

Comments
 (0)