@@ -49,6 +49,20 @@ static smt_termt convert_multiary_operator_to_terms(
49
49
factory);
50
50
}
51
51
52
+ // / \brief Ensures that all operands of the argument expression are of the same
53
+ // / type.
54
+ // / \param expr: The expression of which the operands we evaluate for type
55
+ // / equality.
56
+ template <typename target_typet>
57
+ static bool operands_are_of_same_type (const exprt &expr)
58
+ {
59
+ return std::all_of (
60
+ expr.operands ().cbegin (),
61
+ expr.operands ().cend (),
62
+ [](const exprt &operand)
63
+ { return can_cast_type<target_typet>(operand.type ()); });
64
+ }
65
+
52
66
static smt_sortt convert_type_to_smt_sort (const bool_typet &type)
53
67
{
54
68
return smt_bool_sortt{};
@@ -154,12 +168,7 @@ static smt_termt convert_expr_to_smt(const concatenation_exprt &concatenation)
154
168
155
169
static smt_termt convert_expr_to_smt (const bitand_exprt &bitwise_and_expr)
156
170
{
157
- if (std::all_of (
158
- bitwise_and_expr.operands ().cbegin (),
159
- bitwise_and_expr.operands ().cend (),
160
- [](exprt operand) {
161
- return can_cast_type<integer_bitvector_typet>(operand.type ());
162
- }))
171
+ if (operands_are_of_same_type<integer_bitvector_typet>(bitwise_and_expr))
163
172
{
164
173
return convert_multiary_operator_to_terms (
165
174
bitwise_and_expr, smt_bit_vector_theoryt::make_and);
@@ -174,12 +183,7 @@ static smt_termt convert_expr_to_smt(const bitand_exprt &bitwise_and_expr)
174
183
175
184
static smt_termt convert_expr_to_smt (const bitor_exprt &bitwise_or_expr)
176
185
{
177
- if (std::all_of (
178
- bitwise_or_expr.operands ().cbegin (),
179
- bitwise_or_expr.operands ().cend (),
180
- [](exprt operand) {
181
- return can_cast_type<integer_bitvector_typet>(operand.type ());
182
- }))
186
+ if (operands_are_of_same_type<integer_bitvector_typet>(bitwise_or_expr))
183
187
{
184
188
return convert_multiary_operator_to_terms (
185
189
bitwise_or_expr, smt_bit_vector_theoryt::make_or);
@@ -194,12 +198,7 @@ static smt_termt convert_expr_to_smt(const bitor_exprt &bitwise_or_expr)
194
198
195
199
static smt_termt convert_expr_to_smt (const bitxor_exprt &bitwise_xor)
196
200
{
197
- if (std::all_of (
198
- bitwise_xor.operands ().cbegin (),
199
- bitwise_xor.operands ().cend (),
200
- [](exprt operand) {
201
- return can_cast_type<integer_bitvector_typet>(operand.type ());
202
- }))
201
+ if (operands_are_of_same_type<integer_bitvector_typet>(bitwise_xor))
203
202
{
204
203
return convert_multiary_operator_to_terms (
205
204
bitwise_xor, smt_bit_vector_theoryt::make_xor);
0 commit comments