Skip to content

Commit 05f46a9

Browse files
committed
Fix the problem where two static functions with the same name would cause the dependency graph to fail.
1 parent 5b6eb00 commit 05f46a9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/goto-programs/link_goto_model.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Author: Michael Tautschnig, Daniel Kroening
2323

2424
static void rename_symbols_in_function(
2525
goto_functionst::goto_functiont &function,
26+
irep_idt &new_function_name,
2627
const rename_symbolt &rename_symbol)
2728
{
2829
goto_programt &program=function.body;
@@ -32,6 +33,9 @@ static void rename_symbols_in_function(
3233
{
3334
rename_symbol(iit->code);
3435
rename_symbol(iit->guard);
36+
// we need to update the instruction's function field as
37+
// well, with the new symbol for the function
38+
iit->function=new_function_name;
3539
}
3640
}
3741

@@ -67,7 +71,7 @@ static bool link_functions(
6771

6872
if(dest_f_it==dest_functions.function_map.end()) // not there yet
6973
{
70-
rename_symbols_in_function(src_it->second, rename_symbol);
74+
rename_symbols_in_function(src_it->second, final_id, rename_symbol);
7175

7276
goto_functionst::goto_functiont &in_dest_symbol_table=
7377
dest_functions.function_map[final_id];
@@ -86,7 +90,7 @@ static bool link_functions(
8690
weak_symbols.find(final_id)!=weak_symbols.end())
8791
{
8892
// the one with body wins!
89-
rename_symbols_in_function(src_func, rename_symbol);
93+
rename_symbols_in_function(src_func, final_id, rename_symbol);
9094

9195
in_dest_symbol_table.body.swap(src_func.body);
9296
in_dest_symbol_table.type=src_func.type;
@@ -136,7 +140,10 @@ static bool link_functions(
136140

137141
if(!macro_application.expr_map.empty())
138142
Forall_goto_functions(dest_it, dest_functions)
139-
rename_symbols_in_function(dest_it->second, macro_application);
143+
{
144+
irep_idt final_id=dest_it->first;
145+
rename_symbols_in_function(dest_it->second, final_id, macro_application);
146+
}
140147

141148
if(!object_type_updates.expr_map.empty())
142149
{

0 commit comments

Comments
 (0)