This is an archive of the discontinued LLVM Phabricator instance.

[RewriteStatepointsForGC] Removes some unnecessary calls for operator[].
Needs RevisionPublic

Authored by staronj on Feb 16 2017, 5:09 AM.

Details

Reviewers
Prazek
reames
Summary

Working on clang-tidy check that is finding modifications of container you are iterating I found this lines of code. Here, we are using operator[] on std::map. In this case is not a problem, because we use the key of actual entry and it will not break anything, but we can easily remove operator[] by binding for-loop variable by reference.

Diff Detail

Event Timeline

staronj created this revision.Feb 16 2017, 5:09 AM
reames edited edge metadata.Feb 16 2017, 5:37 PM

Can you give a bit of context on the motivation here?

staronj edited the summary of this revision. (Show Details)Feb 17 2017, 4:15 AM
reames requested changes to this revision.Feb 24 2017, 5:27 PM

All of the const changes can be separate and submitted. (Please do so before posting revised patch to simplify review.)

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
762

Sink variable to use please.

Also, assigning to reference is mildly confusing. Can you add a comment to clarify?

819

This appears to be changing behaviour. The State variable previous survive to end of scope unmodified and is now modified part way through before hitting more conditional code. Please revert.

This revision now requires changes to proceed.Feb 24 2017, 5:27 PM