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

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Jul 20 06:59:40 PDT 2010


Author: akirtzidis
Date: Tue Jul 20 08:59:40 2010
New Revision: 108833

URL: http://llvm.org/viewvc/llvm-project?rev=108833&view=rev
Log:
Whether the specialization should be added to template's folding set when read from PCH,
is determined by a isCanonicalDecl check.

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=108833&r1=108832&r2=108833&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Tue Jul 20 08:59:40 2010
@@ -926,7 +926,7 @@
     D->setPointOfInstantiation(POI);
   D->setSpecializationKind((TemplateSpecializationKind)Record[Idx++]);
 
-  if (Record[Idx++]) { // IsKeptInFoldingSet.
+  if (D->isCanonicalDecl()) { // It's kept in the folding set.
     ClassTemplateDecl *CanonPattern
                        = cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++]));
     if (ClassTemplatePartialSpecializationDecl *Partial

Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=108833&r1=108832&r2=108833&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Tue Jul 20 08:59:40 2010
@@ -828,10 +828,6 @@
   Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
 }
 
-static bool IsKeptInFoldingSet(ClassTemplateSpecializationDecl *D) {
-  return D->getTypeForDecl()->getAsCXXRecordDecl() == D;
-}
-
 void PCHDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   VisitTemplateDecl(D);
 
@@ -845,7 +841,7 @@
     CTSDSetTy &CTSDSet = D->getSpecializations();
     Record.push_back(CTSDSet.size());
     for (CTSDSetTy::iterator I=CTSDSet.begin(), E = CTSDSet.end(); I!=E; ++I) {
-      assert(IsKeptInFoldingSet(&*I));
+      assert(I->isCanonicalDecl() && "Expected only canonical decls in set");
       Writer.AddDeclRef(&*I, Record);
     }
 
@@ -853,7 +849,7 @@
     CTPSDSetTy &CTPSDSet = D->getPartialSpecializations();
     Record.push_back(CTPSDSet.size());
     for (CTPSDSetTy::iterator I=CTPSDSet.begin(), E=CTPSDSet.end(); I!=E; ++I) {
-      assert(IsKeptInFoldingSet(&*I));
+      assert(I->isCanonicalDecl() && "Expected only canonical decls in set");
       Writer.AddDeclRef(&*I, Record); 
     }
 
@@ -892,10 +888,8 @@
   Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);
   Record.push_back(D->getSpecializationKind());
 
-  bool IsInInFoldingSet = IsKeptInFoldingSet(D);
-  Record.push_back(IsInInFoldingSet);
-  if (IsInInFoldingSet) {
-    // When reading, we'll add it to the folding set of this one. 
+  if (D->isCanonicalDecl()) {
+    // When reading, we'll add it to the folding set of the following template. 
     Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);
   }
 





More information about the cfe-commits mailing list