23 #include "llvm/ADT/STLExtras.h"
25 using namespace clang;
35 : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc),
36 NumParams(Params.size()), ContainsUnexpandedParameterPack(
false) {
37 assert(this->NumParams == NumParams &&
"Too many template parameters");
38 for (
unsigned Idx = 0; Idx < NumParams; ++Idx) {
44 if (NTTP->getType()->containsUnexpandedParameterPack())
45 ContainsUnexpandedParameterPack =
true;
48 if (TTP->getTemplateParameters()->containsUnexpandedParameterPack())
49 ContainsUnexpandedParameterPack =
true;
60 void *Mem = C.
Allocate(totalSizeToAlloc<NamedDecl *>(Params.size()),
61 llvm::alignOf<TemplateParameterList>());
67 unsigned NumRequiredArgs = 0;
68 for (
iterator P = const_cast<TemplateParameterList *>(
this)->
begin(),
69 PEnd = const_cast<TemplateParameterList *>(
this)->
end();
71 if ((*P)->isTemplateParameterPack()) {
73 if (NTTP->isExpandedParameterPack()) {
74 NumRequiredArgs += NTTP->getNumExpansionTypes();
82 if (TTP->hasDefaultArgument())
85 = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
86 if (NTTP->hasDefaultArgument())
88 }
else if (cast<TemplateTemplateParmDecl>(*P)->hasDefaultArgument())
94 return NumRequiredArgs;
103 = dyn_cast<TemplateTypeParmDecl>(FirstParm))
104 return TTP->getDepth();
106 = dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
107 return NTTP->getDepth();
109 return cast<TemplateTemplateParmDecl>(FirstParm)->
getDepth();
115 PEnd = Params->
end();
117 (*P)->setDeclContext(Owner);
126 return new (
C)
char[
sizeof(
void*) * 2];
148 PrevDecls.push_back(Prev);
160 for (
unsigned I = 0, N = PrevDecls.size();
I != N; ++
I)
166 template<
class EntryType>
172 llvm::FoldingSetNodeID
ID;
174 EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
175 return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() :
nullptr;
178 template<
class Derived,
class EntryType>
180 llvm::FoldingSetVector<EntryType> &Specializations, EntryType *Entry,
185 void *CorrectInsertPos;
187 SETraits::getTemplateArgs(Entry),
189 InsertPos == CorrectInsertPos &&
190 "given incorrect InsertPos for specialization");
192 Specializations.InsertNode(Entry, InsertPos);
194 EntryType *Existing = Specializations.GetOrInsertNode(Entry);
197 "non-canonical specialization?");
201 L->AddedCXXTemplateSpecialization(cast<Derived>(
this),
202 SETraits::getDecl(Entry));
211 ParamEnd = Params->
end();
212 Param != ParamEnd; ++Param) {
216 if (TTP->isParameterPack())
221 dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
223 NTTP->getType().getNonLValueExprType(Context),
225 NTTP->getLocation());
227 if (NTTP->isParameterPack())
229 NTTP->getLocation(),
None);
239 if ((*Param)->isTemplateParameterPack())
250 void FunctionTemplateDecl::DeallocateCommon(
void *Ptr) {
287 for (uint32_t
I = 0, N = *Specs++;
I != N; ++
I)
292 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
327 void ClassTemplateDecl::DeallocateCommon(
void *Ptr) {
361 for (uint32_t
I = 0, N = *Specs++;
I != N; ++
I)
366 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
372 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
411 assert(Existing->
isCanonicalDecl() &&
"Non-canonical specialization?");
415 L->AddedCXXTemplateSpecialization(
this, D);
420 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
423 PS.reserve(PartialSpecs.size());
425 P = PartialSpecs.begin(), PEnd = PartialSpecs.end();
427 PS.push_back(
P->getMostRecentDecl());
433 using llvm::FoldingSetVector;
435 partial_spec_iterator;
439 if (Context.
hasSameType(
P->getInjectedSpecializationType(), T))
440 return P->getMostRecentDecl();
454 if (
P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
455 return P->getMostRecentDecl();
477 TemplateArgs.resize(Params->
size());
482 TemplateArgs.size());
494 bool Typename,
bool ParameterPack) {
538 NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(
DeclContext *DC,
541 unsigned D,
unsigned P,
546 unsigned NumExpandedTypes,
548 :
DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
550 ExpandedParameterPack(
true), NumExpandedTypes(NumExpandedTypes) {
551 if (ExpandedTypes && ExpandedTInfos) {
553 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
554 for (
unsigned I = 0;
I != NumExpandedTypes; ++
I) {
555 new (&TypesAndInfos[
I].first)
QualType(ExpandedTypes[
I]);
556 TypesAndInfos[
I].second = ExpandedTInfos[
I];
568 T, ParameterPack, TInfo);
574 unsigned D,
unsigned P,
578 unsigned NumExpandedTypes,
581 additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>>(
584 ExpandedTypes, NumExpandedTypes, ExpandedTInfos);
596 unsigned NumExpandedTypes) {
598 additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>>(
601 nullptr,
QualType(),
nullptr,
nullptr,
602 NumExpandedTypes,
nullptr);
622 void TemplateTemplateParmDecl::anchor() { }
624 TemplateTemplateParmDecl::TemplateTemplateParmDecl(
628 :
TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
630 ExpandedParameterPack(
true), NumExpandedParams(NumExpansions) {
632 std::uninitialized_copy(Expansions, Expansions + NumExpandedParams,
633 getTrailingObjects<TemplateParameterList *>());
652 additionalSizeToAlloc<TemplateParameterList *>(Expansions.size()))
660 false,
nullptr,
nullptr);
665 unsigned NumExpansions) {
667 additionalSizeToAlloc<TemplateParameterList *>(NumExpansions))
669 nullptr, NumExpansions,
nullptr);
680 DefaultArgument.
set(
nullptr);
690 : Arguments(getTrailingObjects<
TemplateArgument>()), NumArguments(NumArgs) {
691 std::uninitialized_copy(Args, Args + NumArgs,
692 getTrailingObjects<TemplateArgument>());
699 void *Mem = Context.
Allocate(totalSizeToAlloc<TemplateArgument>(NumArgs));
711 if (TemplateArgsAsWritten)
713 *TemplateArgsAsWritten);
725 void TemplateDecl::anchor() { }
741 SpecializedTemplate(SpecializedTemplate),
742 ExplicitInfo(nullptr),
764 Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
765 SpecializedTemplate, Args, NumArgs, PrevDecl);
782 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
787 OS, TemplateArgs.
data(), TemplateArgs.
size(), Policy);
792 if (SpecializedPartialSpecialization *PartialSpec
793 = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
794 return PartialSpec->PartialSpecialization->getSpecializedTemplate();
818 CTPSDecl *ctpsd =
const_cast<CTPSDecl*
>(cast<CTPSDecl>(
this));
820 assert(inst_from !=
nullptr);
821 return inst_from->getSourceRange();
828 if (inst_from.isNull())
830 if (ClassTemplateDecl *ctd = inst_from.dyn_cast<ClassTemplateDecl*>())
831 return ctd->getSourceRange();
840 void ClassTemplatePartialSpecializationDecl::anchor() { }
842 ClassTemplatePartialSpecializationDecl::
854 ClassTemplatePartialSpecialization,
855 TK, DC, StartLoc, IdLoc,
857 Args, NumArgs, PrevDecl),
858 TemplateParams(Params), ArgsAsWritten(ArgInfos),
859 InstantiatedFromMember(nullptr,
false)
880 Params, SpecializedTemplate, Args,
881 NumArgs, ASTArgInfos, PrevDecl);
902 void FriendTemplateDecl::anchor() { }
940 void TypeAliasTemplateDecl::DeallocateCommon(
void *Ptr) {
954 void ClassScopeFunctionSpecializationDecl::anchor() { }
967 void VarTemplateDecl::DeallocateCommon(
void *Ptr) {
1006 for (uint32_t
I = 0, N = *Specs++;
I != N; ++
I)
1011 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
1017 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
1055 assert(Existing->
isCanonicalDecl() &&
"Non-canonical specialization?");
1059 L->AddedCXXTemplateSpecialization(
this, D);
1064 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &PartialSpecs =
1067 PS.reserve(PartialSpecs.size());
1069 P = PartialSpecs.begin(),
1070 PEnd = PartialSpecs.end();
1072 PS.push_back(P->getMostRecentDecl());
1083 if (P->getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
1084 return P->getMostRecentDecl();
1098 :
VarDecl(DK, Context, DC, StartLoc, IdLoc,
1100 SpecializedTemplate(SpecializedTemplate), ExplicitInfo(nullptr),
1116 VarTemplateSpecialization, Context, DC, StartLoc, IdLoc,
1117 SpecializedTemplate, T, TInfo, S, Args, NumArgs);
1127 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
1132 OS, TemplateArgs.
data(), TemplateArgs.
size(), Policy);
1136 if (SpecializedPartialSpecialization *PartialSpec =
1137 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1138 return PartialSpec->PartialSpecialization->getSpecializedTemplate();
1144 unsigned N = ArgsInfo.
size();
1147 for (
unsigned I = 0;
I != N; ++
I)
1154 void VarTemplatePartialSpecializationDecl::anchor() {}
1156 VarTemplatePartialSpecializationDecl::VarTemplatePartialSpecializationDecl(
1163 DC, StartLoc, IdLoc, SpecializedTemplate, T,
1164 TInfo, S, Args, NumArgs),
1165 TemplateParams(Params), ArgsAsWritten(ArgInfos),
1166 InstantiatedFromMember(nullptr,
false) {
1183 Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
1184 S, Args, NumArgs, ASTArgInfos);
1200 nullptr,
true,
false);
1201 T->setImplicit(
true);
1208 nullptr, TI->
getType(),
true, TI);
1219 false,
nullptr, TPL);
1220 TemplateTemplateParm->setImplicit(
true);
1225 nullptr,
true,
false);
1226 TemplateTypeParm->setImplicit(
true);
1230 QualType(TemplateTypeParm->getTypeForDecl(), 0));
1233 nullptr, TInfo->
getType(),
false, TInfo);
1234 NamedDecl *Params[] = {TemplateTemplateParm, TemplateTypeParm,
1235 NonTypeTemplateParm};
1249 llvm_unreachable(
"unhandled BuiltinTemplateKind!");
1252 void BuiltinTemplateDecl::anchor() {}
Defines the clang::ASTContext interface.
void setImplicit(bool I=true)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
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.
A (possibly-)qualified type.
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.
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)
Decl - This represents one declaration (or definition), e.g.
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)
getValueKindForType - Given a formal return or parameter type, give its value kind.
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
A container of type source information.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setRAngleLoc(SourceLocation Loc)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Declaration of a redeclarable template.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
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>".
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
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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
getNameForDiagnostic - Appends a human-readable name for this declaration into the given stream...
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.
A convenient class for passing around template argument information.
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)
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
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.
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.
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...
detail::InMemoryDirectory::const_iterator I
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
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
isTemplateParameter - Determines whether this declaration is a template parameter pack...
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.
SourceLocation getLocStart() const LLVM_READONLY
Represents a ValueDecl that came out of a declarator.
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.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
const Type * getTypeForDecl() const
Expr - This represents one expression.
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.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
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)
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
static TemplateParameterList * createBuiltinTemplateParameterList(const ASTContext &C, DeclContext *DC, BuiltinTemplateKind BTK)
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
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.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc)
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
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
Encodes a location in the source.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const TemplateArgument * iterator
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
This names the __make_integer_seq BuiltinTemplateDecl.
bool isValid() const
Return true if this is a valid SourceLocation object.
ASTContext & getASTContext() const LLVM_READONLY
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
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.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
static void AdoptTemplateParameterList(TemplateParameterList *Params, DeclContext *Owner)
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
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()
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
const IdentifierInfo * getIdentifier() const
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
static TemplateParameterList * createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC)
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
void setLAngleLoc(SourceLocation Loc)
QualType getType() const
Return the type wrapped by this type source info.
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)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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.
This template specialization was instantiated from a template due to an explicit instantiation declar...
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
DeclarationName - The name of a declaration.
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.
detail::InMemoryDirectory::const_iterator E
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
getNameForDiagnostic - Appends a human-readable name for this declaration into the given stream...
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
getNameForDiagnostic - Appends a human-readable name for this declaration into the given stream...
Common * getCommonPtr() const
Location wrapper for a TemplateArgument.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs)
const T * getAs() const
Member-template getAs<specific type>'.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
This template specialization was declared or defined by an explicit specialization (C++ [temp...
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
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.
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.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
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
Return true if this QualType doesn't point to a type yet.
TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc)
VarTemplateDecl * getDefinition()
const TemplateArgument & getArgument() const
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
FunctionTemplateDecl * getMostRecentDecl()