File tree 2 files changed +7
-31
lines changed 2 files changed +7
-31
lines changed Original file line number Diff line number Diff line change 12
12
#include < util/options.h>
13
13
14
14
#include < goto-programs/goto_model.h>
15
+ #include < goto-programs/remove_returns.h>
15
16
#include < goto-programs/remove_skip.h>
16
17
#include < goto-programs/remove_unreachable.h>
17
18
#include < goto-programs/write_goto_binary.h>
@@ -169,6 +170,10 @@ bool static_simplifier(
169
170
goto_model.goto_functions .update ();
170
171
}
171
172
173
+ // restore return types before writing the binary
174
+ restore_returns (goto_model);
175
+ goto_model.goto_functions .update ();
176
+
172
177
m.status () << " Writing goto binary" << messaget::eom;
173
178
return write_goto_binary (out,
174
179
ns.get_symbol_table (),
Original file line number Diff line number Diff line change @@ -352,38 +352,9 @@ bool remove_returnst::restore_returns(
352
352
continue ;
353
353
354
354
// 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 ();
385
356
i_it->make_return ();
386
- i_it->code =return_code ;
357
+ i_it->code = code_returnt (rhs) ;
387
358
}
388
359
}
389
360
You can’t perform that action at this time.
0 commit comments