]> granicus.if.org Git - clang/commitdiff
updateOutOfDateIdentifier() can cause the identifier table to be
authorDouglas Gregor <dgregor@apple.com>
Mon, 7 Jan 2013 16:56:53 +0000 (16:56 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 7 Jan 2013 16:56:53 +0000 (16:56 +0000)
rehashed, invaliding the iterator walking through the identifier
table. Separate out the identification of out-of-date identifiers from
updating them.

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

lib/Serialization/ASTWriter.cpp

index 58f7fe7051c3545351df7035182b13bc159c84fd..887876f284278e02c420cff123031c64b3c76acd 100644 (file)
@@ -3459,11 +3459,19 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
 
   // If there are any out-of-date identifiers, bring them up to date.
   if (ExternalPreprocessorSource *ExtSource = PP.getExternalSource()) {
+    // Find out-of-date identifiers.
+    SmallVector<IdentifierInfo *, 4> OutOfDate;
     for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(),
                                 IDEnd = PP.getIdentifierTable().end();
-         ID != IDEnd; ++ID)
+         ID != IDEnd; ++ID) {
       if (ID->second->isOutOfDate())
-        ExtSource->updateOutOfDateIdentifier(*ID->second);
+        OutOfDate.push_back(ID->second);
+    }
+
+    // Update the out-of-date identifiers.
+    for (unsigned I = 0, N = OutOfDate.size(); I != N; ++I) {
+      ExtSource->updateOutOfDateIdentifier(*OutOfDate[I]);
+    }
   }
 
   // Build a record containing all of the tentative definitions in this file, in