Skip to content

Fix a problem with functions with the same name crashing the dependency graph. #1674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions regression/goto-analyzer/dependence-graph6/file1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extern int s1;
static void sub(void)
{
if (s1) {
}
}

void f1(void)
{
sub();
}
11 changes: 11 additions & 0 deletions regression/goto-analyzer/dependence-graph6/file2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extern int s2;
static void sub(void)
{
if (s2) {
}
}

void f2(void)
{
sub();
}
8 changes: 8 additions & 0 deletions regression/goto-analyzer/dependence-graph6/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
void f1(void);
void f2(void);

void main(void)
{
f1();
f2();
}
9 changes: 9 additions & 0 deletions regression/goto-analyzer/dependence-graph6/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
main.c
file1.c file2.c --dependence-graph
^EXIT=0$
^SIGNAL=0$
--
Assertion .+ failed
--

13 changes: 10 additions & 3 deletions src/goto-programs/read_goto_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ bool is_goto_binary(const std::string &filename)

static void rename_symbols_in_function(
goto_functionst::goto_functiont &function,
irep_idt &new_function_name,
const rename_symbolt &rename_symbol)
{
goto_programt &program=function.body;
Expand All @@ -223,6 +224,9 @@ static void rename_symbols_in_function(
{
rename_symbol(iit->code);
rename_symbol(iit->guard);
// we need to update the instruction's function field as
// well, with the new symbol for the function
iit->function=new_function_name;
}
}

Expand Down Expand Up @@ -256,7 +260,7 @@ static bool link_functions(

if(dest_f_it==dest_functions.function_map.end()) // not there yet
{
rename_symbols_in_function(src_it->second, rename_symbol);
rename_symbols_in_function(src_it->second, final_id, rename_symbol);

goto_functionst::goto_functiont &in_dest_symbol_table=
dest_functions.function_map[final_id];
Expand All @@ -275,7 +279,7 @@ static bool link_functions(
weak_symbols.find(final_id)!=weak_symbols.end())
{
// the one with body wins!
rename_symbols_in_function(src_func, rename_symbol);
rename_symbols_in_function(src_func, final_id, rename_symbol);

in_dest_symbol_table.body.swap(src_func.body);
in_dest_symbol_table.type=src_func.type;
Expand Down Expand Up @@ -323,7 +327,10 @@ static bool link_functions(

if(!macro_application.expr_map.empty())
Forall_goto_functions(dest_it, dest_functions)
rename_symbols_in_function(dest_it->second, macro_application);
{
irep_idt final_id=dest_it->first;
rename_symbols_in_function(dest_it->second, final_id, macro_application);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is necessary, the cases of renamed functions should all be caught above.


if(!object_type_updates.expr_map.empty())
{
Expand Down