Skip to content

Commit c617c6c

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 c617c6c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/solvers/flattening/boolbv_extractbit.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Daniel Kroening, [email protected]
1212
#include <algorithm>
1313

1414
#include <util/arith_tools.h>
15+
#include <util/exception_utils.h>
1516
#include <util/std_expr.h>
1617
#include <util/std_types.h>
1718

@@ -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,9 @@ 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(
39+
"extractbit expression not implemented for verilog integers in "
40+
"flattening solver");
4241
}
4342
else
4443
{

0 commit comments

Comments
 (0)