Skip to content

Commit c0f179c

Browse files
committed
Use unary_minus_overflow_exprt
1 parent 631aeb4 commit c0f179c

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

src/ansi-c/c_typecheck_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3161,7 +3161,7 @@ exprt c_typecheck_baset::do_special_functions(
31613161

31623162
typecheck_expr_unary_arithmetic(tmp);
31633163

3164-
unary_overflow_exprt overflow{ID_unary_minus, tmp.operands().front()};
3164+
unary_minus_overflow_exprt overflow{tmp.operands().front()};
31653165
overflow.add_source_location() = tmp.source_location();
31663166
return std::move(overflow);
31673167
}

src/ansi-c/expr2c.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3921,7 +3921,7 @@ std::string expr2ct::convert_with_precedence(
39213921
return convert_cond(src, precedence);
39223922

39233923
else if(
3924-
src.id() == ID_overflow_unary_minus ||
3924+
can_cast_expr<unary_minus_overflow_exprt>(src) ||
39253925
can_cast_expr<binary_overflow_exprt>(src))
39263926
{
39273927
return convert_overflow(src, precedence);

src/ansi-c/goto_check_c.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ void goto_check_ct::integer_overflow_check(
10521052
std::string kind = type.id() == ID_unsignedbv ? "unsigned" : "signed";
10531053

10541054
add_guarded_property(
1055-
not_exprt{unary_overflow_exprt{expr.id(), to_unary_expr(expr).op()}},
1055+
not_exprt{unary_minus_overflow_exprt{to_unary_expr(expr).op()}},
10561056
"arithmetic overflow on " + kind + " " + expr.id_string(),
10571057
"overflow",
10581058
expr.find_source_location(),

src/solvers/flattening/boolbv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ literalt boolbvt::convert_rest(const exprt &expr)
418418
return convert_onehot(to_unary_expr(expr));
419419
else if(
420420
can_cast_expr<binary_overflow_exprt>(expr) ||
421-
expr.id() == ID_overflow_unary_minus)
421+
can_cast_expr<unary_minus_overflow_exprt>(expr))
422422
{
423423
return convert_overflow(expr);
424424
}

src/solvers/flattening/boolbv_overflow.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ literalt boolbvt::convert_overflow(const exprt &expr)
161161
return
162162
prop.land(!neg_shift, prop.lselect(undef, prop.lor(bv0), overflow));
163163
}
164-
else if(expr.id()==ID_overflow_unary_minus)
164+
else if(
165+
const auto unary_minus_overflow =
166+
expr_try_dynamic_cast<unary_minus_overflow_exprt>(expr))
165167
{
166-
const auto &overflow_expr = to_unary_expr(expr);
167-
168-
const bvt &bv = convert_bv(overflow_expr.op());
168+
const bvt &bv = convert_bv(unary_minus_overflow->op());
169169

170170
return bv_utils.overflow_negate(bv);
171171
}

src/util/simplify_expr.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,7 @@ simplify_exprt::simplify_overflow_unary(const unary_overflow_exprt &expr)
22782278
return unchanged(expr);
22792279

22802280
mp_integer no_overflow_result;
2281-
if(expr.id() == ID_overflow_unary_minus)
2281+
if(can_cast_expr<unary_minus_overflow_exprt>(expr))
22822282
no_overflow_result = -*op_value;
22832283
else
22842284
UNREACHABLE;
@@ -2552,9 +2552,11 @@ simplify_exprt::resultt<> simplify_exprt::simplify_node(exprt node)
25522552
{
25532553
r = simplify_overflow_binary(*binary_overflow);
25542554
}
2555-
else if(expr.id() == ID_overflow_unary_minus)
2555+
else if(
2556+
const auto unary_overflow =
2557+
expr_try_dynamic_cast<unary_overflow_exprt>(expr))
25562558
{
2557-
r = simplify_overflow_unary(to_unary_overflow_expr(expr));
2559+
r = simplify_overflow_unary(*unary_overflow);
25582560
}
25592561
else if(expr.id() == ID_bitreverse)
25602562
{

0 commit comments

Comments
 (0)