Skip to content

Refactor boolbvt::convert_overflow #6752

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

Conversation

thomasspriggs
Copy link
Contributor

This PR is based on the refactoring suggestion from @tautschnig in this code review comment - #6744 (comment)

This PR should be purely refactoring only. As in both implementations should produce the same results given the same inputs. Many of the remaining differences between the different operators are down to differences in error / unexpected case handling. The implementation could be further simplified based on unifying whether these checks result in skipped conversions or invariant violations for the different operators. However I would prefer not to make more functional changes as part of this PR.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • 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).
  • 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.

Comment on lines +168 to +170
literalt boolbvt::convert_unary_overflow(const unary_overflow_exprt &expr)
{
if(
Copy link
Collaborator

Choose a reason for hiding this comment

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

There really is just this single unary_minus_overflow_exprt that exists for this case, so I would suggest to make this convert_unary_minus_overflow(const unary_minus_overflow_exprt &expr).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unary_minus_overflow_exprt and unary_overflow_exprt are currently equivalent. This fact could be used to simplify the way they are currently used, or even to remove unary_overflow_exprt and just keep unary_minus_overflow_exprt. However I think it would make it more difficult to add other kinds of unary overflow expressions. Adding more checks isn't something I am planning to work on but does seem worth considering. The following example unary operations might be considered for overflow checks -

  • The existing abs_exprt.
  • Increment operators ++ / --.
  • The trigonometric tan / "tangent" operation.
  • Could a narrowing cast be considered to overflow?

@thomasspriggs thomasspriggs merged commit 15eb581 into diffblue:develop Mar 24, 2022
@thomasspriggs thomasspriggs deleted the tas/refactor_convert_overflow branch March 24, 2022 11:57
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.

2 participants