Invariant cleanup in flattening/boolbv_extractbit.cpp and flattening/boolbv_extractbits.cpp#3041
Conversation
64f6578 to
1de020e
Compare
allredj
left a comment
There was a problem hiding this comment.
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).
allredj
left a comment
There was a problem hiding this comment.
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.
I think this could be rewritten as const bvt result_bv(src_bv.begin() + offset, src_bv.begin() + offset + bv_width);
| mp_integer upper_as_int, lower_as_int; | ||
| auto const &src_bv = convert_bv(expr.src()); | ||
|
|
||
| auto maybe_upper_as_int = numeric_cast<mp_integer>(expr.upper()); |
|
Apologies, I forgot to include a commit. Please hold reviews while I'm fixing that. |
NlightNFotis
left a comment
There was a problem hiding this comment.
Some nitpicks only, otherwise LGTM
|
|
||
| equal_exprt equality; | ||
| equality.lhs()=operands[1]; // index operand | ||
| equality.lhs() = expr.index(); // index operand |
There was a problem hiding this comment.
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.
Can this not be rewritten as an invariant with diagnostic information?
There was a problem hiding this comment.
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. |
allredj
left a comment
There was a problem hiding this comment.
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
allredj
left a comment
There was a problem hiding this comment.
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