Skip to content

Commit 34e6f54

Browse files
authored
Merge pull request #1674 from NlightNFotis/test_pb4_fix
Fix a problem with functions with the same name crashing the dependency graph.
2 parents 8879771 + 8cb7ff5 commit 34e6f54

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extern int s1;
2+
static void sub(void)
3+
{
4+
if (s1) {
5+
}
6+
}
7+
8+
void f1(void)
9+
{
10+
sub();
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extern int s2;
2+
static void sub(void)
3+
{
4+
if (s2) {
5+
}
6+
}
7+
8+
void f2(void)
9+
{
10+
sub();
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
void f1(void);
2+
void f2(void);
3+
4+
void main(void)
5+
{
6+
f1();
7+
f2();
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
file1.c file2.c --dependence-graph
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
Assertion .+ failed
8+
--
9+

src/goto-programs/read_goto_binary.cpp

+10-3
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)