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

Sebastian Redl sebastian.redl at getdesigned.at
Tue Aug 24 15:50:19 PDT 2010


Author: cornedbee
Date: Tue Aug 24 17:50:19 2010
New Revision: 111985

URL: http://llvm.org/viewvc/llvm-project?rev=111985&view=rev
Log:
AST reader support for having specializations of templates from earlier in the chain.

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

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=111985&r1=111984&r2=111985&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Tue Aug 24 17:50:19 2010
@@ -316,7 +316,11 @@
       /// \brief Record code for an update to a decl context's lookup table.
       ///
       /// In practice, this should only be used for the TU and namespaces.
-      UPDATE_VISIBLE = 34
+      UPDATE_VISIBLE = 34,
+
+      /// \brief Record code for template specializations introduced after
+      /// serializations of the original template decl.
+      ADDITIONAL_TEMPLATE_SPECIALIZATIONS = 35
     };
 
     /// \brief Record types used within a source manager block.

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=111985&r1=111984&r2=111985&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Aug 24 17:50:19 2010
@@ -372,6 +372,16 @@
   /// most recent declarations in another AST file.
   FirstLatestDeclIDMap FirstLatestDeclIDs;
 
+  typedef llvm::SmallVector<serialization::DeclID, 4>
+      AdditionalTemplateSpecializations;
+  typedef llvm::DenseMap<serialization::DeclID,
+                         AdditionalTemplateSpecializations>
+      AdditionalTemplateSpecializationsMap;
+
+  /// \brief Additional specializations (including partial) of templates that
+  /// were introduced after the template was serialized.
+  AdditionalTemplateSpecializationsMap AdditionalTemplateSpecializationsPending;
+
   /// \brief Read the records that describe the contents of declcontexts.
   bool ReadDeclContextStorage(llvm::BitstreamCursor &Cursor,
                               const std::pair<uint64_t, uint64_t> &Offsets,

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=111985&r1=111984&r2=111985&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Aug 24 17:50:19 2010
@@ -1972,6 +1972,13 @@
             std::make_pair(&F, Record[I+1]);
       break;
     }
+
+    case ADDITIONAL_TEMPLATE_SPECIALIZATIONS: {
+      AdditionalTemplateSpecializations &ATS =
+          AdditionalTemplateSpecializationsPending[Record[0]];
+      ATS.insert(ATS.end(), Record.begin()+1, Record.end());
+      break;
+    }
     }
     First = false;
   }

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=111985&r1=111984&r2=111985&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Aug 24 17:50:19 2010
@@ -1424,6 +1424,20 @@
       }
     }
   }
+
+  // If this is a template, read additional specializations that may be in a
+  // different part of the chain.
+  if (isa<RedeclarableTemplateDecl>(D)) {
+    AdditionalTemplateSpecializationsMap::iterator F =
+        AdditionalTemplateSpecializationsPending.find(ID);
+    if (F != AdditionalTemplateSpecializationsPending.end()) {
+      for (AdditionalTemplateSpecializations::iterator I = F->second.begin(),
+                                                       E = F->second.end();
+           I != E; ++I)
+        GetDecl(*I);
+      AdditionalTemplateSpecializationsPending.erase(F);
+    }
+  }
   assert(Idx == Record.size());
 
   // If we have deserialized a declaration that has a definition the





More information about the cfe-commits mailing list