Skip to content

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

Conversation

danpoe
Copy link
Contributor

@danpoe danpoe commented Sep 10, 2018

No description provided.

@@ -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, "");
Copy link
Contributor Author

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?

Copy link
Member

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");
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

@@ -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);
Copy link
Member

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.

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

@@ -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)
Copy link
Member

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?

Copy link
Contributor Author

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?

assert(expr.operands().size()==1);
DATA_INVARIANT(
expr.operands().size() == 1,
"unary plus expressions should have one operand");

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See PR #2931 ;)

Copy link
Collaborator

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?

@danpoe danpoe force-pushed the refactor/error-handling-solvers-flattening-from-boolbv-constant branch from cedaaad to 0c6ed43 Compare September 10, 2018 16:30
@@ -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)
Copy link
Member

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");
Copy link
Member

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.

@@ -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, "");
Copy link
Member

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(to_integer(index_expr.index(), index))
throw "literal expects constant index";
bool error = to_integer(index_expr.index(), index);
CHECK_RETURN(!error);
Copy link
Collaborator

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?

assert(expr.operands().size()==1);
DATA_INVARIANT(
expr.operands().size() == 1,
"unary plus expressions should have one operand");
Copy link
Collaborator

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?


if(size*tmp.size()!=width)
throw "convert_lambda: unexpected operand width";
std::size_t offset = integer2unsigned(i * tmp.size());
Copy link
Collaborator

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

@danpoe danpoe force-pushed the refactor/error-handling-solvers-flattening-from-boolbv-constant branch from 0c6ed43 to a721b1b Compare September 19, 2018 12:05
Copy link
Contributor

@allredj allredj left a 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

@danpoe danpoe force-pushed the refactor/error-handling-solvers-flattening-from-boolbv-constant branch 2 times, most recently from b2ae89a to e8f2e21 Compare September 21, 2018 10:24
Copy link
Contributor

@allredj allredj left a 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

@danpoe danpoe force-pushed the refactor/error-handling-solvers-flattening-from-boolbv-constant branch from e8f2e21 to ce19636 Compare September 25, 2018 11:18
Copy link
Contributor

@allredj allredj left a 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

@danpoe
Copy link
Contributor Author

danpoe commented Sep 28, 2018

@peterschrammel I think this is ready to be merged now.

@peterschrammel peterschrammel removed their assignment Sep 28, 2018
@tautschnig tautschnig merged commit d37341e into diffblue:develop Sep 28, 2018
@danpoe danpoe deleted the refactor/error-handling-solvers-flattening-from-boolbv-constant branch June 2, 2020 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants