Skip to content

Commit 991bcba

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 352014e commit 991bcba

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -777,13 +777,12 @@ 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);
780+
and_exprt and_bv{{
781+
less_than3,
783782
// 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));
783+
not_exprt(bitwise_equal),
784+
not_exprt(both_zero),
785+
not_exprt(nan)}};
787786

788787
return std::move(and_bv);
789788
}

src/util/guard.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ void guardt::add(const exprt &expr)
5252
}
5353
else if(id()!=ID_and)
5454
{
55-
and_exprt a;
56-
a.add_to_operands(*this);
55+
and_exprt a({*this});
5756
*this=a;
5857
}
5958

src/util/std_expr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ exprt conjunction(const exprt::operandst &op)
5353
return op.front();
5454
else
5555
{
56-
and_exprt result;
57-
result.operands()=op;
58-
return std::move(result);
56+
return and_exprt(exprt::operandst(op));
5957
}
6058
}
6159

src/util/std_expr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,11 @@ class and_exprt:public multi_ary_exprt
24722472
: multi_ary_exprt(ID_and, {op0, op1, op2, op3}, bool_typet())
24732473
{
24742474
}
2475+
2476+
and_exprt(exprt::operandst &&_operands)
2477+
: multi_ary_exprt(ID_and, std::move(_operands), bool_typet())
2478+
{
2479+
}
24752480
};
24762481

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

0 commit comments

Comments
 (0)