Skip to content

Commit 9191b6a

Browse files
authored
Merge pull request diffblue#2199 from tautschnig/simplifier-typing
Static simplification should not alter symbol types
2 parents f99e631 + fc02e8f commit 9191b6a

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

src/goto-analyzer/static_simplifier.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Martin Brain, [email protected]
1212
#include <util/options.h>
1313

1414
#include <goto-programs/goto_model.h>
15+
#include <goto-programs/remove_returns.h>
1516
#include <goto-programs/remove_skip.h>
1617
#include <goto-programs/remove_unreachable.h>
1718
#include <goto-programs/write_goto_binary.h>
@@ -169,6 +170,10 @@ bool static_simplifier(
169170
goto_model.goto_functions.update();
170171
}
171172

173+
// restore return types before writing the binary
174+
restore_returns(goto_model);
175+
goto_model.goto_functions.update();
176+
172177
m.status() << "Writing goto binary" << messaget::eom;
173178
return write_goto_binary(out,
174179
ns.get_symbol_table(),

src/goto-programs/remove_returns.cpp

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -352,38 +352,9 @@ bool remove_returnst::restore_returns(
352352
continue;
353353

354354
// replace "fkt#return_value=x;" by "return x;"
355-
code_returnt return_code(assign.rhs());
356-
357-
// the assignment might be a goto target
358-
i_it->make_skip();
359-
i_it++;
360-
361-
while(!i_it->is_goto() && !i_it->is_end_function())
362-
{
363-
INVARIANT(
364-
i_it->is_dead(),
365-
"only dead statements should appear between "
366-
"a return and the next goto or function end");
367-
i_it++;
368-
}
369-
370-
if(i_it->is_goto())
371-
{
372-
INVARIANT(
373-
i_it->get_target()->is_end_function(),
374-
"GOTO following return should target end of function");
375-
}
376-
else
377-
{
378-
INVARIANT(
379-
i_it->is_end_function(),
380-
"control-flow after assigning return value should lead directly "
381-
"to end of function");
382-
i_it=goto_program.instructions.insert(i_it, *i_it);
383-
}
384-
355+
const exprt rhs = assign.rhs();
385356
i_it->make_return();
386-
i_it->code=return_code;
357+
i_it->code = code_returnt(rhs);
387358
}
388359
}
389360

0 commit comments

Comments
 (0)