Skip to content

Commit

Permalink
GOTO conversion: move out-only clean_expr parameter to return value
Browse files Browse the repository at this point in the history
Removes one side-effect of invoking clean_expr and instead expands on
the return-value type.
  • Loading branch information
tautschnig committed Jul 9, 2024
1 parent 69c11e3 commit c2a3496
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 278 deletions.
10 changes: 5 additions & 5 deletions src/ansi-c/goto-conversion/builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,16 @@ void goto_convertt::do_cpp_new(
bool new_array = rhs.get(ID_statement) == ID_cpp_new_array;

exprt count;
needs_destructiont new_vars;
clean_expr_resultt side_effects;

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

// might have side-effect
new_vars.add(clean_expr(count, dest, ID_cpp));
side_effects.add(clean_expr(count, ID_cpp));
dest.destructive_append(side_effects.side_effects);
}

exprt tmp_symbol_expr;
Expand Down Expand Up @@ -495,9 +496,8 @@ void goto_convertt::do_cpp_new(
typecast_exprt(tmp_symbol_expr, lhs.type()),
rhs.find_source_location()));

new_vars.minimal_scope.push_front(
to_symbol_expr(tmp_symbol_expr).get_identifier());
destruct_locals(new_vars.minimal_scope, dest, ns);
side_effects.add_temporary(to_symbol_expr(tmp_symbol_expr).get_identifier());
destruct_locals(side_effects.temporaries, dest, ns);

// grab initializer
goto_programt tmp_initializer;
Expand Down
Loading

0 comments on commit c2a3496

Please sign in to comment.