Go to the documentation of this file.
14 #ifndef LLVM_CLANG_AST_DECLTEMPLATE_H
15 #define LLVM_CLANG_AST_DECLTEMPLATE_H
29 #include "llvm/ADT/ArrayRef.h"
30 #include "llvm/ADT/FoldingSet.h"
31 #include "llvm/ADT/PointerIntPair.h"
32 #include "llvm/ADT/PointerUnion.h"
33 #include "llvm/ADT/iterator.h"
34 #include "llvm/ADT/iterator_range.h"
35 #include "llvm/Support/Casting.h"
36 #include "llvm/Support/Compiler.h"
37 #include "llvm/Support/TrailingObjects.h"
48 class ClassTemplateDecl;
49 class ClassTemplatePartialSpecializationDecl;
51 class FunctionTemplateDecl;
53 class NonTypeTemplateParmDecl;
55 class TemplateTemplateParmDecl;
56 class TemplateTypeParmDecl;
58 class UnresolvedSetImpl;
59 class VarTemplateDecl;
60 class VarTemplatePartialSpecializationDecl;
64 llvm::PointerUnion<TemplateTypeParmDecl *, NonTypeTemplateParmDecl *,
72 :
private llvm::TrailingObjects<TemplateParameterList, NamedDecl *,
82 unsigned NumParams : 29;
86 unsigned ContainsUnexpandedParameterPack : 1;
89 unsigned HasRequiresClause : 1;
93 unsigned HasConstrainedParameters : 1;
105 return HasRequiresClause ? 1 : 0;
109 template <
size_t N,
bool HasRequiresClause>
118 Expr *RequiresClause);
131 unsigned size()
const {
return NumParams; }
139 assert(Idx <
size() &&
"Template parameter index out-of-range");
143 assert(Idx <
size() &&
"Template parameter index out-of-range");
168 if (
P->isParameterPack())
175 return HasRequiresClause ? getTrailingObjects<Expr *>()[0] :
nullptr;
180 return HasRequiresClause ? getTrailingObjects<Expr *>()[0] :
nullptr;
202 bool OmitTemplateKW =
false)
const;
214 template <
size_t N,
bool HasRequiresClause>
216 :
public TemplateParameterList::FixedSizeStorageOwner {
217 typename TemplateParameterList::FixedSizeStorage<
219 N, HasRequiresClause ? 1u : 0u
228 Expr *RequiresClause)
229 : FixedSizeStorageOwner(
230 (assert(N == Params.size()),
231 assert(HasRequiresClause == (RequiresClause != nullptr)),
233 TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
238 :
private llvm::TrailingObjects<TemplateArgumentList, TemplateArgument> {
244 unsigned NumArguments;
270 : Arguments(Args.
data()), NumArguments(Args.
size()) {}
278 : Arguments(Other->
data()), NumArguments(Other->
size()) {}
282 assert(Idx < NumArguments &&
"Invalid template argument index");
296 unsigned size()
const {
return NumArguments; }
312 template<
typename ParmDecl,
typename ArgType>
318 ParmDecl *PrevDeclWithDefaultArg;
321 static_assert(
sizeof(Chain) ==
sizeof(
void *) * 2,
322 "non-pointer argument type?");
324 llvm::PointerUnion<ArgType, ParmDecl*, Chain*> ValueOrInherited;
326 static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
328 if (
auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
330 assert(!Parm->getDefaultArgStorage()
331 .ValueOrInherited.template is<ParmDecl *>() &&
332 "should only be one level of indirection");
340 bool isSet()
const {
return !ValueOrInherited.isNull(); }
344 bool isInherited()
const {
return ValueOrInherited.template is<ParmDecl*>(); }
350 if (
const auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl *>())
351 Storage = &Prev->getDefaultArgStorage();
352 if (
const auto *C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
354 return Storage->ValueOrInherited.template get<ArgType>();
360 if (
const auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>())
362 if (
const auto *C = ValueOrInherited.template dyn_cast<Chain *>())
363 return C->PrevDeclWithDefaultArg;
369 assert(!
isSet() &&
"default argument already set");
370 ValueOrInherited = Arg;
375 InheritedFrom = getParmOwningDefaultArg(InheritedFrom);
377 ValueOrInherited = InheritedFrom;
378 else if (
auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>()) {
379 assert(C.isSameDefaultTemplateArgument(D, InheritedFrom));
382 }
else if (
auto *Inherited =
383 ValueOrInherited.template dyn_cast<Chain *>()) {
384 assert(C.isSameDefaultTemplateArgument(Inherited->PrevDeclWithDefaultArg,
386 Inherited->PrevDeclWithDefaultArg = InheritedFrom;
389 Chain{InheritedFrom, ValueOrInherited.template get<ArgType>()};
394 ValueOrInherited = ArgType();
408 void anchor()
override;
448 return K >= firstTemplate && K <= lastTemplate;
468 assert(
TemplatedDecl == NewTemplatedDecl &&
"Inconsistent TemplatedDecl");
478 :
public llvm::FoldingSetNode,
479 private llvm::TrailingObjects<FunctionTemplateSpecializationInfo,
480 MemberSpecializationInfo *> {
483 llvm::PointerIntPair<FunctionDecl *, 1, bool> Function;
489 llvm::PointerIntPair<FunctionTemplateDecl *, 2> Template;
510 : Function(FD, MSInfo ?
true :
false), Template(Template, TSK - 1),
515 getTrailingObjects<MemberSpecializationInfo *>()[0] = MSInfo;
518 size_t numTrailingObjects(OverloadToken<MemberSpecializationInfo*>)
const {
519 return Function.getInt();
558 "Cannot encode TSK_Undeclared for a function template specialization");
559 Template.setInt(TSK - 1);
608 return numTrailingObjects(OverloadToken<MemberSpecializationInfo *>())
609 ? getTrailingObjects<MemberSpecializationInfo *>()[0]
620 ID.AddInteger(TemplateArgs.size());
632 llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
641 : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
643 "Cannot encode undeclared template specializations for members");
662 "Cannot encode undeclared template specializations for members");
663 MemberAndTSK.setInt(TSK - 1);
670 return PointOfInstantiation;
675 PointOfInstantiation = POI;
694 :
private llvm::TrailingObjects<DependentFunctionTemplateSpecializationInfo,
696 FunctionTemplateDecl *> {
698 unsigned NumTemplates;
706 size_t numTrailingObjects(OverloadToken<TemplateArgumentLoc>)
const {
709 size_t numTrailingObjects(OverloadToken<FunctionTemplateDecl *>)
const {
731 return getTrailingObjects<FunctionTemplateDecl *>()[I];
736 return getTrailingObjects<TemplateArgumentLoc>();
757 return AngleLocs.
getEnd();
779 void anchor()
override;
789 return D->getTemplateArgs().asArray();
793 template <
typename EntryType,
typename SETraits = SpecEntryTraits<EntryType>,
794 typename DeclType =
typename SETraits::DeclType>
796 : llvm::iterator_adaptor_base<
797 SpecIterator<EntryType, SETraits, DeclType>,
798 typename llvm::FoldingSetVector<EntryType>::iterator,
799 typename std::iterator_traits<typename llvm::FoldingSetVector<
800 EntryType>::iterator>::iterator_category,
801 DeclType *, ptrdiff_t, DeclType *, DeclType *> {
804 typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
808 return SETraits::getDecl(&*this->I)->getMostRecentDecl();
814 template <
typename EntryType>
815 static SpecIterator<EntryType>
822 template <
class EntryType,
typename ...ProfileArguments>
825 void *&InsertPos, ProfileArguments &&...ProfileArgs);
827 template <
class Derived,
class EntryType>
829 EntryType *Entry,
void *InsertPos);
839 llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
914 assert(
getCommonPtr()->InstantiatedFromMember.getPointer() &&
915 "Only member templates can be member template specializations");
960 assert(!
getCommonPtr()->InstantiatedFromMember.getPointer());
986 return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate;
1033 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
1067 return cast<FunctionTemplateDecl>(
1071 return cast<FunctionTemplateDecl>(
1078 return cast_or_null<FunctionTemplateDecl>(
1082 return cast_or_null<FunctionTemplateDecl>(
1087 return cast<FunctionTemplateDecl>(
1096 return cast_or_null<FunctionTemplateDecl>(
1170 "The depth of template parmeter position is more than 2^20!");
1172 "The position of template parmeter position is more than 2^12!");
1182 "The depth of template parmeter position is more than 2^20!");
1190 "The position of template parmeter position is more than 2^12!");
1205 private llvm::TrailingObjects<TemplateTypeParmDecl, TypeConstraint> {
1208 friend TrailingObjects;
1218 bool HasTypeConstraint : 1;
1223 bool TypeConstraintInitialized : 1;
1228 bool ExpandedParameterPack : 1;
1231 unsigned NumExpanded = 0;
1240 bool HasTypeConstraint,
1241 std::optional<unsigned> NumExpanded)
1242 :
TypeDecl(TemplateTypeParm, DC, IdLoc,
Id, KeyLoc), Typename(Typename),
1243 HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(
false),
1244 ExpandedParameterPack(NumExpanded),
1245 NumExpanded(NumExpanded.value_or(0)) {}
1251 bool Typename,
bool ParameterPack,
bool HasTypeConstraint =
false,
1252 std::optional<unsigned> NumExpanded = std::nullopt);
1257 bool HasTypeConstraint);
1265 return Typename && !HasTypeConstraint;
1281 return DefaultArgument.
get();
1295 DefaultArgument.
set(DefArg);
1307 DefaultArgument.
clear();
1331 if (TC->hasExplicitTemplateArgs())
1332 for (
const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
1333 if (ArgLoc.getArgument().containsUnexpandedParameterPack())
1363 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1370 return TypeConstraintInitialized ? getTrailingObjects<TypeConstraint>() :
1378 Expr *ImmediatelyDeclaredConstraint);
1382 return HasTypeConstraint;
1391 if (HasTypeConstraint)
1410 private llvm::TrailingObjects<NonTypeTemplateParmDecl,
1411 std::pair<QualType, TypeSourceInfo *>,
1414 friend TrailingObjects;
1430 bool ExpandedParameterPack =
false;
1433 unsigned NumExpandedTypes = 0;
1435 size_t numTrailingObjects(
1436 OverloadToken<std::pair<QualType, TypeSourceInfo *>>)
const {
1437 return NumExpandedTypes;
1447 NonTypeTemplateParmDecl(
DeclContext *DC, SourceLocation StartLoc,
1448 SourceLocation IdLoc,
unsigned D,
unsigned P,
1449 IdentifierInfo *
Id, QualType T,
1450 TypeSourceInfo *TInfo,
1451 ArrayRef<QualType> ExpandedTypes,
1452 ArrayRef<TypeSourceInfo *> ExpandedTInfos);
1455 static NonTypeTemplateParmDecl *
1457 SourceLocation IdLoc,
unsigned D,
unsigned P, IdentifierInfo *
Id,
1458 QualType T,
bool ParameterPack, TypeSourceInfo *TInfo);
1460 static NonTypeTemplateParmDecl *
1462 SourceLocation IdLoc,
unsigned D,
unsigned P, IdentifierInfo *
Id,
1463 QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
1464 ArrayRef<TypeSourceInfo *> ExpandedTInfos);
1468 bool HasTypeConstraint);
1471 unsigned NumExpandedTypes,
1472 bool HasTypeConstraint);
1561 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1562 return NumExpandedTypes;
1568 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1569 auto TypesAndInfos =
1570 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1571 return TypesAndInfos[I].first;
1577 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1578 auto TypesAndInfos =
1579 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1580 return TypesAndInfos[I].second;
1591 *getTrailingObjects<Expr *>() = E;
1627 private llvm::TrailingObjects<TemplateTemplateParmDecl,
1628 TemplateParameterList *> {
1640 bool ExpandedParameterPack =
false;
1643 unsigned NumExpandedParams = 0;
1646 unsigned D,
unsigned P,
bool ParameterPack,
1652 unsigned D,
unsigned P,
1656 void anchor()
override;
1665 unsigned P,
bool ParameterPack,
1679 unsigned NumExpansions);
1700 return ParameterPack &&
1727 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1728 return NumExpandedParams;
1734 assert(I < NumExpandedParams &&
"Out-of-range expansion type index");
1735 return getTrailingObjects<TemplateParameterList *>()[I];
1747 return DefaultArgument.
isSet() ? *DefaultArgument.
get() : NoneLoc;
1793 void anchor()
override;
1831 struct SpecializedPartialSpecialization {
1842 llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1843 SpecializedTemplate;
1846 struct ExplicitSpecializationInfo {
1856 ExplicitSpecializationInfo() =
default;
1861 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
1871 unsigned SpecializationKind : 3;
1905 return cast<ClassTemplateSpecializationDecl>(
1915 return *TemplateArgs;
1919 TemplateArgs = Args;
1955 SpecializedTemplate = Specialized;
1959 SpecializationKind = TSK;
1964 return PointOfInstantiation;
1968 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
1969 PointOfInstantiation = Loc;
1991 if (
const auto *PartialSpec =
1992 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1993 return PartialSpec->PartialSpecialization;
2010 if (
const auto *PartialSpec =
2011 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2012 return *PartialSpec->TemplateArgs;
2022 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
2023 "Already set to a class template partial specialization!");
2024 auto *PS =
new (
getASTContext()) SpecializedPartialSpecialization();
2025 PS->PartialSpecialization = PartialSpec;
2026 PS->TemplateArgs = TemplateArgs;
2027 SpecializedTemplate = PS;
2033 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
2034 "Previously set to a class template partial specialization!");
2035 SpecializedTemplate = TemplDecl;
2042 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2043 ExplicitInfo->TypeAsWritten = T;
2049 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2054 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2060 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2061 ExplicitInfo->ExternLoc = Loc;
2067 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2068 ExplicitInfo->TemplateKeywordLoc = Loc;
2073 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2085 ID.AddInteger(TemplateArgs.size());
2093 return K >= firstClassTemplateSpecialization &&
2094 K <= lastClassTemplateSpecialization;
2112 llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
2113 InstantiatedFromMember;
2127 InstantiatedFromMember(
nullptr,
false) {}
2129 void anchor()
override;
2149 return cast<ClassTemplatePartialSpecializationDecl>(
2156 return TemplateParams;
2175 return ArgsAsWritten;
2200 cast<ClassTemplatePartialSpecializationDecl>(
getFirstDecl());
2201 return First->InstantiatedFromMember.getPointer();
2211 First->InstantiatedFromMember.setPointer(PartialSpec);
2232 cast<ClassTemplatePartialSpecializationDecl>(
getFirstDecl());
2233 return First->InstantiatedFromMember.getInt();
2239 assert(
First->InstantiatedFromMember.getPointer() &&
2240 "Only member templates can be member template specializations");
2241 return First->InstantiatedFromMember.setInt(
true);
2248 assert(
getTypeForDecl() &&
"partial specialization has no type set!");
2250 ->getInjectedSpecializationType();
2265 return K == ClassTemplatePartialSpecialization;
2281 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>
2291 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
2296 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
2348 return cast<ClassTemplateDecl>(
2352 return cast<ClassTemplateDecl>(
2359 return cast_or_null<ClassTemplateDecl>(
2363 return cast_or_null<ClassTemplateDecl>(
2369 return cast<ClassTemplateDecl>(
2377 return cast_or_null<ClassTemplateDecl>(
2468 virtual void anchor();
2475 unsigned NumParams = 0;
2489 :
Decl(
Decl::FriendTemplate, DC, Loc), NumParams(NumParams),
2490 Params(Params), Friend(Friend), FriendLoc(FriendLoc) {}
2524 assert(i <= NumParams);
2570 return cast<TypeAliasTemplateDecl>(
2574 return cast<TypeAliasTemplateDecl>(
2581 return cast_or_null<TypeAliasTemplateDecl>(
2585 return cast_or_null<TypeAliasTemplateDecl>(
2591 return cast_or_null<TypeAliasTemplateDecl>(
2634 :
Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc),
2638 :
Decl(Decl::ClassScopeFunctionSpecialization, Empty) {}
2640 virtual void anchor();
2649 return TemplateArgs;
2654 bool HasExplicitTemplateArgs,
2658 HasExplicitTemplateArgs
2670 return K == Decl::ClassScopeFunctionSpecialization;
2688 public llvm::FoldingSetNode {
2693 struct SpecializedPartialSpecialization {
2704 llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2705 SpecializedTemplate;
2708 struct ExplicitSpecializationInfo {
2718 ExplicitSpecializationInfo() =
default;
2723 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
2734 unsigned SpecializationKind : 3;
2740 unsigned IsCompleteDefinition : 1;
2770 return cast<VarTemplateSpecializationDecl>(Recent);
2785 return TemplateArgsInfo;
2812 SpecializationKind = TSK;
2817 return PointOfInstantiation;
2821 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
2822 PointOfInstantiation = Loc;
2831 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2842 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2844 if (
const auto *PartialSpec =
2845 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2846 return PartialSpec->PartialSpecialization;
2863 if (
const auto *PartialSpec =
2864 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2865 return *PartialSpec->TemplateArgs;
2875 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2876 "Already set to a variable template partial specialization!");
2877 auto *PS =
new (
getASTContext()) SpecializedPartialSpecialization();
2878 PS->PartialSpecialization = PartialSpec;
2879 PS->TemplateArgs = TemplateArgs;
2880 SpecializedTemplate = PS;
2886 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2887 "Previously set to a variable template partial specialization!");
2888 SpecializedTemplate = TemplDecl;
2895 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2896 ExplicitInfo->TypeAsWritten = T;
2902 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2907 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2913 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2914 ExplicitInfo->ExternLoc = Loc;
2920 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2921 ExplicitInfo->TemplateKeywordLoc = Loc;
2926 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2944 ID.AddInteger(TemplateArgs.size());
2952 return K >= firstVarTemplateSpecialization &&
2953 K <= lastVarTemplateSpecialization;
2971 llvm::PointerIntPair<VarTemplatePartialSpecializationDecl *, 1, bool>
2972 InstantiatedFromMember;
2984 InstantiatedFromMember(
nullptr,
false) {}
2986 void anchor()
override;
3003 return cast<VarTemplatePartialSpecializationDecl>(
3010 return TemplateParams;
3015 return ArgsAsWritten;
3054 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
3055 return First->InstantiatedFromMember.getPointer();
3061 First->InstantiatedFromMember.setPointer(PartialSpec);
3082 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
3083 return First->InstantiatedFromMember.getInt();
3089 assert(
First->InstantiatedFromMember.getPointer() &&
3090 "Only member templates can be member template specializations");
3091 return First->InstantiatedFromMember.setInt(
true);
3114 return K == VarTemplatePartialSpecialization;
3130 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>
3137 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
3142 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
3204 return cast_or_null<VarTemplateDecl>(
3208 return cast_or_null<VarTemplateDecl>(
3214 return cast<VarTemplateDecl>(
3222 return cast_or_null<VarTemplateDecl>(
3324 private llvm::TrailingObjects<ImplicitConceptSpecializationDecl,
3326 unsigned NumTemplateArgs;
3338 unsigned NumTemplateArgs);
3366 public Mergeable<TemplateParamObjectDecl>,
3367 public llvm::FoldingSetNode {
3433 auto *TD = dyn_cast<TemplateDecl>(D);
3434 return TD && (isa<ClassTemplateDecl>(TD) ||
3435 isa<ClassTemplatePartialSpecializationDecl>(TD) ||
3436 isa<TypeAliasTemplateDecl>(TD) ||
3437 isa<TemplateTemplateParmDecl>(TD))
3454 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
3455 if (TTP->isExpandedParameterPack())
3456 return TTP->getNumExpansionParameters();
3459 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3460 if (NTTP->isExpandedParameterPack())
3461 return NTTP->getNumExpansionTypes();
3464 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3465 if (TTP->isExpandedParameterPack())
3466 return TTP->getNumExpansionTemplateParameters();
3469 return std::nullopt;
3478 #endif // LLVM_CLANG_AST_DECLTEMPLATE_H
static DependentFunctionTemplateSpecializationInfo * Create(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isTemplateExplicitInstantiationOrSpecialization(TemplateSpecializationKind Kind)
True if this template specialization kind is an explicit specialization, explicit instantiation decla...
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
void * allocateDefaultArgStorageChain(const ASTContext &C)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
llvm::iterator_range< spec_iterator > spec_range
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Expr * getConstraintExpr() const
ClassTemplatePartialSpecializationDecl * getMostRecentDecl()
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
ASTContext & getASTContext() const LLVM_READONLY
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ArgType get() const
Get the default argument's value.
static bool classofKind(Kind K)
YAML serialization mapping.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const VarTemplateDecl * getMostRecentDecl() const
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
Declaration of a friend template.
virtual CommonBase * newCommon(ASTContext &C) const =0
TemplateArgumentList(OnStackType, ArrayRef< TemplateArgument > Args)
Construct a new, temporary template argument list on the stack.
const DefArgStorage & getDefaultArgStorage() const
TemplateParmPosition()=delete
QualType getType() const
Return the type wrapped by this type source info.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Provides information about a dependent function-template specialization declaration.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
unsigned getIndex() const
Retrieve the index of the template parameter.
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Provides information a specialization of a member of a class template, which may be a member function...
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)
A set of unresolved declarations.
TypeAliasTemplateDecl * getInstantiatedFromMemberTemplate() const
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
bool isConstrained() const
A trivial tuple used to represent a source range.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool hasPlaceholderTypeConstraint() const
Determine whether this non-type template parameter's type has a placeholder with a type-constraint.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this variable template specialization is an instantiation of a template (rather than an explicit s...
QualType getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Provides common interface for the Decls that can be redeclared.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
spec_iterator spec_begin() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
ClassTemplateSpecializationDecl * getMostRecentDecl()
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
static bool classofKind(Kind K)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static SpecIterator< EntryType > makeSpecIterator(llvm::FoldingSetVector< EntryType > &Specs, bool isEnd)
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or nullptr if no such declaration exists...
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
redecl_iterator redecls_begin() const
bool hasAssociatedConstraints() const
VarTemplateSpecializationDecl * getMostRecentDecl()
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Encodes a location in the source.
TemplateParmPosition(unsigned D, unsigned P)
static bool classof(const Decl *D)
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
size_t numTrailingObjects(OverloadToken< NamedDecl * >) const
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
const NamedDecl * getParam(unsigned Idx) const
This represents a decl that may have a name.
SourceLocation getBegin() const
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
static DeclType * getDecl(FunctionTemplateSpecializationInfo *I)
spec_iterator spec_end() const
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
TemplateArgumentList(const TemplateArgumentList *Other)
Produces a shallow copy of the given template argument list.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
const Expr * getRequiresClause() const
The constraint-expression of the associated requires-clause.
QualType InjectedClassNameType
The injected-class-name type for this class template.
void setSpecializationKind(TemplateSpecializationKind TSK)
A (possibly-)qualified type.
const Type * getTypeForDecl() const
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the total constraint-expression associated with this template, including constraint-expressions d...
bool isSet() const
Determine whether there is a default argument for this parameter.
spec_iterator spec_end() const
redecl_iterator redecls_end() const
bool hasExplicitTemplateArgs() const
const DefArgStorage & getDefaultArgStorage() const
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
Declaration of a function specialization at template class scope.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
QualType getCanonicalType() const
const_iterator end() const
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
llvm::iterator_range< redecl_iterator > redecl_range
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Common * getCommonPtr() const
RedeclarableTemplateDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
SourceLocation getLAngleLoc() const
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
DeclType * operator*() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
FixedSizeTemplateParameterListStorage(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
ArrayRef< TemplateArgument > getTemplateArguments() const
ArrayRef< const NamedDecl * > asArray() const
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
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, std::optional< unsigned > NumExpanded=std::nullopt)
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setMemberSpecialization()
Note that this member template is a specialization.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMemberTemplate() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
void clear()
Remove the default argument, even if it was inherited.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
void setTemplateArgs(TemplateArgumentList *Args)
Describes how types, statements, expressions, and declarations should be printed.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Declaration of a redeclarable template.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
static bool classof(const Decl *D)
Represents a variable template specialization, which refers to a variable template with a given set o...
void setPointOfInstantiation(SourceLocation Loc)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
const TemplateArgumentLoc * getTemplateArgs() const
Returns the explicit template arguments that were given.
std::conditional_t< Const, const T, T > Qualified
void setDepth(unsigned D)
static bool classofKind(Kind K)
The name of a declaration.
NamedDecl * TemplatedDecl
Data that is common to all of the declarations of a given class template.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
const VarTemplateDecl * getCanonicalDecl() const
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
void printAsInit(llvm::raw_ostream &OS) const
Print this object as an initializer suitable for a variable of the object's type.
static bool classofKind(Kind K)
llvm::iterator_range< spec_iterator > spec_range
static bool classof(const Decl *D)
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
ConceptDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
llvm::iterator_range< redecl_iterator > redecl_range
static bool classof(const Decl *D)
static bool classof(const Decl *D)
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints derived from this template parameter list, including the requires clause a...
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
TemplateArgumentList & operator=(const TemplateArgumentList &)=delete
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
static bool classofKind(Kind K)
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static bool classofKind(Kind K)
const FunctionTemplateDecl * getMostRecentDecl() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
TypeAliasTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Declaration of a template function.
bool isExpandedParameterPack() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
static bool classofKind(Kind K)
static bool classof(const Decl *D)
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Kind
Lists the kind of concrete classes of Decl.
VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
NamedDecl * getParam(unsigned Idx)
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
Represents a pack expansion of types.
void Profile(llvm::FoldingSetNodeID &ID)
static bool classof(const Decl *D)
static ArrayRef< TemplateArgument > getTemplateArgs(FunctionTemplateSpecializationInfo *I)
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
A convenient class for passing around template argument information.
TagTypeKind
The kind of a tag type.
static bool classof(const Decl *D)
CommonBase * newCommon(ASTContext &C) const override
DeclType * operator->() const
const VarTemplateDecl * getPreviousDecl() const
TypeAliasTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
spec_range specializations() const
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
llvm::iterator_range< spec_iterator > spec_range
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
redeclarable_base::redecl_iterator redecl_iterator
Declaration of a C++20 concept.
static bool classof(const Decl *D)
SourceLocation getEnd() const
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool HasTypeConstraint)
TemplateParameterList * TemplateParams
Common * getCommonPtr() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Data that is common to all of the declarations of a given function template.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getInjectedSpecializationType() const
Retrieves the injected specialization type for this partial specialization.
TemplateParameterList(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
static bool classof(const Decl *D)
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
ClassTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this class template, or nullptr if no such declaration exists.
const T * getAs() const
Member-template getAs<specific type>'.
void setMemberSpecialization()
Note that this member template is a specialization.
spec_iterator spec_end() const
VarTemplateDecl * getDefinition()
void setTemplateArguments(ArrayRef< TemplateArgument > Converted)
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
bool hasAssociatedConstraints() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Represents a template argument.
spec_range specializations() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
void Profile(llvm::FoldingSetNodeID &ID)
static bool classofKind(Kind K)
const ClassTemplateDecl * getMostRecentDecl() const
TemplateParameterList * getTemplateParameterList(unsigned i) const
spec_range specializations() const
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
SourceLocation getEndLoc() const LLVM_READONLY
TemplateParamObjectDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPointOfInstantiation(SourceLocation Loc)
void setPlaceholderTypeConstraint(Expr *E)
SourceRange getSourceRange() const LLVM_READONLY
Location wrapper for a TemplateArgument.
const ASTTemplateArgumentListInfo * getTemplateArgsInfo() const
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type),...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
static bool classof(const Decl *D)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static constexpr unsigned MaxPosition
Decl * getPrimaryMergedDecl(Decl *D)
Get the primary declaration for a declaration from an AST file.
CommonBase * newCommon(ASTContext &C) const override
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
Represents a variable declaration or definition.
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this variable template specialization is actually an instantiation of the given variable te...
void setInstantiationOf(ClassTemplateDecl *TemplDecl)
Note that this class template specialization is an instantiation of the given class template.
std::optional< unsigned > getExpandedPackSize(const NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
static bool classofKind(Kind K)
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Stores a list of template parameters for a TemplateDecl and its derived classes.
void setInheritedDefaultArgument(const ASTContext &C, NonTypeTemplateParmDecl *Parm)
void setTemplateParameters(TemplateParameterList *TParams)
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Represents a declaration of a type.
MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, SourceLocation POI=SourceLocation())
const TemplateArgument & operator[](unsigned Idx) const
Retrieve the template argument at a given index.
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
const TypeAliasTemplateDecl * getCanonicalDecl() const
void setInheritedDefaultArgument(const ASTContext &C, TemplateTypeParmDecl *Prev)
Set that this default argument was inherited from another parameter.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
TemplateArgument * InjectedArgs
The set of "injected" template arguments used within this template.
A C++ nested-name-specifier augmented with source location information.
RedeclarableTemplateDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void Profile(llvm::FoldingSetNodeID &ID) const
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
friend class RedeclarableTemplate
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
This file provides AST data structures related to concepts.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const TemplateParamObjectDecl * getCanonicalDecl() const
static ImplicitConceptSpecializationDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation SL, ArrayRef< TemplateArgument > ConvertedArgs)
void set(ArgType Arg)
Set the default argument.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
Declaration of a template type parameter.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
SourceLocation getTemplateLoc() const
static bool classofKind(Kind K)
void setPosition(unsigned P)
A template parameter object.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
bool isAbbreviated() const
Return whether this function template is an abbreviated function template, e.g.
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
static bool classof(const Decl *D)
SourceLocation getRAngleLoc() const
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
VarTemplateDecl * getMostRecentDecl()
static bool classof(const Decl *D)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
bool isExplicitSpecialization() const
void printAsExpr(llvm::raw_ostream &OS) const
Print this object as an equivalent expression.
void loadLazySpecializationsImpl() const
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
Data that is common to all of the declarations of a given variable template.
VarTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
static DeclType * getDecl(EntryType *D)
bool isExplicitSpecialization() const
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type),...
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
FunctionDecl * getFunction() const
Retrieve the declaration of the function template specialization.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Represents a C++ struct/union/class.
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
void Profile(llvm::FoldingSetNodeID &ID) const
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
static bool classof(const Decl *D)
bool isExplicitSpecialization() const
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
const RedeclarableTemplateDecl * getCanonicalDecl() const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
NamedDecl * getAsNamedDecl(TemplateParameter P)
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
Declaration of a class template.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
static bool classofKind(Kind K)
void setDeclaredWithTypename(bool withTypename)
Set whether this template type parameter was declared with the 'typename' or 'class' keyword.
SourceLocation getRAngleLoc() const
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
bool isExplicitSpecialization() const
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const_iterator begin() const
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
void removeDefaultArgument()
Removes the default argument of this template parameter.
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known only by ...
RedeclarableTemplateDecl * getNextRedeclaration() const
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
BuiltinTemplateKind getBuiltinTemplateKind() const
void setPointOfInstantiation(SourceLocation POI)
Set the (first) point of instantiation of this function template specialization.
OnStackType
Type used to indicate that the template argument list itself is a stack object.
SpecIterator(typename llvm::FoldingSetVector< EntryType >::iterator SetIter)
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template.
Decl - This represents one declaration (or definition), e.g.
static bool classofKind(Kind K)
Represents a ValueDecl that came out of a declarator.
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static bool classofKind(Kind K)
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Stores a list of template parameters and the associated requires-clause (if any) for a TemplateDecl a...
void setMemberSpecialization()
Note that this member template is a specialization.
CXXMethodDecl * getSpecialization() const
Sema - This implements semantic analysis and AST building for C.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
static bool classof(const Decl *D)
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i'th template candidate.
ValueDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T)
static bool classofKind(Kind K)
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)
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
static bool classofKind(Kind K)
A template argument list.
RedeclarableTemplateDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
One of these records is kept for each identifier that is lexed.
void setCompleteDefinition()
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
ConceptDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
void Profile(llvm::FoldingSetNodeID &ID) const
void addSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, EntryType *Entry, void *InsertPos)
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
bool isParameterPack() const
Returns whether this is a parameter pack.
ArrayRef< NamedDecl * > asArray()
const DefArgStorage & getDefaultArgStorage() const
CXXRecordDecl * getMostRecentNonInjectedDecl()
SourceRange getSourceRange() const LLVM_READONLY
void setInstantiationOf(VarTemplateDecl *TemplDecl)
Note that this variable template specialization is an instantiation of the given variable template.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
Reads an AST files chain containing the contents of a translation unit.
bool isTypeConcept() const
static constexpr unsigned MaxDepth
Storage for a default argument.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const FunctionTemplateDecl * getPreviousDecl() const
const ClassTemplateDecl * getPreviousDecl() const
void Profile(llvm::FoldingSetNodeID &ID) const
void printName(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const override
Print this template parameter object in a human-readable format.
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
const TypeAliasTemplateDecl * getPreviousDecl() const
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the associated-constraints of this template parameter.
static bool classof(const Decl *D)
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
ClassTemplateDecl * getMostRecentDecl()
bool isClassScopeExplicitSpecialization() const
unsigned getNumExpansionParameters() const
Retrieves the number of parameters in an expanded parameter pack.
VarTemplatePartialSpecializationDecl * getMostRecentDecl()
bool hasAssociatedConstraints() const
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
bool isClassScopeExplicitSpecialization() const
Is this an explicit specialization at class scope (within the class that owns the primary template)?...
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
static bool classof(const Decl *D)
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
void setSpecializationKind(TemplateSpecializationKind TSK)
bool isInherited() const
Determine whether the default argument for this parameter was inherited from a previous declaration o...
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
static bool classofKind(Kind K)
SpecEntryTraits< EntryType >::DeclType * findSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, void *&InsertPos, ProfileArguments &&...ProfileArgs)
const FunctionTemplateDecl * getCanonicalDecl() const
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
bool isValid() const
Return true if this is a valid SourceLocation object.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
CommonBase * newCommon(ASTContext &C) const override
A container of type source information.
Defines the position of a template parameter within a template parameter list.
void removeDefaultArgument()
Removes the default argument of this template parameter.
Common * getCommonPtr() const
bool isMemberSpecialization()
Determines whether this class template partial specialization template was a specialization of a memb...
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or nullptr if this template w...
llvm::PointerIntPair< RedeclarableTemplateDecl *, 1, bool > InstantiatedFromMember
The template from which this was most directly instantiated (or null).
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
TemplateParameterList * getReplacedTemplateParameterList(Decl *D)
Internal helper used by Subst* nodes to retrieve the parameter list for their AssociatedDecl.
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
TemplateParamObjectDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void removeDefaultArgument()
Removes the default argument of this template parameter.
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this class template.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool hasParameterPack() const
Determine whether this template parameter list contains a parameter pack.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, const APValue &V)
static ImplicitConceptSpecializationDecl * CreateDeserialized(const ASTContext &C, unsigned ID, unsigned NumTemplateArgs)
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Declaration of an alias template.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
static ArrayRef< TemplateArgument > getTemplateArgs(EntryType *D)
const ConceptDecl * getCanonicalDecl() const
void * getAsOpaquePtr() const
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
spec_iterator spec_begin() const
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
static bool classofKind(Kind K)
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template.
FunctionTemplateDecl * getMostRecentDecl()
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
static ConceptDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
void init(NamedDecl *NewTemplatedDecl)
Initialize the underlying templated declaration.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
SourceLocation getLAngleLoc() const
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Declaration of a variable template.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
This represents one expression.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
static bool classof(const Decl *D)
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
const APValue & getValue() const
CommonBase * newCommon(ASTContext &C) const override
const ClassTemplateDecl * getCanonicalDecl() const
unsigned getNumTemplateParameters() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
static bool classofKind(Kind K)
Represents a class template specialization, which refers to a class template with a given set of temp...
static bool classof(const Decl *D)
spec_iterator spec_begin() const
void setInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *PartialSpec)
bool hasAssociatedConstraints() const
SourceLocation getLocation() const
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
void setSpecializedTemplate(ClassTemplateDecl *Specialized)
unsigned size() const
Retrieve the number of template arguments in this template argument list.
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Represents a function declaration or definition.
unsigned getDepth() const
Retrieve the depth of the template parameter.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
void setInherited(const ASTContext &C, ParmDecl *InheritedFrom)
Set that the default argument was inherited from another parameter.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
VarTemplateSpecializationDecl(Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
size_t numTrailingObjects(OverloadToken< Expr * >) const
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, const TemplateArgumentListInfo &TemplateArgs)
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the associated-constraints of this template parameter.
ArrayRef< TemplateArgument > getInjectedTemplateArgs()
Retrieve the "injected" template arguments that correspond to the template parameters of this templat...
SourceLocation PointOfInstantiation
The point at which this function template specialization was first instantiated.
MemberSpecializationInfo * getMemberSpecializationInfo() const
Get the specialization info if this function template specialization is also a member specialization:
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
static bool classofKind(Kind K)
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
Represents a static or instance method of a struct/union/class.
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
StorageClass
Storage classes.