Skip to content

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

Conversation

hannes-steffenhagen-diffblue
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue commented Sep 25, 2018

Also contains some minor refactoring for those files in separate commits

  • Each commit message has a non-empty body, explaining why the change was made.
  • My contribution is formatted in line with CODING_STANDARD.md.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed) (not applicable)
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

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

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: 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];
Copy link
Collaborator

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());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might add a const

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

Apologies, I forgot to include a commit. Please hold reviews while I'm fixing that.

Copy link
Contributor

@NlightNFotis NlightNFotis left a 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
Copy link
Contributor

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

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?

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, that was in the commit I forgot to include

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature-invariant_cleanup-flattening-extractbits branch from 1de020e to e81aafb Compare September 26, 2018 11:55
@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature-invariant_cleanup-flattening-extractbits branch from e81aafb to c6ffde7 Compare September 26, 2018 11:58
@hannes-steffenhagen-diffblue
Copy link
Contributor Author

@tautschnig @NlightNFotis I believe I've addressed your comments now, please re-review once CI is done.

Copy link
Contributor

@NlightNFotis NlightNFotis left a comment

Choose a reason for hiding this comment

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

LGTM

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

@hannes-steffenhagen-diffblue
Copy link
Contributor Author

All stages of the travis build have passed. I'm not sure why it's showing its in progress, its really not

@tautschnig
Copy link
Collaborator

Seems to be happening on other PRs as well (#2048, #2979).

@tautschnig
Copy link
Collaborator

@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
@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the feature-invariant_cleanup-flattening-extractbits branch from c6ffde7 to 9423a5c Compare September 26, 2018 16:52
@tautschnig tautschnig merged commit 771b368 into diffblue:develop Sep 26, 2018
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: 9423a5c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86049202

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