Skip to content

Commit 1b43ee9

Browse files
Refactoring in boolbvt::convert_bitwise
1 parent adc2d5d commit 1b43ee9

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/solvers/flattening/boolbv_bitwise.cpp

+6-15
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@ Author: Daniel Kroening, [email protected]
1111

1212
bvt boolbvt::convert_bitwise(const exprt &expr)
1313
{
14-
std::size_t width=boolbv_width(expr.type());
15-
14+
const std::size_t width = boolbv_width(expr.type());
1615
if(width==0)
1716
return conversion_failed(expr);
1817

1918
if(expr.id()==ID_bitnot)
2019
{
21-
if(expr.operands().size()!=1)
22-
throw "bitnot takes one operand";
23-
20+
DATA_INVARIANT(expr.operands().size() == 1, "bitnot takes one operand");
2421
const exprt &op0=expr.op0();
25-
2622
const bvt &op_bv=convert_bv(op0);
27-
28-
if(op_bv.size()!=width)
29-
throw "convert_bitwise: unexpected operand width";
30-
23+
CHECK_RETURN(op_bv.size() == width);
3124
return bv_utils.inverted(op_bv);
3225
}
3326
else if(expr.id()==ID_bitand || expr.id()==ID_bitor ||
@@ -41,9 +34,7 @@ bvt boolbvt::convert_bitwise(const exprt &expr)
4134
forall_operands(it, expr)
4235
{
4336
const bvt &op=convert_bv(*it);
44-
45-
if(op.size()!=width)
46-
throw "convert_bitwise: unexpected operand width";
37+
CHECK_RETURN(op.size() == width);
4738

4839
if(it==expr.operands().begin())
4940
bv=op;
@@ -64,13 +55,13 @@ bvt boolbvt::convert_bitwise(const exprt &expr)
6455
else if(expr.id()==ID_bitxnor)
6556
bv[i]=prop.lequal(bv[i], op[i]);
6657
else
67-
throw "unexpected operand";
58+
UNIMPLEMENTED;
6859
}
6960
}
7061
}
7162

7263
return bv;
7364
}
7465

75-
throw "unexpected bitwise operand";
66+
UNIMPLEMENTED;
7667
}

0 commit comments

Comments
 (0)