Skip to content

Commit 8c2d622

Browse files
committed
Fix the problem where two static functions with the same name would cause the dependency graph to fail.
1 parent e1d6d41 commit 8c2d622

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/goto-programs/read_goto_binary.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ bool is_goto_binary(const std::string &filename)
214214

215215
static void rename_symbols_in_function(
216216
goto_functionst::goto_functiont &function,
217+
irep_idt &new_function_name,
217218
const rename_symbolt &rename_symbol)
218219
{
219220
goto_programt &program=function.body;
@@ -223,6 +224,9 @@ static void rename_symbols_in_function(
223224
{
224225
rename_symbol(iit->code);
225226
rename_symbol(iit->guard);
227+
// we need to update the instruction's function field as
228+
// well, with the new symbol for the function
229+
iit->function=new_function_name;
226230
}
227231
}
228232

@@ -256,7 +260,7 @@ static bool link_functions(
256260

257261
if(dest_f_it==dest_functions.function_map.end()) // not there yet
258262
{
259-
rename_symbols_in_function(src_it->second, rename_symbol);
263+
rename_symbols_in_function(src_it->second, final_id, rename_symbol);
260264

261265
goto_functionst::goto_functiont &in_dest_symbol_table=
262266
dest_functions.function_map[final_id];
@@ -275,7 +279,7 @@ static bool link_functions(
275279
weak_symbols.find(final_id)!=weak_symbols.end())
276280
{
277281
// the one with body wins!
278-
rename_symbols_in_function(src_func, rename_symbol);
282+
rename_symbols_in_function(src_func, final_id, rename_symbol);
279283

280284
in_dest_symbol_table.body.swap(src_func.body);
281285
in_dest_symbol_table.type=src_func.type;
@@ -323,7 +327,10 @@ static bool link_functions(
323327

324328
if(!macro_application.expr_map.empty())
325329
Forall_goto_functions(dest_it, dest_functions)
326-
rename_symbols_in_function(dest_it->second, macro_application);
330+
{
331+
irep_idt final_id=dest_it->first;
332+
rename_symbols_in_function(dest_it->second, final_id, macro_application);
333+
}
327334

328335
if(!object_type_updates.expr_map.empty())
329336
{

0 commit comments

Comments
 (0)