Skip to content

Static simplification should not alter symbol types #2199

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
May 17, 2018
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
5 changes: 5 additions & 0 deletions src/goto-analyzer/static_simplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Author: Martin Brain, [email protected]
#include <util/options.h>

#include <goto-programs/goto_model.h>
#include <goto-programs/remove_returns.h>
#include <goto-programs/remove_skip.h>
#include <goto-programs/remove_unreachable.h>
#include <goto-programs/write_goto_binary.h>
Expand Down Expand Up @@ -169,6 +170,10 @@ bool static_simplifier(
goto_model.goto_functions.update();
}

// restore return types before writing the binary
restore_returns(goto_model);
goto_model.goto_functions.update();

m.status() << "Writing goto binary" << messaget::eom;
return write_goto_binary(out,
ns.get_symbol_table(),
Expand Down
33 changes: 2 additions & 31 deletions src/goto-programs/remove_returns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,38 +352,9 @@ bool remove_returnst::restore_returns(
continue;

// replace "fkt#return_value=x;" by "return x;"
code_returnt return_code(assign.rhs());

// the assignment might be a goto target
i_it->make_skip();
i_it++;

while(!i_it->is_goto() && !i_it->is_end_function())
{
INVARIANT(
i_it->is_dead(),
"only dead statements should appear between "
"a return and the next goto or function end");
i_it++;
}

if(i_it->is_goto())
{
INVARIANT(
i_it->get_target()->is_end_function(),
"GOTO following return should target end of function");
}
else
{
INVARIANT(
i_it->is_end_function(),
"control-flow after assigning return value should lead directly "
"to end of function");
i_it=goto_program.instructions.insert(i_it, *i_it);
}

const exprt rhs = assign.rhs();
i_it->make_return();
i_it->code=return_code;
i_it->code = code_returnt(rhs);
}
}

Expand Down