Skip to content

Commit c5c5e91

Browse files
committed
Use can_cast_type inplace of type id in convert_binary_overflow
1 parent 9b1a388 commit c5c5e91

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/solvers/flattening/boolbv_overflow.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Author: Daniel Kroening, kroening@kroening.com
77
\*******************************************************************/
88

99
#include <util/bitvector_expr.h>
10+
#include <util/bitvector_types.h>
1011
#include <util/invariant.h>
1112

1213
#include "boolbv.h"
@@ -21,7 +22,7 @@ literalt boolbvt::convert_binary_overflow(const binary_overflow_exprt &expr)
2122
: nullopt);
2223

2324
const bv_utilst::representationt rep =
24-
expr.lhs().type().id() == ID_signedbv
25+
can_cast_type<signedbv_typet>(expr.lhs().type())
2526
? bv_utilst::representationt::SIGNED
2627
: bv_utilst::representationt::UNSIGNED;
2728

@@ -50,9 +51,11 @@ literalt boolbvt::convert_binary_overflow(const binary_overflow_exprt &expr)
5051
const auto mult_overflow = expr_try_dynamic_cast<mult_overflow_exprt>(expr))
5152
{
5253
if(
53-
mult_overflow->lhs().type().id() != ID_unsignedbv &&
54-
mult_overflow->lhs().type().id() != ID_signedbv)
54+
!can_cast_type<unsignedbv_typet>(expr.lhs().type()) &&
55+
!can_cast_type<signedbv_typet>(expr.lhs().type()))
56+
{
5557
return SUB::convert_rest(expr);
58+
}
5659

5760
DATA_INVARIANT(
5861
mult_overflow->lhs().type() == mult_overflow->rhs().type(),
@@ -105,7 +108,7 @@ literalt boolbvt::convert_binary_overflow(const binary_overflow_exprt &expr)
105108
bvt result=bv_utils.shift(bv_ext, bv_utilst::shiftt::SHIFT_LEFT, bv1);
106109

107110
// a negative shift is undefined; yet this isn't an overflow
108-
literalt neg_shift = shl_overflow->lhs().type().id() == ID_unsignedbv
111+
literalt neg_shift = rep == bv_utilst::representationt::UNSIGNED
109112
? const_literal(false)
110113
: bv1.back(); // sign bit
111114

0 commit comments

Comments
 (0)