This is an archive of the discontinued LLVM Phabricator instance.

[PM] Use range-based for loops in LegacyPassManager.cpp (NFC).
ClosedPublic

Authored by fhahn on Jul 12 2017, 9:13 AM.

Details

Summary

This patch replaces a bunch of iterator-based for loops with range-based
for loops. There are 2 iterator-based loops left in this file in
removeNotPreservedAnalysis, but I think those cannot be replaced by
range-based for loops as they modify the container they are iterating
over.

Unless I missed something, this schould be a NFC and I would appreciate
if someone could have a quick look to confirm that.

Diff Detail

Event Timeline

fhahn created this revision.Jul 12 2017, 9:13 AM
mehdi_amini added inline comments.Jul 12 2017, 9:39 AM
lib/IR/LegacyPassManager.cpp
641

Shouldn't this be a break;?

1255

Side note but: why don't we use unique_ptr? (always surprised when I see delete used)

fhahn updated this revision to Diff 106246.Jul 12 2017, 9:44 AM

Use break instead of continue

lib/IR/LegacyPassManager.cpp
641

Ah yes!

1255

I can check how much effort using unique_ptr would be and will submit a separate patch if it's feasible.

jhenderson accepted this revision.Jul 13 2017, 2:36 AM

LGTM, with one minor request.

lib/IR/LegacyPassManager.cpp
1073–1074

Could you use ID here instead of I, please, for consistency (and readability)?

This revision is now accepted and ready to land.Jul 13 2017, 2:36 AM
fhahn updated this revision to Diff 106387.Jul 13 2017, 3:36 AM
fhahn marked an inline comment as done.

Changed I -> ID

fhahn added a comment.Jul 13 2017, 3:37 AM

Thanks James & Mehdi

fhahn closed this revision.Jul 13 2017, 3:52 AM