Skip to content

Commit f904bcc

Browse files
committed
Construct and_exprt in a non-deprecated way
The default constructor is deprecated. To facilitate construction with an arbitrary number of operands a new constructor taking a initializer list is added.
1 parent 80cb920 commit f904bcc

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

src/solvers/flattening/functions.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ exprt functionst::arguments_equal(const exprt::operandst &o1,
3535
if(o1.empty())
3636
return true_exprt();
3737

38-
and_exprt and_expr;
39-
and_exprt::operandst &conjuncts=and_expr.operands();
40-
conjuncts.resize(o1.size());
38+
exprt::operandst conjuncts;
39+
conjuncts.reserve(o1.size());
4140

4241
for(std::size_t i=0; i<o1.size(); i++)
4342
{
4443
exprt lhs=o1[i];
4544
exprt rhs = typecast_exprt::conditional_cast(o2[i], o1[i].type());
46-
conjuncts[i]=equal_exprt(lhs, rhs);
45+
conjuncts.push_back(equal_exprt(lhs, rhs));
4746
}
4847

49-
return std::move(and_expr);
48+
return conjunction(conjuncts);
5049
}
5150

5251
void functionst::add_function_constraints(const function_infot &info)

src/solvers/floatbv/float_bv.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -777,13 +777,11 @@ exprt float_bvt::relation(
777777

778778
if(rel==relt::LT)
779779
{
780-
and_exprt and_bv;
781-
and_bv.reserve_operands(4);
782-
and_bv.copy_to_operands(less_than3);
783-
// for the case of two negative numbers
784-
and_bv.copy_to_operands(not_exprt(bitwise_equal));
785-
and_bv.copy_to_operands(not_exprt(both_zero));
786-
and_bv.copy_to_operands(not_exprt(nan));
780+
and_exprt and_bv{{less_than3,
781+
// for the case of two negative numbers
782+
not_exprt(bitwise_equal),
783+
not_exprt(both_zero),
784+
not_exprt(nan)}};
787785

788786
return std::move(and_bv);
789787
}

src/util/guard.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ void guardt::add(const exprt &expr)
5454
}
5555
else if(id()!=ID_and)
5656
{
57-
and_exprt a;
58-
a.add_to_operands(*this);
57+
and_exprt a({*this});
5958
*this=a;
6059
}
6160

src/util/std_expr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ exprt conjunction(const exprt::operandst &op)
5555
return op.front();
5656
else
5757
{
58-
and_exprt result;
59-
result.operands()=op;
60-
return std::move(result);
58+
return and_exprt(exprt::operandst(op));
6159
}
6260
}
6361

src/util/std_expr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,11 @@ class and_exprt:public multi_ary_exprt
24472447
: multi_ary_exprt(ID_and, {op0, op1, op2, op3}, bool_typet())
24482448
{
24492449
}
2450+
2451+
explicit and_exprt(exprt::operandst &&_operands)
2452+
: multi_ary_exprt(ID_and, std::move(_operands), bool_typet())
2453+
{
2454+
}
24502455
};
24512456

24522457
/// 1) generates a conjunction for two or more operands

0 commit comments

Comments
 (0)