-
Notifications
You must be signed in to change notification settings - Fork 274
Invariant cleanup in flattening/boolbv_extractbit.cpp and flattening/boolbv_extractbits.cpp #3041
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
Invariant cleanup in flattening/boolbv_extractbit.cpp and flattening/boolbv_extractbits.cpp #3041
Conversation
64f6578
to
1de020e
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.
This PR failed Diffblue compatibility checks (cbmc commit: 64f6578).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85886706
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).
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: 1de020e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85888067
for(std::size_t i=0; i<width; i++) | ||
bv[i]=bv0[offset+i]; | ||
for(std::size_t i = 0; i < bv_width; i++) | ||
result_bv[i] = src_bv[offset + i]; |
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 could be rewritten as const bvt result_bv(src_bv.begin() + offset, src_bv.begin() + offset + bv_width);
auto const &src_bv = convert_bv(expr.src()); | ||
|
||
auto maybe_upper_as_int = numeric_cast<mp_integer>(expr.upper()); |
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.
Might add a const
Apologies, I forgot to include a commit. Please hold reviews while I'm fixing that. |
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.
Some nitpicks only, otherwise LGTM
@@ -56,7 +52,7 @@ literalt boolbvt::convert_extractbit(const extractbit_exprt &expr) | |||
unsignedbv_typet index_type(index_width); | |||
|
|||
equal_exprt equality; | |||
equality.lhs()=operands[1]; // index operand | |||
equality.lhs() = expr.index(); // index 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.
Nit: the strong typing makes the comment useless now?
{ | ||
error().source_location=expr.find_source_location(); | ||
error() << "extractbits: wrong width (expected " << (o1-o2+1) | ||
<< " but got " << width << "): " << expr.pretty() << eom; | ||
error() << "extractbits: wrong width (expected " |
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.
Can this not be rewritten as an invariant with diagnostic information?
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, that was in the commit I forgot to include
1de020e
to
e81aafb
Compare
e81aafb
to
c6ffde7
Compare
@tautschnig @NlightNFotis I believe I've addressed your comments now, please re-review once CI is done. |
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.
LGTM
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: c6ffde7).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86008775
All stages of the travis build have passed. I'm not sure why it's showing its in progress, its really not |
@hannes-steffenhagen-diffblue You might try rebasing, some other PRs have by now gone through (though not all). |
Using semantic names for operators instead of their position and expanding single letter abbreviations should help with legibility.
The throw was on checking if a constant expression with extractbit was a valid integer expression. The assert was signaling that we didn't support a type of expression so has been replaced with a throw of the appropriate exception type
This allows us to be a bit more explicit in the code with `has_value` rather than using an "anonymous" boolean result.
Also removes one throw that guards against violation of extractbits_expr invariants
c6ffde7
to
9423a5c
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: 9423a5c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86049202
Also contains some minor refactoring for those files in separate commits