-
Notifications
You must be signed in to change notification settings - Fork 274
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
Conversation
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 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"); |
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.
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"); |
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.
Above we require exactly two operands - could both of these DATA_INVARIANT
s be fused into one, at the beginning of the method?
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.
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"); |
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.
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.
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.
Agreed. I will handle all of the cases in this PR.
src/goto-programs/goto_program.cpp
Outdated
"size of target list"); | ||
DATA_INVARIANT( | ||
instruction.targets.size() == exception_list.size(), | ||
"size of target list"); |
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.
Hmm, what's wrong with the size?
statement==ID_postdecrement); | ||
DATA_INVARIANT( | ||
statement == ID_postincrement || statement == ID_postdecrement, | ||
" expected postincrement or postdecrement"); |
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.
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"); |
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.
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"); |
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.
Agreed. I will handle all of the cases in this PR.
src/goto-programs/goto_program.cpp
Outdated
@@ -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); |
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 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.
8654b36
to
57a04a7
Compare
@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 |
9b6d01a
to
612ef30
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: 612ef30).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84857760
612ef30
to
c952f55
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.
Looks ok to me.
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: c952f55).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85323156
410dfaf
to
c952f55
Compare
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.