return TemplateArgs;
}
- /// \brief Initialize the template arguments of the class template
- /// specialization.
- void initTemplateArgs(TemplateArgument *Args, unsigned NumArgs) {
- assert(TemplateArgs.flat_size() == 0 &&
- "Template arguments already initialized!");
- TemplateArgs.init(getASTContext(), Args, NumArgs);
- }
-
/// \brief Determine the kind of specialization that this
/// declaration represents.
TemplateSpecializationKind getSpecializationKind() const {
SpecializedTemplate = PS;
}
- /// \brief Note that this class template specialization is actually an
- /// instantiation of the given class template partial specialization whose
- /// template arguments have been deduced.
- void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec,
- TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs) {
- ASTContext &Ctx = getASTContext();
- setInstantiationOf(PartialSpec,
- new (Ctx) TemplateArgumentList(Ctx, TemplateArgs,
- NumTemplateArgs));
- }
-
/// \brief Note that this class template specialization is an instantiation
/// of the given class template.
void setInstantiationOf(ClassTemplateDecl *TemplDecl) {
static bool classof(const ClassTemplatePartialSpecializationDecl *) {
return true;
}
+
+ friend class ASTDeclReader;
+ friend class ASTDeclWriter;
};
class ClassTemplatePartialSpecializationDecl
void ASTDeclReader::VisitClassTemplateSpecializationDecl(
ClassTemplateSpecializationDecl *D) {
VisitCXXRecordDecl(D);
-
+
+ ASTContext &C = *Reader.getContext();
if (Decl *InstD = Reader.GetDecl(Record[Idx++])) {
if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
- D->setInstantiationOf(CTD);
+ D->SpecializedTemplate = CTD;
} else {
llvm::SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, Cursor, Record, Idx);
- D->setInstantiationOf(cast<ClassTemplatePartialSpecializationDecl>(InstD),
- TemplArgs.data(), TemplArgs.size());
+ TemplateArgumentList *ArgList
+ = new (C) TemplateArgumentList(C, TemplArgs.data(), TemplArgs.size());
+ ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
+ = new (C) ClassTemplateSpecializationDecl::
+ SpecializedPartialSpecialization();
+ PS->PartialSpecialization
+ = cast<ClassTemplatePartialSpecializationDecl>(InstD);
+ PS->TemplateArgs = ArgList;
+ D->SpecializedTemplate = PS;
}
}
// Explicit info.
if (TypeSourceInfo *TyInfo = Reader.GetTypeSourceInfo(Cursor, Record, Idx)) {
- D->setTypeAsWritten(TyInfo);
- D->setExternLoc(Reader.ReadSourceLocation(Record, Idx));
- D->setTemplateKeywordLoc(Reader.ReadSourceLocation(Record, Idx));
+ ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo
+ = new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
+ ExplicitInfo->TypeAsWritten = TyInfo;
+ ExplicitInfo->ExternLoc = Reader.ReadSourceLocation(Record, Idx);
+ ExplicitInfo->TemplateKeywordLoc = Reader.ReadSourceLocation(Record, Idx);
+ D->ExplicitInfo = ExplicitInfo;
}
llvm::SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, Cursor, Record, Idx);
- D->initTemplateArgs(TemplArgs.data(), TemplArgs.size());
- SourceLocation POI = Reader.ReadSourceLocation(Record, Idx);
- if (POI.isValid())
- D->setPointOfInstantiation(POI);
- D->setSpecializationKind((TemplateSpecializationKind)Record[Idx++]);
+ D->TemplateArgs.init(C, TemplArgs.data(), TemplArgs.size());
+ D->PointOfInstantiation = Reader.ReadSourceLocation(Record, Idx);
+ D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
if (D->isCanonicalDecl()) { // It's kept in the folding set.
ClassTemplateDecl *CanonPattern