Skip to content

Cleanup expression/code cast validation #4176

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
merged 12 commits into from
Mar 7, 2019

Conversation

tautschnig
Copy link
Collaborator

@tautschnig tautschnig commented Feb 13, 2019

Please review commit-by-commit; several commits are text-motion only and others are automated text replacement - both indicated in the respective commit messages. This requires/includes #4175 ("Return statements always have one operand"), so please skip that while reviewing.

The original aim was to get rid of all the sharing-breaking side effects in to_*exprt procedures, but when starting on this I noticed that really a lot more cleanup was indicated.

  • 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.
  • n/a 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a 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.

✔️
Passed Diffblue compatibility checks (cbmc commit: 0563f78).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100773027

Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

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

lgtm, though obviously skimmed the automated changes

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

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: b2f1dbd).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/103118539
Status will be re-evaluated on next push.
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).

  • the compatibility was already broken by an earlier merge.

@@ -354,6 +354,11 @@ inline bool can_cast_expr<unary_exprt>(const exprt &base)
return base.operands().size() == 1;
}

inline void validate_expr(const unary_exprt &value)
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ commit message: unnecessariliy -> unnecessarily

Copy link
Member

Choose a reason for hiding this comment

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

⛏️ some commit messages are too long

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both done and automated spell checking enabled in my editor...

@peterschrammel peterschrammel removed their assignment Mar 6, 2019
This is consistent with what validate_expr and to_code_declt assert at
the moment.
The error message would fail to print as it uses a conversion that is
invalid for the very reason that the error message wants to print.
Adds one implementation of validate_expr, and moves the other existing
ones to replace the comment that claims there is no implementation.
Prefer code re-use over duplicated (and possibly inconsistent)
implementations.
This provides two advantages:
1) Member access such as testing the number of operands does not break
sharing, because it is done in a const context.
2) Code re-use: we no longer implement the same check in two different
ways.

All changes in this commit were applied automatically via text
replacement.
Placing them above to_*_expr is the layout that std_code.h uses.
Furthermore it will facilitate re-use of validate_expr. No code changes,
just text motion.
This provides two advantages:
1) Member access such as testing the number of operands does not break
sharing, because it is done in a const context.
2) Code re-use: we no longer implement the same check in two different
ways.

With the exception of {exist,forall,quantifier}_exprt, all changes in
this commit were applied automatically via text replacement. For
quantifiers, additional checks were inserted (use of can_cast_expr,
validate_expr uses quantifier_exprt's validate_expr).
Placing them above to_*_expr is the layout that std_code.h uses.
Furthermore it will facilitate re-use of validate_expr. No code changes,
just text motion.
Some were unnecessarily missing, others were wrongly commented out.
Commented-out checks obviously don't check anything, and the code that
was commented out wasn't particularly deep so that restoring it in
future is trivial anyway.
This provides two advantages:
1) Member access such as testing the number of operands does not break
sharing, because it is done in a const context.
2) Code re-use: we no longer implement the same check in two different
ways.

All changes in this commit were applied automatically via text
replacement.
Prefer code re-use over duplicated (and possibly inconsistent)
implementations.
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: d4dc77f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/103461000

@tautschnig tautschnig merged commit 9f30ce1 into diffblue:develop Mar 7, 2019
@tautschnig tautschnig deleted the make-cast-const branch March 7, 2019 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants