Skip to content

Type the operand of code_declt #3267

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 3 commits into from
Nov 6, 2018
Merged

Type the operand of code_declt #3267

merged 3 commits into from
Nov 6, 2018

Conversation

kroening
Copy link
Member

@kroening kroening commented Nov 3, 2018

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a 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).
  • n/a 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.

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

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

{
symbol_exprt tmp(symbol.name, symbol.type);

if(symbol.is_lvalue)
tmp.set(ID_C_lvalue, true);

return std::move(tmp);
return tmp;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the std::move being removed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps counterintuitively, the std::move prevents a move here. I.e., removing it enables copy elision.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would that be the case? Notably, clang-7 had complained about the absence of std::move here, and it has just been introduced in 72bfc35.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tautschnig the key is whether a type conversion is required or not. Previously we returned a symbol_exprt, meaning we needed a conversion to exprt (via its copy- or move-constructor), so std::move was a good thing (picking the move constructor). Now we return a symbol_exprt, meaning no type conversion is necessary and RVO / copy/move-elision is possible, so std::move is now a bad thing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Many thanks for the elaboration!

@@ -894,7 +894,9 @@ void dump_ct::convert_global_variable(
}

if(!func.empty() && !symbol.is_extern)
local_static_decls[symbol.name]=d;
{
local_static_decls.insert(std::pair<irep_idt, code_declt>(symbol.name, d));
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 that's fine, but I am surprised to see this seemingly unrelated change in here. And then .emplace would seem better?!

Copy link
Member Author

Choose a reason for hiding this comment

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

It's related as follows: the PR enforces that a code_declt always has a symbol_typet parameter, which is not the case for a very brief time when using [] to insert an element into a map.
But will use .emplace.

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

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

My part looks fine.

@tautschnig
Copy link
Collaborator

Needs a rebase.

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

@kroening kroening merged commit 9d69f68 into develop Nov 6, 2018
@kroening kroening deleted the type_code_declt branch November 6, 2018 13:04
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.

8 participants