[cfe-commits] r136373 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp

Douglas Gregor dgregor at apple.com
Thu Jul 28 12:26:52 PDT 2011


Author: dgregor
Date: Thu Jul 28 14:26:52 2011
New Revision: 136373

URL: http://llvm.org/viewvc/llvm-project?rev=136373&view=rev
Log:
Promote the deserialized PendingInstantiations vector from being a
Module member to being an ASTReader member; we want it to be
centralized for lazy deserialization.


Modified:
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=136373&r1=136372&r2=136373&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jul 28 14:26:52 2011
@@ -343,15 +343,7 @@
   /// \brief Offset of each declaration within the bitstream, indexed
   /// by the declaration ID (-1).
   const uint32_t *DeclOffsets;
-  
-  /// \brief A snapshot of the pending instantiations in the chain.
-  ///
-  /// This record tracks the instantiations that Sema has to perform at the
-  /// end of the TU. It consists of a pair of values for every pending
-  /// instantiation where the first value is the ID of the decl and the second
-  /// is the instantiation location.
-  SmallVector<uint64_t, 64> PendingInstantiations;
-  
+    
   /// \brief The number of C++ base specifier sets in this AST file.
   unsigned LocalNumCXXBaseSpecifiers;
   
@@ -737,6 +729,14 @@
   /// deserialized.
   SmallVector<uint64_t, 64> VTableUses;
 
+  /// \brief A snapshot of the pending instantiations in the chain.
+  ///
+  /// This record tracks the instantiations that Sema has to perform at the
+  /// end of the TU. It consists of a pair of values for every pending
+  /// instantiation where the first value is the ID of the decl and the second
+  /// is the instantiation location.
+  SmallVector<uint64_t, 64> PendingInstantiations;
+
   //@}
 
   /// \name Diagnostic-relevant special data

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=136373&r1=136372&r2=136373&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Jul 28 14:26:52 2011
@@ -2334,8 +2334,19 @@
       break;
 
     case PENDING_IMPLICIT_INSTANTIATIONS:
-      for (unsigned I = 0, N = Record.size(); I != N; ++I)
-        F.PendingInstantiations.push_back(getGlobalDeclID(F, Record[I]));
+      if (PendingInstantiations.size() % 2 != 0) {
+        Error("Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
+        return Failure;
+      }
+        
+      // Later lists of pending instantiations overwrite earlier ones.
+      // FIXME: This is most certainly wrong for modules.
+      PendingInstantiations.clear();
+      for (unsigned I = 0, N = Record.size(); I != N; /* in loop */) {
+        PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
+        PendingInstantiations.push_back(
+          ReadSourceLocation(F, Record, I).getRawEncoding());
+      }
       break;
 
     case SEMA_DECL_REFS:
@@ -4394,17 +4405,12 @@
       SemaObj->StdBadAlloc = SemaDeclRefs[1];
   }
 
-  // The special data sets below always come from the most recent PCH,
-  // which is at the front of the chain.
-  Module &F = ModuleMgr.getPrimaryModule();
-
   // If there were any pending implicit instantiations, deserialize them
   // and add them to Sema's queue of such instantiations.
-  assert(F.PendingInstantiations.size() % 2 == 0 &&
-         "Expected pairs of entries");
-  for (unsigned Idx = 0, N = F.PendingInstantiations.size(); Idx < N;) {
-    ValueDecl *D=cast<ValueDecl>(GetDecl(F.PendingInstantiations[Idx++]));
-    SourceLocation Loc = ReadSourceLocation(F, F.PendingInstantiations,Idx);
+  for (unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
+    ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
+    SourceLocation Loc
+      = SourceLocation::getFromRawEncoding(PendingInstantiations[Idx++]);
     SemaObj->PendingInstantiations.push_back(std::make_pair(D, Loc));
   }
 





More information about the cfe-commits mailing list