Skip to content

Commit 69de79a

Browse files
Replace throw and assert in boolbv_extractbit
The throw was on checking if a constant expression with extractbit was a valid integer expression. The assert was signaling that we didn't support a type of expression so has been replaced with a throw of the appropriate exception type
1 parent 5f384aa commit 69de79a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/solvers/flattening/boolbv_extractbit.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <util/arith_tools.h>
1515
#include <util/std_expr.h>
1616
#include <util/std_types.h>
17+
#include <util/exception_utils.h>
1718

1819
literalt boolbvt::convert_extractbit(const extractbit_exprt &expr)
1920
{
@@ -22,10 +23,7 @@ literalt boolbvt::convert_extractbit(const extractbit_exprt &expr)
2223
// constant?
2324
if(expr.index().is_constant())
2425
{
25-
mp_integer index_as_integer;
26-
27-
if(to_integer(expr.index(), index_as_integer))
28-
throw "extractbit failed to convert constant index";
26+
mp_integer index_as_integer = numeric_cast_v<mp_integer>(expr.index());
2927

3028
if(index_as_integer < 0 || index_as_integer >= src_bv.size())
3129
return prop.new_variable(); // out of range!
@@ -37,8 +35,7 @@ literalt boolbvt::convert_extractbit(const extractbit_exprt &expr)
3735
expr.src().type().id() == ID_verilog_signedbv ||
3836
expr.src().type().id() == ID_verilog_unsignedbv)
3937
{
40-
// TODO
41-
assert(false);
38+
throw unsupported_operation_exceptiont("extractbit expression not implemented for verilog integers in flattening solver");
4239
}
4340
else
4441
{

0 commit comments

Comments
 (0)