[PATCH] D23649: [ADT] Change the range-based for loop in DFS to normal loop. NFC.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 10:19:13 PDT 2016
dblaikie accepted this revision.
dblaikie added a comment.
Please update the title as well to match the intent (it's not so much about range based for loop as it is about mutating the original iterator).
Up to you if you consider the local reference preferable to directly modifying 'Opt'.
================
Comment at: include/llvm/ADT/DepthFirstIterator.h:110-114
@@ -109,3 +109,7 @@
- for (NodeRef Next : make_range(*Opt, GT::child_end(Node))) {
+ // Notice that we use `auto &It =` here, as opposed to `auto It =` or
+ // range-based for loop, so that VisitStack.back().second actually gets
+ // updated.
+ for (auto &It = *Opt; It != GT::child_end(Node); ++It) {
+ NodeRef Next = *It;
// Has our next sibling been visited?
----------------
I /think/ it'd be more explicit & probably not need the comment if you wrote it without the reference:
for (; *Opt != GT::child_end(Node); ++*Opt) {
NodeRef Next = **Opt;
...
https://reviews.llvm.org/D23649
More information about the llvm-commits
mailing list