This is an archive of the discontinued LLVM Phabricator instance.

[IR] Use a reference in a range-based for
ClosedPublic

Authored by Mordante on Nov 30 2019, 12:06 PM.

Details

Summary

This avoids unneeded copies when using a range-based for loops.

This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Diff Detail

Event Timeline

Mordante created this revision.Nov 30 2019, 12:06 PM
fhahn added a subscriber: fhahn.Dec 1 2019, 3:13 AM
fhahn added inline comments.
llvm/lib/IR/Attributes.cpp
728

It might help a bit more with readability of the code (here and other places in the patch) if you expand the type instead of auto, if the type is not too long (https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable)

Mordante marked an inline comment as done.Dec 1 2019, 11:48 AM
Mordante added inline comments.
llvm/lib/IR/Attributes.cpp
728

According the that link it's common to use auto in a range-based for loop. However I agree using *this makes it a bit odd. I'd like the opinion of the reviewers to see how they feel about the usage of auto here.

xbolva00 accepted this revision.Dec 17 2019, 4:30 AM
xbolva00 added inline comments.
llvm/lib/IR/Attributes.cpp
728

I think auto is fine.

This revision is now accepted and ready to land.Dec 17 2019, 4:30 AM
This revision was automatically updated to reflect the committed changes.