Skip to content

Introduce a renamedt type for renamed expressions in symex #4305

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

Conversation

romainbrenguier
Copy link
Contributor

This is a wrapper that will be used to signal that an expression or type
has been renamed to a given level.
It makes it possible to define functions which only accept expression
which have been through renaming.

This is preliminary to #3986 but some of its part becomes redundant, and it needs to be reworked on afterwards.

Eventually expressions of this type will be propagated everywhere renamed expressions are used and .get() should only be used when constructing the target equations.

  • 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.
  • [na] 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).
  • [na] My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • [na] 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: 43ed0d3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102817834

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Hurrah!

/// Wrapper for expressions or types which have been renamed up to a given
/// \p level
template <typename underlyingt, levelt level>
class renamedt
Copy link
Member

Choose a reason for hiding this comment

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

underlyingt appears to be ssa_exprt everywhere -- simply hardwire that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now it is, but my plan is to next use it with exprt (draft PR here: #3986 though it needs to be rebased on this one), we could also think of using it with typet

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Some more comments and a +1 on @kroening's comment that underlyingt should be hardwired to ssa_exprt.

level0(ssa_expr, ns, source.thread_nr);
level1(ssa_expr);
ssa_exprt l0 = level0(std::move(ssa_expr), ns, source.thread_nr);
ssa_expr = level1(std::move(l0));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we just do ssa_expr = level1(level0(std::move(ssa_expr), ns, source.thread_nr)); please?

level2(ssa_expr);
ssa_exprt l0 = level0(std::move(ssa_expr), ns, source.thread_nr);
ssa_exprt l1 = level1(std::move(l0));
ssa_expr = level2(std::move(l1));
Copy link
Collaborator

Choose a reason for hiding this comment

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

ssa_expr = level2(level1(level0(std::move(ssa_expr), ns, source.thread_nr)));

{
// already renamed?
if(!ssa_expr.get_level_0().empty())
return;
return std::move(ssa_expr);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@kroening @NathanJPhillips @smowton is the std::move actually necessary/desirable here (and in all the other cases where the argument is returned)? But maybe it doesn't matter much, because subsequent commits modify these lines.

Copy link
Member

Choose a reason for hiding this comment

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

@tautschnig @romainbrenguier The std::move is not necessary; C++11 guarantees that the move constructor will be used without it, i.e., it's noise.

Copy link
Member

@kroening kroening Mar 2, 2019

Choose a reason for hiding this comment

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

There are three scenarios where std::move is needed:

  1. The parameter is an rvalue reference
  2. You want to move something whose lifetime isn't ending yet (but you are sure that you won't use it anymore)
  3. You want to return something that's derived from the return type.

These aren't super intuitive.

@tautschnig tautschnig assigned romainbrenguier and unassigned danpoe Mar 2, 2019
This is to be uniform with the other levels.
This is so that the returned type can eventually reflect the renaming.
This seems a more appropriate to find it, and we could use the levelt
type for templates we will define in this file.
This is a wrapper that will be used to signal that an expression or type
has been renamed to a given level.
It makes it possible to define functions which only accept expression
which have been through renaming.
This makes it explicit that the expresssion has been renamed.
This makes it explicit in the type that the expression has been renamed.
This makes it in the type the result has been renamed and a level 1
expression is expected as argument.
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: b5ae64b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102966820
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.

@tautschnig tautschnig merged commit 81bc65f into diffblue:develop Mar 3, 2019
@romainbrenguier romainbrenguier deleted the refactor/renamedt branch March 4, 2019 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants