Skip to content

Commit 886d8d1

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
Use (non-trivial) constructors for plus_exprt, side_effect_exprt
This is more efficient, type safe, and easier to read.
1 parent 5161a7e commit 886d8d1

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/ansi-c/c_typecheck_expr.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1270,9 +1270,9 @@ void c_typecheck_baset::typecheck_expr_index(exprt &expr)
12701270
// p[i] is syntactic sugar for *(p+i)
12711271

12721272
typecheck_arithmetic_pointer(expr.op0());
1273-
exprt addition(ID_plus, array_expr.type());
1274-
addition.operands().swap(expr.operands());
1275-
expr.add_to_operands(std::move(addition));
1273+
exprt::operandst summands;
1274+
std::swap(summands, expr.operands());
1275+
expr.add_to_operands(plus_exprt(std::move(summands), array_expr.type()));
12761276
expr.id(ID_dereference);
12771277
expr.set(ID_C_lvalue, true);
12781278
expr.type() = final_array_type.subtype();

src/cpp/cpp_typecheck_conversions.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1394,9 +1394,8 @@ bool cpp_typecheckt::reference_binding(
13941394
{
13951395
{
13961396
// create temporary object
1397-
exprt tmp=exprt(ID_side_effect, type.subtype());
1398-
tmp.set(ID_statement, ID_temporary_object);
1399-
tmp.add_source_location()=expr.source_location();
1397+
side_effect_exprt tmp(
1398+
ID_temporary_object, type.subtype(), expr.source_location());
14001399
// tmp.set(ID_C_lvalue, true);
14011400
tmp.add_to_operands(std::move(new_expr));
14021401
new_expr.swap(tmp);

0 commit comments

Comments
 (0)