Skip to content

C++ front-end: use ranged for #3066

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 5 commits into from
Sep 30, 2018
Merged

C++ front-end: use ranged for #3066

merged 5 commits into from
Sep 30, 2018

Conversation

kroening
Copy link
Member

  • 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).
  • 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: 7137d06).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86369132
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
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.

Great, with even more room for related cleanup I believe.

for(std::size_t i=0; i<function_call.op1().operands().size(); i++)
operands.push_back(function_call.op1().operands()[i]);
for(const auto &op : function_call.op1().operands())
operands.push_back(op);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rewrite this (and some lines above) as operands = function_call.op1().operands(); ?

@@ -483,7 +462,7 @@ void cpp_typecheck_resolvet::disambiguate_functions(
1000*template_distance+args_distance;

distance_map.insert(
std::pair<std::size_t, exprt>(total_distance, *it));
std::pair<std::size_t, exprt>(total_distance, old_id));
Copy link
Collaborator

Choose a reason for hiding this comment

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

More modernisation: distance_map.insert({total_distance, old_id});

it++)
function_call.op1().copy_to_operands(*it);
for(auto &op : operands_tc)
function_call.op1().copy_to_operands(op);
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 we can get rid of this loop entirely if using a 3-argument constructor for function_call above.

{
for(unsigned i=0; i<indent; i++) out << ' ';
out << " secondary_scope=" << (*it)->identifier << '\n';
out << " secondary_scope=" << s->identifier << '\n';
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could further simplify this loop by using std::string(indent, ' ') in place of the for loop above. Applies several times across this file.

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

@kroening
Copy link
Member Author

All done!

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

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

@tautschnig tautschnig merged commit 270d487 into develop Sep 30, 2018
@tautschnig tautschnig deleted the cpp-ranged-for branch September 30, 2018 13:33
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.

4 participants