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
Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
}
-static bool IsKeptInFoldingSet(ClassTemplateSpecializationDecl *D) {
- return D->getTypeForDecl()->getAsCXXRecordDecl() == D;
-}
-
void PCHDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
VisitTemplateDecl(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);
}
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);
}
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);
}