]> granicus.if.org Git - clang/commitdiff
Switch to an idiomatic C++ erase/remove for this loop, and fix a bug in the
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 6 Mar 2014 00:33:23 +0000 (00:33 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 6 Mar 2014 00:33:23 +0000 (00:33 +0000)
process (I don't believe it's possible to write a testcase for the bug with
a non-checking STL implementation).

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

lib/Serialization/ASTReader.cpp

index 41c532ec274ee0ed4818b8151abb1d7df4bf0ee7..99361d207e8d5f756c96fd72ddd1cc3b6a5658d4 100644 (file)
@@ -1684,9 +1684,11 @@ void ASTReader::removeOverriddenMacros(IdentifierInfo *II,
     }
 
     // If this macro is already in our list of conflicts, remove it from there.
-    for (unsigned AI = 0, AN = Ambig.size(); AI != AN; ++AI)
-      if (Ambig[AI]->getInfo()->getOwningModuleID() == OwnerID)
-        Ambig.erase(Ambig.begin() + AI);
+    Ambig.erase(
+        std::remove_if(Ambig.begin(), Ambig.end(), [&](DefMacroDirective *MD) {
+          return MD->getInfo()->getOwningModuleID() == OwnerID;
+        }),
+        Ambig.end());
   }
 }