Skip to content

Always initialise the exceptional return variable of the entry function #856

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
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
20 changes: 20 additions & 0 deletions src/goto-programs/remove_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ void remove_exceptionst::add_exceptional_returns(
if(goto_program.empty())
return;

// the entry function has already been added to the symbol table
// if you find it, initialise it
if(symbol_table.has_symbol(id2string(function_id)+EXC_SUFFIX))
{
const symbolt &symbol=
symbol_table.lookup(id2string(function_id)+EXC_SUFFIX);
symbol_exprt lhs_expr_null=symbol.symbol_expr();
null_pointer_exprt rhs_expr_null((pointer_typet(empty_typet())));
goto_programt::targett t_null=
goto_program.insert_before(goto_program.instructions.begin());
t_null->make_assignment();
t_null->source_location=
goto_program.instructions.begin()->source_location;
t_null->code=code_assignt(
lhs_expr_null,
rhs_expr_null);
t_null->function=function_id;
return;
}

// We generate an exceptional return value for any function that has
// a throw or a function call. This can be improved by only considering
// function calls that may escape exceptions. However, this will
Expand Down