27 #include "llvm/ADT/ArrayRef.h" 28 #include "llvm/ADT/FoldingSet.h" 29 #include "llvm/ADT/None.h" 30 #include "llvm/ADT/PointerUnion.h" 31 #include "llvm/ADT/SmallVector.h" 32 #include "llvm/Support/Casting.h" 33 #include "llvm/Support/ErrorHandling.h" 40 using namespace clang;
53 : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc),
54 NumParams(Params.size()), ContainsUnexpandedParameterPack(
false),
55 HasRequiresClause(RequiresClause != nullptr),
56 HasConstrainedParameters(
false) {
57 for (
unsigned Idx = 0; Idx < NumParams; ++Idx) {
62 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
63 if (!IsPack && NTTP->getType()->containsUnexpandedParameterPack())
64 ContainsUnexpandedParameterPack =
true;
65 if (NTTP->hasPlaceholderTypeConstraint())
66 HasConstrainedParameters =
true;
67 }
else if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P)) {
69 TTP->getTemplateParameters()->containsUnexpandedParameterPack())
70 ContainsUnexpandedParameterPack =
true;
72 cast<TemplateTypeParmDecl>(P)->getTypeConstraint()) {
73 if (TC->getImmediatelyDeclaredConstraint()
74 ->containsUnexpandedParameterPack())
75 ContainsUnexpandedParameterPack =
true;
76 HasConstrainedParameters =
true;
82 if (HasRequiresClause) {
84 ContainsUnexpandedParameterPack =
true;
85 *getTrailingObjects<Expr *>() = RequiresClause;
94 void *Mem = C.
Allocate(totalSizeToAlloc<NamedDecl *, Expr *>(
95 Params.size(), RequiresClause ? 1u : 0u),
98 RAngleLoc, RequiresClause);
102 unsigned NumRequiredArgs = 0;
104 if (
P->isTemplateParameterPack()) {
105 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
P)) {
106 if (NTTP->isExpandedParameterPack()) {
107 NumRequiredArgs += NTTP->getNumExpansionTypes();
110 }
else if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(
P)) {
111 if (TTP->isExpandedParameterPack()) {
112 NumRequiredArgs += TTP->getNumExpansionParameters();
116 const auto *TP = cast<TemplateTemplateParmDecl>(
P);
117 if (TP->isExpandedParameterPack()) {
118 NumRequiredArgs += TP->getNumExpansionTemplateParameters();
126 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(
P)) {
127 if (TTP->hasDefaultArgument())
129 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
P)) {
130 if (NTTP->hasDefaultArgument())
132 }
else if (cast<TemplateTemplateParmDecl>(
P)->hasDefaultArgument())
138 return NumRequiredArgs;
146 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(FirstParm))
147 return TTP->getDepth();
148 else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
149 return NTTP->getDepth();
151 return cast<TemplateTemplateParmDecl>(FirstParm)->
getDepth();
157 P->setDeclContext(Owner);
159 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
P))
166 if (HasConstrainedParameters)
168 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
169 if (
const auto *TC = TTP->getTypeConstraint())
170 AC.push_back(TC->getImmediatelyDeclaredConstraint());
171 }
else if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
172 if (
const Expr *E = NTTP->getPlaceholderTypeConstraint())
176 if (HasRequiresClause)
181 return HasRequiresClause || HasConstrainedParameters;
187 return new (
C)
char[
sizeof(
void*) * 2];
199 :
NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl), TemplateParams(Params) {}
201 void TemplateDecl::anchor() {}
207 if (
const Expr *TRC = FD->getTrailingRequiresClause())
215 return FD->getTrailingRequiresClause();
223 void RedeclarableTemplateDecl::anchor() {}
235 Common = Prev->Common;
239 PrevDecls.push_back(Prev);
252 Prev->Common = Common;
265 for (uint32_t I = 0, N = *Specs++; I != N; ++I)
270 template<
class EntryType,
typename... ProfileArguments>
273 llvm::FoldingSetVector<EntryType> &Specs,
void *&InsertPos,
274 ProfileArguments&&... ProfileArgs) {
277 llvm::FoldingSetNodeID
ID;
278 EntryType::Profile(ID, std::forward<ProfileArguments>(ProfileArgs)...,
280 EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
281 return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() :
nullptr;
284 template<
class Derived,
class EntryType>
286 llvm::FoldingSetVector<EntryType> &Specializations, EntryType *Entry,
292 void *CorrectInsertPos;
293 assert(!findSpecializationImpl(Specializations,
295 SETraits::getTemplateArgs(Entry)) &&
296 InsertPos == CorrectInsertPos &&
297 "given incorrect InsertPos for specialization");
299 Specializations.InsertNode(Entry, InsertPos);
301 EntryType *Existing = Specializations.GetOrInsertNode(Entry);
304 "non-canonical specialization?");
308 L->AddedCXXTemplateSpecialization(cast<Derived>(
this),
309 SETraits::getDecl(Entry));
334 auto *CommonPtr =
new (
C)
Common;
340 loadLazySpecializationsImpl();
343 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
345 LoadLazySpecializations();
346 return getCommonPtr()->Specializations;
352 return findSpecializationImpl(getSpecializations(), InsertPos, Args);
357 addSpecializationImpl<FunctionTemplateDecl>(getSpecializations(), Info,
363 Common *CommonPtr = getCommonPtr();
370 std::copy(TemplateArgs.begin(), TemplateArgs.end(),
385 Common *ThisCommon =
static_cast<Common *
>(Base::Common);
386 Common *PrevCommon =
nullptr;
389 if (Prev->Base::Common) {
390 PrevCommon =
static_cast<Common *
>(Prev->Base::Common);
393 PreviousDecls.push_back(Prev);
399 for (
auto *D : PreviousDecls)
400 D->Base::Common = ThisCommon;
406 "Can't merge incompatible declarations!");
408 Base::Common = PrevCommon;
433 loadLazySpecializationsImpl();
436 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
438 LoadLazySpecializations();
439 return getCommonPtr()->Specializations;
442 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
444 LoadLazySpecializations();
445 return getCommonPtr()->PartialSpecializations;
450 auto *CommonPtr =
new (
C)
Common;
458 return findSpecializationImpl(getSpecializations(), InsertPos, Args);
463 addSpecializationImpl<ClassTemplateDecl>(getSpecializations(), D, InsertPos);
470 return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args,
477 ID.AddBoolean(RC !=
nullptr);
480 ID.AddInteger(TPL->
size());
482 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
484 ID.AddBoolean(NTTP->isParameterPack());
485 NTTP->getType().getCanonicalType().Profile(ID);
488 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D)) {
490 ID.AddBoolean(TTP->isParameterPack());
491 ID.AddBoolean(TTP->hasTypeConstraint());
493 TC->getImmediatelyDeclaredConstraint()->Profile(ID, C,
497 const auto *TTP = cast<TemplateTemplateParmDecl>(D);
499 ID.AddBoolean(TTP->isParameterPack());
508 ID.AddInteger(TemplateArgs.size());
510 TemplateArg.Profile(ID, Context);
518 getPartialSpecializations().InsertNode(D, InsertPos);
521 = getPartialSpecializations().GetOrInsertNode(D);
523 assert(Existing->
isCanonicalDecl() &&
"Non-canonical specialization?");
527 L->AddedCXXTemplateSpecialization(
this, D);
532 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &PartialSpecs
533 = getPartialSpecializations();
535 PS.reserve(PartialSpecs.size());
537 PS.push_back(
P.getMostRecentDecl());
544 getPartialSpecializations()) {
545 if (Context.
hasSameType(
P.getInjectedSpecializationType(), T))
546 return P.getMostRecentDecl();
557 if (
P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
558 return P.getMostRecentDecl();
566 Common *CommonPtr = getCommonPtr();
595 bool Typename,
bool ParameterPack,
596 bool HasTypeConstraint,
600 additionalSizeToAlloc<TypeConstraint>(HasTypeConstraint ? 1 : 0))
602 HasTypeConstraint, NumExpanded);
604 TTPDecl->setTypeForDecl(TTPType.
getTypePtr());
617 bool HasTypeConstraint) {
619 additionalSizeToAlloc<TypeConstraint>(HasTypeConstraint ? 1 : 0))
621 nullptr,
false, HasTypeConstraint,
None);
625 return hasDefaultArgument()
626 ? getDefaultArgumentInfo()->getTypeLoc().getBeginLoc()
631 if (hasDefaultArgument() && !defaultArgumentWasInherited())
633 getDefaultArgumentInfo()->getTypeLoc().
getEndLoc());
657 Expr *ImmediatelyDeclaredConstraint) {
658 assert(HasTypeConstraint &&
659 "HasTypeConstraint=true must be passed at construction in order to " 660 "call setTypeConstraint");
661 assert(!TypeConstraintInitialized &&
662 "TypeConstraint was already initialized!");
663 new (getTrailingObjects<TypeConstraint>())
TypeConstraint(NNS, NameInfo,
664 FoundDecl, CD, ArgsAsWritten, ImmediatelyDeclaredConstraint);
665 TypeConstraintInitialized =
true;
672 NonTypeTemplateParmDecl::NonTypeTemplateParmDecl(
676 :
DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
678 ExpandedParameterPack(
true), NumExpandedTypes(ExpandedTypes.size()) {
679 if (!ExpandedTypes.empty() && !ExpandedTInfos.empty()) {
681 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
682 for (
unsigned I = 0; I != NumExpandedTypes; ++I) {
683 new (&TypesAndInfos[I].first)
QualType(ExpandedTypes[I]);
684 TypesAndInfos[I].second = ExpandedTInfos[I];
698 additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
712 additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
716 ExpandedTypes, ExpandedTInfos);
721 bool HasTypeConstraint) {
722 return new (
C,
ID, additionalSizeToAlloc<std::pair<
QualType,
725 HasTypeConstraint ? 1 : 0))
727 0, 0,
nullptr, QualType(),
false,
nullptr);
732 unsigned NumExpandedTypes,
733 bool HasTypeConstraint) {
735 new (
C,
ID, additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
737 NumExpandedTypes, HasTypeConstraint ? 1 : 0))
741 NTTP->NumExpandedTypes = NumExpandedTypes;
746 if (hasDefaultArgument() && !defaultArgumentWasInherited())
753 return hasDefaultArgument()
754 ? getDefaultArgument()->getSourceRange().getBegin()
762 void TemplateTemplateParmDecl::anchor() {}
764 TemplateTemplateParmDecl::TemplateTemplateParmDecl(
768 :
TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
770 ExpandedParameterPack(
true), NumExpandedParams(Expansions.size()) {
771 if (!Expansions.empty())
772 std::uninitialized_copy(Expansions.begin(), Expansions.end(),
773 getTrailingObjects<TemplateParameterList *>());
792 additionalSizeToAlloc<TemplateParameterList *>(Expansions.size()))
799 false,
nullptr,
nullptr);
804 unsigned NumExpansions) {
806 new (
C,
ID, additionalSizeToAlloc<TemplateParameterList *>(NumExpansions))
809 TTP->NumExpandedParams = NumExpansions;
814 return hasDefaultArgument() ? getDefaultArgument().getLocation()
821 DefaultArgument.set(
nullptr);
830 : Arguments(getTrailingObjects<TemplateArgument>()),
831 NumArguments(Args.size()) {
832 std::uninitialized_copy(Args.begin(), Args.end(),
833 getTrailingObjects<TemplateArgument>());
839 void *Mem = Context.
Allocate(totalSizeToAlloc<TemplateArgument>(Args.size()));
849 if (TemplateArgsAsWritten)
851 *TemplateArgsAsWritten);
854 C.
Allocate(totalSizeToAlloc<MemberSpecializationInfo *>(MSInfo ? 1 : 0));
856 FD, Template, TSK, TemplateArgs, ArgsAsWritten, POI, MSInfo);
872 SpecializedTemplate(SpecializedTemplate),
893 Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
894 SpecializedTemplate, Args, PrevDecl);
895 Result->setMayHaveOutOfDateDef(
false);
906 Result->setMayHaveOutOfDateDef(
false);
911 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
916 PS ? PS->getTemplateArgsAsWritten() :
nullptr) {
926 if (
const auto *PartialSpec =
927 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
928 return PartialSpec->PartialSpecialization->getSpecializedTemplate();
952 auto *ctpsd =
const_cast<CTPSDecl *
>(cast<CTPSDecl>(
this));
954 assert(inst_from !=
nullptr);
955 return inst_from->getSourceRange();
962 if (inst_from.isNull())
964 if (
const auto *ctd = inst_from.dyn_cast<ClassTemplateDecl *>())
965 return ctd->getSourceRange();
977 Expr *ConstraintExpr) {
979 return new (
C, DC)
ConceptDecl(DC, L, Name, Params, ConstraintExpr);
994 void ClassTemplatePartialSpecializationDecl::anchor() {}
996 ClassTemplatePartialSpecializationDecl::
1007 ClassTemplatePartialSpecialization,
1008 TK, DC, StartLoc, IdLoc,
1009 SpecializedTemplate, Args, PrevDecl),
1010 TemplateParams(Params), ArgsAsWritten(ArgInfos),
1011 InstantiatedFromMember(
nullptr,
false) {
1028 auto *
Result =
new (Context, DC)
1030 Params, SpecializedTemplate, Args,
1031 ASTArgInfos, PrevDecl);
1033 Result->setMayHaveOutOfDateDef(
false);
1043 Result->setMayHaveOutOfDateDef(
false);
1051 void FriendTemplateDecl::anchor() {}
1088 auto *CommonPtr =
new (
C)
Common;
1097 void ClassScopeFunctionSpecializationDecl::anchor() {}
1135 loadLazySpecializationsImpl();
1138 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
1140 LoadLazySpecializations();
1141 return getCommonPtr()->Specializations;
1144 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
1146 LoadLazySpecializations();
1147 return getCommonPtr()->PartialSpecializations;
1152 auto *CommonPtr =
new (
C)
Common;
1160 return findSpecializationImpl(getSpecializations(), InsertPos, Args);
1165 addSpecializationImpl<VarTemplateDecl>(getSpecializations(), D, InsertPos);
1171 return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args,
1179 ID.AddInteger(TemplateArgs.size());
1181 TemplateArg.Profile(ID, Context);
1188 getPartialSpecializations().InsertNode(D, InsertPos);
1191 getPartialSpecializations().GetOrInsertNode(D);
1193 assert(Existing->
isCanonicalDecl() &&
"Non-canonical specialization?");
1197 L->AddedCXXTemplateSpecialization(
this, D);
1202 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &PartialSpecs =
1203 getPartialSpecializations();
1205 PS.reserve(PartialSpecs.size());
1207 PS.push_back(
P.getMostRecentDecl());
1215 if (
P.getInstantiatedFromMember()->getCanonicalDecl() == DCanon)
1216 return P.getMostRecentDecl();
1230 :
VarDecl(DK, Context, DC, StartLoc, IdLoc,
1232 SpecializedTemplate(SpecializedTemplate),
1247 VarTemplateSpecialization, Context, DC, StartLoc, IdLoc,
1248 SpecializedTemplate, T, TInfo, S, Args);
1258 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
1263 PS ? PS->getTemplateArgsAsWritten() :
nullptr) {
1272 if (
const auto *PartialSpec =
1273 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1274 return PartialSpec->PartialSpecialization->getSpecializedTemplate();
1290 void VarTemplatePartialSpecializationDecl::anchor() {}
1292 VarTemplatePartialSpecializationDecl::VarTemplatePartialSpecializationDecl(
1299 DC, StartLoc, IdLoc, SpecializedTemplate, T,
1301 TemplateParams(Params), ArgsAsWritten(ArgInfos),
1302 InstantiatedFromMember(
nullptr,
false) {
1319 Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
1320 S, Args, ASTArgInfos);
1336 nullptr,
true,
false,
1338 T->setImplicit(
true);
1345 nullptr, TI->
getType(),
true, TI);
1356 false,
nullptr, TPL);
1357 TemplateTemplateParm->setImplicit(
true);
1362 nullptr,
true,
false,
1364 TemplateTypeParm->setImplicit(
true);
1368 QualType(TemplateTypeParm->getTypeForDecl(), 0));
1371 nullptr, TInfo->
getType(),
false, TInfo);
1372 NamedDecl *Params[] = {TemplateTemplateParm, TemplateTypeParm,
1373 NonTypeTemplateParm};
1386 nullptr, TInfo->
getType(),
false, TInfo);
1391 nullptr,
true,
true,
1393 Ts->setImplicit(
true);
1398 llvm::makeArrayRef(Params),
1411 llvm_unreachable(
"unhandled BuiltinTemplateKind!");
1414 void BuiltinTemplateDecl::anchor() {}
1425 NestedNameSpec.getNestedNameSpecifier()->print(OS, Policy);
1426 ConceptName.printName(OS, Policy);
1427 if (hasExplicitTemplateArgs()) {
1429 for (
auto &ArgLoc : ArgsAsWritten->arguments())
1430 ArgLoc.getArgument().print(Policy, OS);
Defines the clang::ASTContext interface.
void setImplicit(bool I=true)
Represents a function declaration or definition.
A (possibly-)qualified type.
virtual Decl * GetExternalDecl(uint32_t ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
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...
SourceRange getBraceRange() const
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...
C Language Family Type Representation.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, Optional< unsigned > NumExpanded=None)
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
Decl - This represents one declaration (or definition), e.g.
SourceLocation getBeginLoc() const LLVM_READONLY
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
ArrayRef< NamedDecl * > asArray()
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.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Declaration of a variable template.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
SourceLocation getEndLoc() const LLVM_READONLY
NamedDecl * getParam(unsigned Idx)
A container of type source information.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
SourceLocation getEndLoc() const
Get the end source location.
void setRAngleLoc(SourceLocation Loc)
Represents a variable declaration or definition.
ASTMutationListener * getASTMutationListener() const
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Declaration of a redeclarable template.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
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. ...
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
bool isParameterPack() const
Whether this declaration is a parameter pack.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
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...
unsigned getDepth() const
Retrieve the depth of the template parameter.
VarTemplateSpecializationDecl(Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Defines the position of a template parameter within a template parameter list.
void * allocateDefaultArgStorageChain(const ASTContext &C)
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
Declaration of a function specialization at template class scope.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
A convenient class for passing around template argument information.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
static TemplateParameterList * createTypePackElementParameterList(const ASTContext &C, DeclContext *DC)
bool isConstrained() const
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
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.
Represents a ValueDecl that came out of a declarator.
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.
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
bool hasAssociatedConstraints() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
This represents one expression.
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
Declaration of a template type parameter.
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
SpecEntryTraits< EntryType >::DeclType * findSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, void *&InsertPos, ProfileArguments &&...ProfileArgs)
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...
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
Represents a C++ template name within the type system.
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
Defines the clang::TypeLoc interface and its subclasses.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
StorageClass
Storage classes.
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
Declaration of an alias template.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
SourceLocation getEnd() const
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool HasTypeConstraint)
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
static TemplateParameterList * createBuiltinTemplateParameterList(const ASTContext &C, DeclContext *DC, BuiltinTemplateKind BTK)
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
bool hasAssociatedConstraints() const
Data that is common to all of the declarations of a given class template.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
void print(llvm::raw_ostream &OS, PrintingPolicy Policy) const
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
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 only by ...
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
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.
bool isParameterPack() const
Returns whether this is a parameter pack.
Encodes a location in the source.
static void ProfileTemplateParameterList(ASTContext &C, llvm::FoldingSetNodeID &ID, const TemplateParameterList *TPL)
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
This names the __make_integer_seq BuiltinTemplateDecl.
ASTContext & getASTContext() const LLVM_READONLY
CommonBase * newCommon(ASTContext &C) const override
void Profile(llvm::FoldingSetNodeID &ID) const
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
void Profile(llvm::FoldingSetNodeID &ID) const
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...
static ConceptDecl * CreateDeserialized(ASTContext &C, unsigned ID)
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
TemplateParameterList(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList *> Params, FriendUnion Friend, SourceLocation FriendLoc)
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.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
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)
void addArgument(const TemplateArgumentLoc &Loc)
void * Allocate(size_t Size, unsigned Align=8) const
Represents a template argument.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
TagTypeKind
The kind of a tag type.
Dataflow Directional Tag Classes.
void getInjectedTemplateArgs(const TemplateParameterList *Params, SmallVectorImpl< TemplateArgument > &Args)
Get a template argument list with one argument per template parameter in a template parameter list...
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
bool isValid() const
Return true if this is a valid SourceLocation object.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
All associated constraints derived from this template parameter list, including the requires clause a...
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
const TemplateArgument & getArgument() const
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.).
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
This template specialization was instantiated from a template due to an explicit instantiation declar...
unsigned getIndex() const
Retrieve the index of the template parameter.
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
The name of a declaration.
TemplateParameterList * TemplateParams
This names the __type_pack_element BuiltinTemplateDecl.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
bool isNull() const
Determine whether this template argument has no value.
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
Appends a human-readable name for this declaration into the given stream.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
Location wrapper for a TemplateArgument.
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or nullptr if no such declaration exists...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
A template argument list.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
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).
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...
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
Get the total constraint-expression associated with this template, including constraint-expressions d...
CommonBase * newCommon(ASTContext &C) const override
void addSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, EntryType *Entry, void *InsertPos)
CommonBase * newCommon(ASTContext &C) const override
Provides information a specialization of a member of a class template, which may be a member function...
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
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.
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
void loadLazySpecializationsImpl() const
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.
SourceLocation getLAngleLoc() const
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
NamedDecl * getMostRecentDecl()
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
This represents a decl that may have a name.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Declaration of a friend template.
SourceLocation getRAngleLoc() const
VarTemplateDecl * getDefinition()
const LangOptions & getLangOpts() const
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
QualType getType() const
Return the type wrapped by this type source info.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.