[cfe-commits] r107476 - in /cfe/trunk/lib/Frontend: PCHReaderDecl.cpp PCHWriterDecl.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Jul 2 04:55:37 PDT 2010


Author: akirtzidis
Date: Fri Jul  2 06:55:37 2010
New Revision: 107476

URL: http://llvm.org/viewvc/llvm-project?rev=107476&view=rev
Log:
Fix reading ClassTemplateDecl's ClassTemplateSpecializationDecls and ClassTemplatePartialSpecializationDecls.

Store/read also their template arguments because they may be initializing and not be able to provide them.

Modified:
    cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
    cfe/trunk/lib/Frontend/PCHWriterDecl.cpp

Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=107476&r1=107475&r2=107476&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Fri Jul  2 06:55:37 2010
@@ -768,11 +768,12 @@
     while (size--) {
       ClassTemplateSpecializationDecl *CTSD
          = cast<ClassTemplateSpecializationDecl>(Reader.GetDecl(Record[Idx++]));
+      llvm::SmallVector<TemplateArgument, 8> TemplArgs;
+      Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx);
       llvm::FoldingSetNodeID ID;
       void *InsertPos = 0;
-      ClassTemplateSpecializationDecl::Profile(ID, 
-                                  CTSD->getTemplateArgs().getFlatArgumentList(),
-                                            CTSD->getTemplateArgs().flat_size(),
+      ClassTemplateSpecializationDecl::Profile(ID, TemplArgs.data(),
+                                               TemplArgs.size(),
                                                *Reader.getContext());
       D->getSpecializations().FindNodeOrInsertPos(ID, InsertPos);
       D->getSpecializations().InsertNode(CTSD, InsertPos);
@@ -783,12 +784,13 @@
       ClassTemplatePartialSpecializationDecl *CTSD
          = cast<ClassTemplatePartialSpecializationDecl>(
                                                  Reader.GetDecl(Record[Idx++]));
+      llvm::SmallVector<TemplateArgument, 8> TemplArgs;
+      Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx);
       llvm::FoldingSetNodeID ID;
       void *InsertPos = 0;
-      ClassTemplatePartialSpecializationDecl::Profile(ID, 
-                                  CTSD->getTemplateArgs().getFlatArgumentList(),
-                                            CTSD->getTemplateArgs().flat_size(),
-                                               *Reader.getContext());
+      ClassTemplatePartialSpecializationDecl::Profile(ID, TemplArgs.data(),
+                                                      TemplArgs.size(),
+                                                      *Reader.getContext());
       D->getPartialSpecializations().FindNodeOrInsertPos(ID, InsertPos);
       D->getPartialSpecializations().InsertNode(CTSD, InsertPos);
     }

Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=107476&r1=107475&r2=107476&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Fri Jul  2 06:55:37 2010
@@ -751,14 +751,24 @@
     typedef llvm::FoldingSet<ClassTemplateSpecializationDecl> CTSDSetTy;
     CTSDSetTy &CTSDSet = D->getSpecializations();
     Record.push_back(CTSDSet.size());
-    for (CTSDSetTy::iterator I=CTSDSet.begin(), E = CTSDSet.end(); I!=E; ++I)
-      Writer.AddDeclRef(&*I, Record);
+    for (CTSDSetTy::iterator I=CTSDSet.begin(), E = CTSDSet.end(); I!=E; ++I) {
+      ClassTemplateSpecializationDecl *CTSD = &*I; 
+      Writer.AddDeclRef(CTSD, Record);
+      // Write the argument list here because we may get it uninitialized when
+      // reading it back. 
+      Writer.AddTemplateArgumentList(&CTSD->getTemplateArgs(), Record);
+    }
 
     typedef llvm::FoldingSet<ClassTemplatePartialSpecializationDecl> CTPSDSetTy;
     CTPSDSetTy &CTPSDSet = D->getPartialSpecializations();
     Record.push_back(CTPSDSet.size());
-    for (CTPSDSetTy::iterator I=CTPSDSet.begin(), E = CTPSDSet.end(); I!=E; ++I)
-      Writer.AddDeclRef(&*I, Record);
+    for (CTPSDSetTy::iterator I=CTPSDSet.begin(), E=CTPSDSet.end(); I!=E; ++I) {
+      ClassTemplatePartialSpecializationDecl *CTPSD = &*I; 
+      Writer.AddDeclRef(CTPSD, Record);
+      // Write the argument list here because we may get it uninitialized when
+      // reading it back. 
+      Writer.AddTemplateArgumentList(&CTPSD->getTemplateArgs(), Record);
+    }
 
     // InjectedClassNameType is computed, no need to write it.
 





More information about the cfe-commits mailing list