@@ -112,29 +112,23 @@ void goto_convertt::remove_assignment(
112112 UNREACHABLE;
113113 }
114114
115- exprt rhs;
116-
117- const typet &op0_type = to_binary_expr (expr).op0 ().type ();
115+ const binary_exprt &binary_expr = to_binary_expr (expr);
116+ const typet &op0_type = binary_expr.op0 ().type ();
118117
119118 PRECONDITION (
120119 op0_type.id () != ID_c_enum_tag && op0_type.id () != ID_c_enum &&
121120 op0_type.id () != ID_c_bool && op0_type.id () != ID_bool);
122121
123- rhs.id (new_id);
124- rhs.copy_to_operands (
125- to_binary_expr (expr).op0 (), to_binary_expr (expr).op1 ());
126- rhs.type () = to_binary_expr (expr).op0 ().type ();
122+ exprt rhs = binary_exprt{binary_expr.op0 (), new_id, binary_expr.op1 ()};
127123 rhs.add_source_location () = expr.source_location ();
128124
129- if (
130- result_is_used && !address_taken &&
131- needs_cleaning (to_binary_expr (expr).op0 ()))
125+ if (result_is_used && !address_taken && needs_cleaning (binary_expr.op0 ()))
132126 {
133127 make_temp_symbol (rhs, " assign" , dest, mode);
134128 replacement_expr_opt = rhs;
135129 }
136130
137- exprt new_lhs = skip_typecast (to_binary_expr (expr) .op0 ());
131+ exprt new_lhs = skip_typecast (binary_expr .op0 ());
138132 rhs = typecast_exprt::conditional_cast (rhs, new_lhs.type ());
139133 rhs.add_source_location () = expr.source_location ();
140134 code_assignt assignment (new_lhs, rhs);
@@ -196,14 +190,6 @@ void goto_convertt::remove_pre(
196190 statement == ID_preincrement || statement == ID_predecrement,
197191 " expects preincrement or predecrement" );
198192
199- exprt rhs;
200- rhs.add_source_location ()=expr.source_location ();
201-
202- if (statement==ID_preincrement)
203- rhs.id (ID_plus);
204- else
205- rhs.id (ID_minus);
206-
207193 const auto &op = to_unary_expr (expr).op ();
208194 const typet &op_type = op.type ();
209195
@@ -233,8 +219,9 @@ void goto_convertt::remove_pre(
233219 else
234220 constant = from_integer (1 , constant_type);
235221
236- rhs.add_to_operands (op, std::move (constant));
237- rhs.type () = op.type ();
222+ exprt rhs = binary_exprt{
223+ op, statement == ID_preincrement ? ID_plus : ID_minus, std::move (constant)};
224+ rhs.add_source_location () = expr.source_location ();
238225
239226 const bool cannot_use_lhs =
240227 result_is_used && !address_taken && needs_cleaning (op);
@@ -282,14 +269,6 @@ void goto_convertt::remove_post(
282269 statement == ID_postincrement || statement == ID_postdecrement,
283270 " expects postincrement or postdecrement" );
284271
285- exprt rhs;
286- rhs.add_source_location ()=expr.source_location ();
287-
288- if (statement==ID_postincrement)
289- rhs.id (ID_plus);
290- else
291- rhs.id (ID_minus);
292-
293272 const auto &op = to_unary_expr (expr).op ();
294273 const typet &op_type = op.type ();
295274
@@ -319,8 +298,11 @@ void goto_convertt::remove_post(
319298 else
320299 constant = from_integer (1 , constant_type);
321300
322- rhs.add_to_operands (op, std::move (constant));
323- rhs.type () = op.type ();
301+ binary_exprt rhs{
302+ op,
303+ statement == ID_postincrement ? ID_plus : ID_minus,
304+ std::move (constant)};
305+ rhs.add_source_location () = expr.source_location ();
324306
325307 code_assignt assignment (op, rhs);
326308 assignment.add_source_location ()=expr.find_source_location ();
0 commit comments