[llvm-branch-commits] [cfe-branch] r115282 - /cfe/branches/Apple/whitney/lib/Serialization/ASTReader.cpp

Daniel Dunbar daniel at zuster.org
Thu Sep 30 20:42:16 PDT 2010


Author: ddunbar
Date: Thu Sep 30 22:42:16 2010
New Revision: 115282

URL: http://llvm.org/viewvc/llvm-project?rev=115282&view=rev
Log:
Merge r115263:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Fri Oct 1 01:18:02 2010 +0000

    If we get a TU_CONTEXT update from a chained PCH file before we
    actually have an ASTContext, delay the processing of that
    update. Patch by Sebastian Redl! Fixes <rdar://problem/8499034>.

Modified:
    cfe/branches/Apple/whitney/lib/Serialization/ASTReader.cpp

Modified: cfe/branches/Apple/whitney/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Serialization/ASTReader.cpp?rev=115282&r1=115281&r2=115282&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Serialization/ASTReader.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Serialization/ASTReader.cpp Thu Sep 30 22:42:16 2010
@@ -1734,7 +1734,8 @@
         reinterpret_cast<const DeclID *>(BlobStart),
         BlobLen / sizeof(DeclID)
       };
-      DeclContextOffsets[Context->getTranslationUnitDecl()].push_back(Info);
+      DeclContextOffsets[Context ? Context->getTranslationUnitDecl() : 0]
+        .push_back(Info);
       break;
     }
 
@@ -1744,7 +1745,7 @@
                         (const unsigned char *)BlobStart + Record[1],
                         (const unsigned char *)BlobStart,
                         ASTDeclContextNameLookupTrait(*this));
-      if (ID == 1) { // Is it the TU?
+      if (ID == 1 && Context) { // Is it the TU?
         DeclContextInfo Info = {
           Table, /* No lexical inforamtion */ 0, 0
         };
@@ -2195,6 +2196,17 @@
   PP->getHeaderSearchInfo().SetExternalLookup(this);
   PP->setExternalSource(this);
 
+  // If we have an update block for the TU waiting, we have to add it before
+  // deserializing the decl.
+  DeclContextOffsetsMap::iterator DCU = DeclContextOffsets.find(0);
+  if (DCU != DeclContextOffsets.end()) {
+    // Insertion could invalidate map, so grab vector.
+    DeclContextInfos T;
+    T.swap(DCU->second);
+    DeclContextOffsets.erase(DCU);
+    DeclContextOffsets[Ctx.getTranslationUnitDecl()].swap(T);
+  }
+
   // Load the translation unit declaration
   GetTranslationUnitDecl();
 





More information about the llvm-branch-commits mailing list