]> granicus.if.org Git - llvm/commitdiff
[Automaton] Fix invalid iterator reference
authorJames Molloy <jmolloy@google.com>
Fri, 4 Oct 2019 17:15:30 +0000 (17:15 +0000)
committerJames Molloy <jmolloy@google.com>
Fri, 4 Oct 2019 17:15:30 +0000 (17:15 +0000)
Found by the expensive checks bot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373763 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Automaton.h

index 38ab92fe63953f11402b11a75f07d5f35b6f0d53..5fe0824017dd9785827753fca8327f723e89e974 100644 (file)
@@ -94,9 +94,8 @@ private:
     // Iterate over all existing heads. We will mutate the Heads deque during
     // iteration.
     unsigned NumHeads = Heads.size();
-    for (auto HeadI = Heads.begin(), HeadE = std::next(Heads.begin(), NumHeads);
-         HeadI != HeadE; ++HeadI) {
-      PathSegment *Head = *HeadI;
+    for (unsigned I = 0; I < NumHeads; ++I) {
+      PathSegment *Head = Heads[I];
       // The sequence of pairs is sorted. Select the set of pairs that
       // transition from the current head state.
       auto PI = lower_bound(Pairs, NfaStatePair{Head->State, 0ULL});