Skip to content

Commit 94d9b7a

Browse files
Merge pull request #4384 from romainbrenguier/enhance/move_in_expr_constructors
Make multi_ary_exprt constructor params be copies
2 parents 410f50e + 3530548 commit 94d9b7a

File tree

1 file changed

+37
-39
lines changed

1 file changed

+37
-39
lines changed

src/util/std_expr.h

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
/// \file util/std_expr.h
1414
/// API to expression classes
1515

16+
#include "as_const.h"
1617
#include "expr_cast.h"
1718
#include "invariant.h"
1819
#include "std_types.h"
@@ -969,20 +970,20 @@ class multi_ary_exprt : public expr_protectedt
969970
operands() = std::move(_operands);
970971
}
971972

972-
multi_ary_exprt(const exprt &_lhs, const irep_idt &_id, const exprt &_rhs)
973-
: expr_protectedt(_id, _lhs.type())
973+
multi_ary_exprt(exprt _lhs, const irep_idt &_id, exprt _rhs)
974+
: expr_protectedt(_id, as_const(_lhs).type())
974975
{
975-
add_to_operands(_lhs, _rhs);
976+
add_to_operands(std::move(_lhs), std::move(_rhs));
976977
}
977978

978979
multi_ary_exprt(
979-
const exprt &_lhs,
980+
exprt _lhs,
980981
const irep_idt &_id,
981-
const exprt &_rhs,
982+
exprt _rhs,
982983
const typet &_type)
983984
: expr_protectedt(_id, _type)
984985
{
985-
add_to_operands(_lhs, _rhs);
986+
add_to_operands(std::move(_lhs), std::move(_rhs));
986987
}
987988

988989
// In contrast to exprt::opX, the methods
@@ -1069,18 +1070,13 @@ class plus_exprt:public multi_ary_exprt
10691070
{
10701071
}
10711072

1072-
plus_exprt(
1073-
const exprt &_lhs,
1074-
const exprt &_rhs):
1075-
multi_ary_exprt(_lhs, ID_plus, _rhs)
1073+
plus_exprt(exprt _lhs, exprt _rhs)
1074+
: multi_ary_exprt(std::move(_lhs), ID_plus, std::move(_rhs))
10761075
{
10771076
}
10781077

1079-
plus_exprt(
1080-
const exprt &_lhs,
1081-
const exprt &_rhs,
1082-
const typet &_type):
1083-
multi_ary_exprt(_lhs, ID_plus, _rhs, _type)
1078+
plus_exprt(exprt _lhs, exprt _rhs, const typet &_type)
1079+
: multi_ary_exprt(_lhs, ID_plus, _rhs, _type)
10841080
{
10851081
}
10861082

@@ -1187,10 +1183,8 @@ class mult_exprt:public multi_ary_exprt
11871183
{
11881184
}
11891185

1190-
mult_exprt(
1191-
const exprt &_lhs,
1192-
const exprt &_rhs):
1193-
multi_ary_exprt(_lhs, ID_mult, _rhs)
1186+
mult_exprt(exprt _lhs, exprt _rhs)
1187+
: multi_ary_exprt(std::move(_lhs), ID_mult, std::move(_rhs))
11941188
{
11951189
}
11961190
};
@@ -2410,22 +2404,24 @@ class and_exprt:public multi_ary_exprt
24102404
{
24112405
}
24122406

2413-
and_exprt(const exprt &op0, const exprt &op1):
2414-
multi_ary_exprt(op0, ID_and, op1, bool_typet())
2407+
and_exprt(exprt op0, exprt op1)
2408+
: multi_ary_exprt(std::move(op0), ID_and, std::move(op1), bool_typet())
24152409
{
24162410
}
24172411

2418-
and_exprt(const exprt &op0, const exprt &op1, const exprt &op2)
2419-
: multi_ary_exprt(ID_and, {op0, op1, op2}, bool_typet())
2412+
and_exprt(exprt op0, exprt op1, exprt op2)
2413+
: multi_ary_exprt(
2414+
ID_and,
2415+
{std::move(op0), std::move(op1), std::move(op2)},
2416+
bool_typet())
24202417
{
24212418
}
24222419

2423-
and_exprt(
2424-
const exprt &op0,
2425-
const exprt &op1,
2426-
const exprt &op2,
2427-
const exprt &op3)
2428-
: multi_ary_exprt(ID_and, {op0, op1, op2, op3}, bool_typet())
2420+
and_exprt(exprt op0, exprt op1, exprt op2, exprt op3)
2421+
: multi_ary_exprt(
2422+
ID_and,
2423+
{std::move(op0), std::move(op1), std::move(op2), std::move(op3)},
2424+
bool_typet())
24292425
{
24302426
}
24312427

@@ -2526,22 +2522,24 @@ class or_exprt:public multi_ary_exprt
25262522
{
25272523
}
25282524

2529-
or_exprt(const exprt &op0, const exprt &op1):
2530-
multi_ary_exprt(op0, ID_or, op1, bool_typet())
2525+
or_exprt(exprt op0, exprt op1)
2526+
: multi_ary_exprt(std::move(op0), ID_or, std::move(op1), bool_typet())
25312527
{
25322528
}
25332529

2534-
or_exprt(const exprt &op0, const exprt &op1, const exprt &op2)
2535-
: multi_ary_exprt(ID_or, {op0, op1, op2}, bool_typet())
2530+
or_exprt(exprt op0, exprt op1, exprt op2)
2531+
: multi_ary_exprt(
2532+
ID_or,
2533+
{std::move(op0), std::move(op1), std::move(op2)},
2534+
bool_typet())
25362535
{
25372536
}
25382537

2539-
or_exprt(
2540-
const exprt &op0,
2541-
const exprt &op1,
2542-
const exprt &op2,
2543-
const exprt &op3)
2544-
: multi_ary_exprt(ID_or, {op0, op1, op2, op3}, bool_typet())
2538+
or_exprt(exprt op0, exprt op1, exprt op2, exprt op3)
2539+
: multi_ary_exprt(
2540+
ID_or,
2541+
{std::move(op0), std::move(op1), std::move(op2), std::move(op3)},
2542+
bool_typet())
25452543
{
25462544
}
25472545

0 commit comments

Comments
 (0)