Skip to content

Cleanup of error handling of some of the files under goto-programs #2904

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

Merged
merged 2 commits into from
Sep 20, 2018

Conversation

NlightNFotis
Copy link
Contributor

This is nothing new as a PR, it's just me taking over #2836. I have now rebased and I am now responsible for further development on it.

Addressing some of the comments by @kroening on the previous PR: There should be a new PR in the next few days, where we will have structured goto_locationt inside the invariants, to my understanding at least. This PR will be extended to handle the appropriate cases once that goes in.

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.

This PR failed Diffblue compatibility checks (cbmc commit: 8654b36).
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

statement==ID_predecrement);
DATA_INVARIANT(
statement == ID_preincrement || statement == ID_predecrement,
" expected preincrement or predecrement");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Spurious space at beginning of error message?

DATA_INVARIANT(
!expr.operands().empty(),
expr.find_source_location().as_string() +
": function_call expects at least 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.

Above we require exactly two operands - could both of these DATA_INVARIANTs be fused into one, at the beginning of the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I opted to go with the stricter version (the one requiring exactly two operands) of this invariant, given that I find that both operands are being used at various points of this function.

@@ -445,7 +430,7 @@ void goto_convertt::remove_cpp_delete(
side_effect_exprt &expr,
goto_programt &dest)
{
assert(expr.operands().size()==1);
DATA_INVARIANT(expr.operands().size() == 1, "cpp_delete expected 1 operand");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's spell out "one", for consistency. Or change all of them to numerals. There's ample inconsistency in this PR as far as this is concerned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I will handle all of the cases in this PR.

"size of target list");
DATA_INVARIANT(
instruction.targets.size() == exception_list.size(),
"size of target list");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, what's wrong with the size?

statement==ID_postdecrement);
DATA_INVARIANT(
statement == ID_postincrement || statement == ID_postdecrement,
" expected postincrement or postdecrement");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's also a spurious space at the beginning of the error message, which I have gone ahead and removed.

DATA_INVARIANT(
!expr.operands().empty(),
expr.find_source_location().as_string() +
": function_call expects at least one operand");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I opted to go with the stricter version (the one requiring exactly two operands) of this invariant, given that I find that both operands are being used at various points of this function.

@@ -445,7 +430,7 @@ void goto_convertt::remove_cpp_delete(
side_effect_exprt &expr,
goto_programt &dest)
{
assert(expr.operands().size()==1);
DATA_INVARIANT(expr.operands().size() == 1, "cpp_delete expected 1 operand");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I will handle all of the cases in this PR.

@@ -235,23 +237,23 @@ void parse_lhs_read(const exprt &src, std::list<exprt> &dest)
{
if(src.id()==ID_dereference)
{
assert(src.operands().size()==1);
PRECONDITION(src.operands().size() == 1);
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 figured this would go very well with the changes suggested in #2902, so I went ahead to change all of these, by removing the duplicate preconditions and converting the untyped expressions into the correct types with the typecast expressions.

@NlightNFotis
Copy link
Contributor Author

@tautschnig I have fixed your comments, and I also figured out that some of the changes suggested in a previous PR of mine (#2902) were applicable here, so I removed some of the preconditions and substituted them for a finer typing of exprs at the appropriate places.

@NlightNFotis NlightNFotis force-pushed the 2836_takeover branch 2 times, most recently from 9b6d01a to 612ef30 Compare September 14, 2018 15:46
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: 612ef30).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84857760

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Looks ok to me.

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: c952f55).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85323156

@NlightNFotis NlightNFotis merged commit a04da2e into diffblue:develop Sep 20, 2018
@NlightNFotis NlightNFotis deleted the 2836_takeover branch September 20, 2018 11:25
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.

4 participants