-
Notifications
You must be signed in to change notification settings - Fork 274
Error handling cleanup in solvers/flattening 2 #2932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error handling cleanup in solvers/flattening 2 #2932
Conversation
src/solvers/flattening/boolbv.cpp
Outdated
@@ -302,7 +312,7 @@ bvt boolbvt::convert_bitvector(const exprt &expr) | |||
else if(expr.id()==ID_float_debug1 || | |||
expr.id()==ID_float_debug2) | |||
{ | |||
assert(expr.operands().size()==2); | |||
DATA_INVARIANT(expr.operands().size() == 2, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no expression types corresponding to ID_float_debug1
and ID_float_debug2
as it seems they have been added quickly for debugging purposes. Should there be actual expression types for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed.
if(expr.operands().size()!=2) | ||
throw "lambda takes two operands"; | ||
DATA_INVARIANT( | ||
expr.operands().size() == 2, "lambda expression should have two operands"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There currently exists a lambda expression type in a non-public repo. @peterschrammel: Should this be pulled out from there and added to std_expr.h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's used in cegis. @pkesseli will remove this as soon as the cegis code has been cleaned up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've raised an issue for that as well now: #3039
src/solvers/flattening/boolbv.cpp
Outdated
@@ -126,18 +126,28 @@ const bvt &boolbvt::convert_bv(const exprt &expr) | |||
// Iterators into hash_maps supposedly stay stable | |||
// even though we are inserting more elements recursively. | |||
|
|||
cache_result.first->second=convert_bitvector(expr); | |||
const bvt &bv = convert_bitvector(expr); | |||
CHECK_RETURN(!expected_width || bv.size() == *expected_width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have to remove this, otherwise the invariant with diagnostics will never be triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a CHECK_RETURN_WITH_DIAGNOSTICS
, but I'm not sure if CHECK_RETURN
is even the right invariant type to use here
src/solvers/flattening/boolbv.cpp
Outdated
@@ -183,8 +183,6 @@ bvt boolbvt::convert_bitvector(const exprt &expr) | |||
|
|||
if(expr.id()==ID_index) | |||
return convert_index(to_index_expr(expr)); | |||
else if(expr.id()==ID_constraint_select_one) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this used by EBMC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't know that. Where can I find the source code of EBMC?
src/solvers/flattening/boolbv.cpp
Outdated
assert(expr.operands().size()==1); | ||
DATA_INVARIANT( | ||
expr.operands().size() == 1, | ||
"unary plus expressions should have one operand"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tautschnig Is likely going to suggest to add a to_unary_plus_expr
and call it here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See PR #2931 ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK that has been merged?
cedaaad
to
0c6ed43
Compare
src/util/irep_ids.def
Outdated
@@ -298,7 +298,6 @@ IREP_ID_ONE(predecrement) | |||
IREP_ID_ONE(integer_bits) | |||
IREP_ID_ONE(KnR) | |||
IREP_ID_TWO(C_KnR, #KnR) | |||
IREP_ID_ONE(constraint_select_one) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in ebmc.
if(expr.operands().size()!=2) | ||
throw "lambda takes two operands"; | ||
DATA_INVARIANT( | ||
expr.operands().size() == 2, "lambda expression should have two operands"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's used in cegis. @pkesseli will remove this as soon as the cegis code has been cleaned up.
src/solvers/flattening/boolbv.cpp
Outdated
@@ -302,7 +312,7 @@ bvt boolbvt::convert_bitvector(const exprt &expr) | |||
else if(expr.id()==ID_float_debug1 || | |||
expr.id()==ID_float_debug2) | |||
{ | |||
assert(expr.operands().size()==2); | |||
DATA_INVARIANT(expr.operands().size() == 2, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed.
src/solvers/flattening/boolbv.cpp
Outdated
if(to_integer(index_expr.index(), index)) | ||
throw "literal expects constant index"; | ||
bool error = to_integer(index_expr.index(), index); | ||
CHECK_RETURN(!error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using numeric_cast_v
, which would do the error checking?
src/solvers/flattening/boolbv.cpp
Outdated
assert(expr.operands().size()==1); | ||
DATA_INVARIANT( | ||
expr.operands().size() == 1, | ||
"unary plus expressions should have one operand"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK that has been merged?
src/solvers/flattening/boolbv.cpp
Outdated
|
||
if(size*tmp.size()!=width) | ||
throw "convert_lambda: unexpected operand width"; | ||
std::size_t offset = integer2unsigned(i * tmp.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace by numeric_cast_v
0c6ed43
to
a721b1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: a721b1b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85286739
b2ae89a
to
e8f2e21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: e8f2e21).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85554847
Files boolbv_constant.cpp, boolbv.cpp
e8f2e21
to
ce19636
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: ce19636).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85857128
@peterschrammel I think this is ready to be merged now. |
No description provided.