Skip to content

Commit cb2e20c

Browse files
committed
GOTO conversion: move out-only clean_expr parameter to return value
Removes one side-effect of invoking clean_expr and instead expands on the return-value type.
1 parent bbd9de4 commit cb2e20c

File tree

7 files changed

+308
-280
lines changed

7 files changed

+308
-280
lines changed

src/ansi-c/goto-conversion/builtin_functions.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,16 @@ void goto_convertt::do_cpp_new(
401401
bool new_array = rhs.get(ID_statement) == ID_cpp_new_array;
402402

403403
exprt count;
404-
needs_destructiont new_vars;
404+
clean_expr_resultt side_effects;
405405

406406
if(new_array)
407407
{
408408
count = typecast_exprt::conditional_cast(
409409
static_cast<const exprt &>(rhs.find(ID_size)), object_size.type());
410410

411411
// might have side-effect
412-
new_vars.add(clean_expr(count, dest, ID_cpp));
412+
side_effects.add(clean_expr(count, ID_cpp));
413+
dest.destructive_append(side_effects.side_effects);
413414
}
414415

415416
exprt tmp_symbol_expr;
@@ -495,9 +496,8 @@ void goto_convertt::do_cpp_new(
495496
typecast_exprt(tmp_symbol_expr, lhs.type()),
496497
rhs.find_source_location()));
497498

498-
new_vars.minimal_scope.push_front(
499-
to_symbol_expr(tmp_symbol_expr).get_identifier());
500-
destruct_locals(new_vars.minimal_scope, dest, ns);
499+
side_effects.add_temporary(to_symbol_expr(tmp_symbol_expr).get_identifier());
500+
destruct_locals(side_effects.temporaries, dest, ns);
501501

502502
// grab initializer
503503
goto_programt tmp_initializer;

0 commit comments

Comments
 (0)