Skip to content

Commit f3456f2

Browse files
authored
Merge pull request #3513 from tautschnig/from_expr-is-constant
bv_arithmetict: Lift precondition to from_expr's interface
2 parents 8a94b73 + 4051607 commit f3456f2

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/util/bv_arithmetic.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mp_integer bv_arithmetict::pack() const
8282
return value+power(2, spec.width);
8383
}
8484

85-
exprt bv_arithmetict::to_expr() const
85+
constant_exprt bv_arithmetict::to_expr() const
8686
{
8787
return constant_exprt(integer2bvrep(value, spec.width), spec.to_type());
8888
}
@@ -180,10 +180,8 @@ void bv_arithmetict::change_spec(const bv_spect &dest_spec)
180180
adjust();
181181
}
182182

183-
void bv_arithmetict::from_expr(const exprt &expr)
183+
void bv_arithmetict::from_expr(const constant_exprt &expr)
184184
{
185-
PRECONDITION(expr.is_constant());
186185
spec=bv_spect(expr.type());
187-
value = bvrep2integer(
188-
to_constant_expr(expr).get_value(), spec.width, spec.is_signed);
186+
value = bvrep2integer(expr.get_value(), spec.width, spec.is_signed);
189187
}

src/util/bv_arithmetic.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
1515
#include "mp_arith.h"
1616
#include "format_spec.h"
1717

18+
class constant_exprt;
1819
class exprt;
1920
class typet;
2021

@@ -60,7 +61,7 @@ class bv_arithmetict
6061
{
6162
}
6263

63-
explicit bv_arithmetict(const exprt &expr)
64+
explicit bv_arithmetict(const constant_exprt &expr)
6465
{
6566
from_expr(expr);
6667
}
@@ -91,8 +92,8 @@ class bv_arithmetict
9192
std::string format(const format_spect &format_spec) const;
9293

9394
// expressions
94-
exprt to_expr() const;
95-
void from_expr(const exprt &expr);
95+
constant_exprt to_expr() const;
96+
void from_expr(const constant_exprt &expr);
9697

9798
bv_arithmetict &operator/=(const bv_arithmetict &other);
9899
bv_arithmetict &operator*=(const bv_arithmetict &other);

0 commit comments

Comments
 (0)