aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Frontend/PCHReaderDecl.cpp2
-rw-r--r--lib/Frontend/PCHWriterDecl.cpp14
2 files changed, 5 insertions, 11 deletions
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index 0231fa66a9..5b41280138 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -926,7 +926,7 @@ void PCHDeclReader::VisitClassTemplateSpecializationDecl(
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
diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp
index 64875521c1..5d6a6d267e 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -828,10 +828,6 @@ void PCHDeclWriter::VisitTemplateDecl(TemplateDecl *D) {
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 @@ void PCHDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
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 @@ void PCHDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
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 @@ void PCHDeclWriter::VisitClassTemplateSpecializationDecl(
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);
}