22 #include "llvm/ADT/STLExtras.h"
24 using namespace clang;
34 : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc),
35 NumParams(NumParams), ContainsUnexpandedParameterPack(
false) {
36 assert(this->NumParams == NumParams &&
"Too many template parameters");
37 for (
unsigned Idx = 0; Idx < NumParams; ++Idx) {
43 if (NTTP->getType()->containsUnexpandedParameterPack())
44 ContainsUnexpandedParameterPack =
true;
47 if (TTP->getTemplateParameters()->containsUnexpandedParameterPack())
48 ContainsUnexpandedParameterPack =
true;
62 unsigned Align = std::max(llvm::alignOf<TemplateParameterList>(),
63 llvm::alignOf<NamedDecl*>());
66 NumParams, RAngleLoc);
70 unsigned NumRequiredArgs = 0;
71 for (
iterator P = const_cast<TemplateParameterList *>(
this)->
begin(),
72 PEnd = const_cast<TemplateParameterList *>(
this)->
end();
74 if ((*P)->isTemplateParameterPack()) {
76 if (NTTP->isExpandedParameterPack()) {
77 NumRequiredArgs += NTTP->getNumExpansionTypes();
85 if (TTP->hasDefaultArgument())
88 = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
89 if (NTTP->hasDefaultArgument())
91 }
else if (cast<TemplateTemplateParmDecl>(*P)->hasDefaultArgument())
97 return NumRequiredArgs;
106 = dyn_cast<TemplateTypeParmDecl>(FirstParm))
107 return TTP->getDepth();
109 = dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
110 return NTTP->getDepth();
112 return cast<TemplateTemplateParmDecl>(FirstParm)->
getDepth();
118 PEnd = Params->
end();
120 (*P)->setDeclContext(Owner);
129 return new (
C)
char[
sizeof(
void*) * 2];
151 PrevDecls.push_back(Prev);
163 for (
unsigned I = 0, N = PrevDecls.size(); I != N; ++I)
169 template<
class EntryType>
175 llvm::FoldingSetNodeID
ID;
177 EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
178 return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() :
nullptr;
181 template<
class Derived,
class EntryType>
183 llvm::FoldingSetVector<EntryType> &Specializations, EntryType *Entry,
188 void *CorrectInsertPos;
190 SETraits::getTemplateArgs(Entry),
192 InsertPos == CorrectInsertPos &&
193 "given incorrect InsertPos for specialization");
195 Specializations.InsertNode(Entry, InsertPos);
197 EntryType *Existing = Specializations.GetOrInsertNode(Entry);
200 "non-canonical specialization?");
204 L->AddedCXXTemplateSpecialization(cast<Derived>(
this),
205 SETraits::getDecl(Entry));
214 ParamEnd = Params->
end();
215 Param != ParamEnd; ++Param) {
219 if (TTP->isParameterPack())
224 dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
226 NTTP->getType().getNonLValueExprType(Context),
228 NTTP->getLocation());
230 if (NTTP->isParameterPack())
232 NTTP->getLocation(),
None);
242 if ((*Param)->isTemplateParameterPack())
253 void FunctionTemplateDecl::DeallocateCommon(
void *Ptr) {
290 for (uint32_t I = 0, N = *Specs++; I != N; ++I)
295 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
330 void ClassTemplateDecl::DeallocateCommon(
void *Ptr) {
364 for (uint32_t I = 0, N = *Specs++; I != N; ++I)
369 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
375 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
414 assert(Existing->
isCanonicalDecl() &&
"Non-canonical specialization?");
418 L->AddedCXXTemplateSpecialization(
this, D);
423 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
426 PS.reserve(PartialSpecs.size());
427 for (llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>::iterator
428 P = PartialSpecs.begin(), PEnd = PartialSpecs.end();
430 PS.push_back(
P->getMostRecentDecl());
436 using llvm::FoldingSetVector;
437 typedef FoldingSetVector<ClassTemplatePartialSpecializationDecl>::iterator
438 partial_spec_iterator;
442 if (Context.
hasSameType(
P->getInjectedSpecializationType(), T))
443 return P->getMostRecentDecl();
453 for (llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>::iterator
457 if (
P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
458 return P->getMostRecentDecl();
480 TemplateArgs.resize(Params->
size());
485 TemplateArgs.size());
497 bool Typename,
bool ParameterPack) {
541 NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(
DeclContext *DC,
544 unsigned D,
unsigned P,
549 unsigned NumExpandedTypes,
551 :
DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
553 ExpandedParameterPack(
true), NumExpandedTypes(NumExpandedTypes) {
554 if (ExpandedTypes && ExpandedTInfos) {
555 void **TypesAndInfos =
reinterpret_cast<void **
>(
this + 1);
556 for (
unsigned I = 0; I != NumExpandedTypes; ++I) {
558 TypesAndInfos[2*I + 1] = ExpandedTInfos[I];
570 T, ParameterPack, TInfo);
576 unsigned D,
unsigned P,
580 unsigned NumExpandedTypes,
582 unsigned Extra = NumExpandedTypes * 2 *
sizeof(
void*);
584 DC, StartLoc, IdLoc, D, P, Id, T, TInfo,
585 ExpandedTypes, NumExpandedTypes, ExpandedTInfos);
597 unsigned NumExpandedTypes) {
598 unsigned Extra = NumExpandedTypes * 2 *
sizeof(
void*);
601 nullptr,
nullptr, NumExpandedTypes,
nullptr);
621 void TemplateTemplateParmDecl::anchor() { }
623 TemplateTemplateParmDecl::TemplateTemplateParmDecl(
627 :
TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
629 ExpandedParameterPack(
true), NumExpandedParams(NumExpansions) {
631 std::memcpy(reinterpret_cast<void*>(
this + 1), Expansions,
652 Expansions.size(), Expansions.data());
658 false,
nullptr,
nullptr);
663 unsigned NumExpansions) {
666 nullptr, NumExpansions,
nullptr);
677 DefaultArgument.
set(
nullptr);
695 std::uninitialized_copy(Args, Args + NumArgs, StoredArgs);
707 if (TemplateArgsAsWritten)
709 *TemplateArgsAsWritten);
721 void TemplateDecl::anchor() { }
735 SpecializedTemplate->getIdentifier(),
737 SpecializedTemplate(SpecializedTemplate),
738 ExplicitInfo(nullptr),
760 Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
761 SpecializedTemplate, Args, NumArgs, PrevDecl);
778 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
783 OS, TemplateArgs.
data(), TemplateArgs.
size(), Policy);
788 if (SpecializedPartialSpecialization *PartialSpec
789 = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
790 return PartialSpec->PartialSpecialization->getSpecializedTemplate();
814 CTPSDecl *ctpsd =
const_cast<CTPSDecl*
>(cast<CTPSDecl>(
this));
816 assert(inst_from !=
nullptr);
817 return inst_from->getSourceRange();
824 if (inst_from.isNull())
826 if (ClassTemplateDecl *ctd = inst_from.dyn_cast<ClassTemplateDecl*>())
827 return ctd->getSourceRange();
836 void ClassTemplatePartialSpecializationDecl::anchor() { }
838 ClassTemplatePartialSpecializationDecl::
850 ClassTemplatePartialSpecialization,
851 TK, DC, StartLoc, IdLoc,
853 Args, NumArgs, PrevDecl),
854 TemplateParams(Params), ArgsAsWritten(ArgInfos),
855 InstantiatedFromMember(nullptr,
false)
876 Params, SpecializedTemplate, Args,
877 NumArgs, ASTArgInfos, PrevDecl);
898 void FriendTemplateDecl::anchor() { }
936 void TypeAliasTemplateDecl::DeallocateCommon(
void *Ptr) {
950 void ClassScopeFunctionSpecializationDecl::anchor() { }
963 void VarTemplateDecl::DeallocateCommon(
void *Ptr) {
1002 for (uint32_t I = 0, N = *Specs++; I != N; ++I)
1007 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
1013 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
1051 assert(Existing->
isCanonicalDecl() &&
"Non-canonical specialization?");
1055 L->AddedCXXTemplateSpecialization(
this, D);
1060 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &PartialSpecs =
1063 PS.reserve(PartialSpecs.size());
1064 for (llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>::iterator
1065 P = PartialSpecs.begin(),
1066 PEnd = PartialSpecs.end();
1068 PS.push_back(P->getMostRecentDecl());
1075 for (llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>::iterator
1079 if (P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
1080 return P->getMostRecentDecl();
1094 :
VarDecl(DK, Context, DC, StartLoc, IdLoc,
1095 SpecializedTemplate->getIdentifier(), T, TInfo, S),
1096 SpecializedTemplate(SpecializedTemplate), ExplicitInfo(nullptr),
1112 VarTemplateSpecialization, Context, DC, StartLoc, IdLoc,
1113 SpecializedTemplate, T, TInfo, S, Args, NumArgs);
1123 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
1128 OS, TemplateArgs.
data(), TemplateArgs.
size(), Policy);
1132 if (SpecializedPartialSpecialization *PartialSpec =
1133 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1134 return PartialSpec->PartialSpecialization->getSpecializedTemplate();
1140 unsigned N = ArgsInfo.
size();
1143 for (
unsigned I = 0; I != N; ++I)
1150 void VarTemplatePartialSpecializationDecl::anchor() {}
1152 VarTemplatePartialSpecializationDecl::VarTemplatePartialSpecializationDecl(
1159 DC, StartLoc, IdLoc, SpecializedTemplate, T,
1160 TInfo, S, Args, NumArgs),
1161 TemplateParams(Params), ArgsAsWritten(ArgInfos),
1162 InstantiatedFromMember(nullptr,
false) {
1179 Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
1180 S, Args, NumArgs, ASTArgInfos);
Defines the clang::ASTContext interface.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
virtual Decl * GetExternalDecl(uint32_t ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
bool isParameterPack() const
Returns whether this is a parameter pack.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration. If PrevDecl is NULL, set this as the first and only declaration...
ArrayRef< TemplateArgument > getInjectedTemplateArgs()
Retrieve the "injected" template arguments that correspond to the template parameters of this functio...
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, NamedDecl **Params, unsigned NumParams, SourceLocation RAngleLoc)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Defines the C++ template declaration subclasses.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, ClassTemplateSpecializationDecl *PrevDecl)
Declaration of a variable template.
static ExprValueKind getValueKindForType(QualType T)
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
A container of type source information.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
void * getAsOpaquePtr() const
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setRAngleLoc(SourceLocation Loc)
Declaration of a redeclarable template.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
static TemplateArgument CreatePackCopy(ASTContext &Context, const TemplateArgument *Args, unsigned NumArgs)
Create a new template argument pack by copying the given set of template arguments.
Represents a variable template specialization, which refers to a variable template with a given set o...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>". This is safe to be used inside an AST node, in contrast with TemplateArgumentListInfo.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
bool MayHaveOutOfDateDef
Indicates whether it is possible for declarations of this kind to have an out-of-date definition...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Defines the clang::Expr interface and subclasses for C++ expressions.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ASTMutationListener * getASTMutationListener() const
Represents a class template specialization, which refers to a class template with a given set of temp...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Defines the position of a template parameter within a template parameter list.
Common * getCommonPtr() const
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void * allocateDefaultArgStorageChain(const ASTContext &C)
SourceLocation getLocation() const
Fetches the primary location of the argument.
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Declaration of a function specialization at template class scope.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, unsigned NParams, TemplateParameterList **Params, FriendUnion Friend, SourceLocation FriendLoc)
TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Provides information about a function template specialization, which is a FunctionDecl that has been ...
SourceLocation getBeginLoc() const
Get the begin source location.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
static TemplateArgumentList * CreateCopy(ASTContext &Context, const TemplateArgument *Args, unsigned NumArgs)
Create a new template argument list that copies the given set of template arguments.
void set(ArgType Arg)
Set the default argument.
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this class template.
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known ownly by...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setSpecializationKind(TemplateSpecializationKind TSK)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getRBraceLoc() const
SourceLocation getRAngleLoc() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember()
Retrieve the member class template partial specialization from which this particular class template p...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI)
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in. InsertPos must be obta...
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
QualType getTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon=QualType()) const
bool isTemplateParameterPack() const
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
SpecEntryTraits< EntryType >::DeclType * findSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, ArrayRef< TemplateArgument > Args, void *&InsertPos)
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in. InsertPos must be obtained fro...
SourceLocation getLocStart() const LLVM_READONLY
Represents a ValueDecl that came out of a declarator. Contains type source information through TypeSo...
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
ID
Defines the set of possible language-specific address spaces.
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in. InsertPos must be obta...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
const Type * getTypeForDecl() const
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Declaration of a template type parameter.
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, ClassTemplateDecl *PrevDecl)
Create a class template node.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Data that is common to all of the declarations of a given variable template.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template. Calling this routine may implicitly allocate memory for the common pointer.
Represents a C++ template name within the type system.
Defines the clang::TypeLoc interface and its subclasses.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
StorageClass
Storage classes.
Declaration of an alias template.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Data that is common to all of the declarations of a given class template.
The result type of a method or function.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
SourceLocation getEndLoc() const
Get the end source location.
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions)
void setTypeForDecl(const Type *TD)
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
RedeclarableTemplateDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
CommonBase * newCommon(ASTContext &C) const override
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
QualType InjectedClassNameType
The injected-class-name type for this class template.
void AddDeallocation(void(*Callback)(void *), void *Data)
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
SourceLocation getOuterLocStart() const
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
const Type * getTypePtr() const
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
bool isValid() const
Return true if this is a valid SourceLocation object.
ASTContext & getASTContext() const LLVM_READONLY
CommonBase * newCommon(ASTContext &C) const override
unsigned getDepth() const
Retrieve the depth of the template parameter.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Data that is common to all of the declarations of a given function template.
static void AdoptTemplateParameterList(TemplateParameterList *Params, DeclContext *Owner)
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
SourceLocation getLAngleLoc() const
ClassTemplateDecl * getMostRecentDecl()
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
void setLAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, ClassTemplateSpecializationDecl *PrevDecl)
Represents a template argument.
TagTypeKind
The kind of a tag type.
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
The base class of all kinds of template declarations (e.g., class, function, etc.).
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Represents a C++11 pack expansion that produces a sequence of expressions.
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
bool isNull() const
Determine whether this template argument has no value.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known only by ...
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs, const TemplateArgumentListInfo &ArgInfos)
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Common * getCommonPtr() const
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs)
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or NULL if no such declaration exists...
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
TemplateArgument * InjectedArgs
The set of "injected" template arguments used within this function template.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in. InsertPos must be obtained fro...
VarTemplateDecl * getMostRecentDecl()
Represents a C++ struct/union/class.
static const ASTTemplateArgumentListInfo * Create(ASTContext &C, const TemplateArgumentListInfo &List)
CommonBase * newCommon(ASTContext &C) const override
void addSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, EntryType *Entry, void *InsertPos)
CommonBase * newCommon(ASTContext &C) const override
void * Allocate(size_t Size, unsigned Align=8) const
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
VarTemplateSpecializationDecl(Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs)
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Declaration of a class template.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
unsigned getIndex() const
Retrieve the index of the template parameter.
uint32_t * LazySpecializations
If non-null, points to an array of specializations known only by their external declaration IDs...
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
Kind
Lists the kind of concrete classes of Decl.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
static void GenerateInjectedTemplateArgs(ASTContext &Context, TemplateParameterList *Params, TemplateArgument *Args)
Generate the injected template arguments for the given template parameter list, e.g., for the injected-class-name of a class template.
Common * getCommonPtr() const
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
virtual CommonBase * newCommon(ASTContext &C) const =0
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
static void PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgument *Args, unsigned NumArgs, const PrintingPolicy &Policy, bool SkipBrackets=false)
Print a template argument list, including the '<' and '>' enclosing the template arguments...
A trivial tuple used to represent a source range.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Declaration of a friend template.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
VarTemplateDecl * getDefinition()
const TemplateArgument & getArgument() const
Declaration of a template function.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, NamedDecl **Params, unsigned NumParams, SourceLocation RAngleLoc)
FunctionTemplateDecl * getMostRecentDecl()