14 #ifndef LLVM_CLANG_AST_DECLTEMPLATE_H 15 #define LLVM_CLANG_AST_DECLTEMPLATE_H 28 #include "llvm/ADT/ArrayRef.h" 29 #include "llvm/ADT/FoldingSet.h" 30 #include "llvm/ADT/PointerIntPair.h" 31 #include "llvm/ADT/PointerUnion.h" 32 #include "llvm/ADT/iterator.h" 33 #include "llvm/ADT/iterator_range.h" 34 #include "llvm/Support/Casting.h" 35 #include "llvm/Support/Compiler.h" 36 #include "llvm/Support/TrailingObjects.h" 46 class ClassTemplateDecl;
47 class ClassTemplatePartialSpecializationDecl;
49 class FunctionTemplateDecl;
51 class NonTypeTemplateParmDecl;
53 class TemplateTemplateParmDecl;
54 class TemplateTypeParmDecl;
56 class UnresolvedSetImpl;
57 class VarTemplateDecl;
58 class VarTemplatePartialSpecializationDecl;
62 llvm::PointerUnion<TemplateTypeParmDecl *, NonTypeTemplateParmDecl *,
80 unsigned NumParams : 30;
84 unsigned ContainsUnexpandedParameterPack : 1;
87 unsigned HasRequiresClause : 1;
91 unsigned HasConstrainedParameters : 1;
103 return HasRequiresClause ? 1 : 0;
107 template <
size_t N,
bool HasRequiresClause>
116 Expr *RequiresClause);
129 unsigned size()
const {
return NumParams; }
132 return llvm::makeArrayRef(
begin(),
end());
135 return llvm::makeArrayRef(
begin(),
size());
139 assert(Idx <
size() &&
"Template parameter index out-of-range");
143 assert(Idx <
size() &&
"Template parameter index out-of-range");
164 return ContainsUnexpandedParameterPack;
170 if (
P->isParameterPack())
177 return HasRequiresClause ? getTrailingObjects<Expr *>()[0] :
nullptr;
182 return HasRequiresClause ? getTrailingObjects<Expr *>()[0] :
nullptr;
204 bool OmitTemplateKW =
false)
const;
216 template <
size_t N,
bool HasRequiresClause>
219 typename TemplateParameterList::FixedSizeStorage<
221 N, HasRequiresClause ? 1u : 0u
230 Expr *RequiresClause)
232 (assert(N == Params.
size()),
233 assert(HasRequiresClause == (RequiresClause != nullptr)),
235 TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
246 unsigned NumArguments;
272 : Arguments(Args.data()), NumArguments(Args.
size()) {}
281 : Arguments(Other->data()), NumArguments(Other->
size()) {}
285 assert(Idx < NumArguments &&
"Invalid template argument index");
294 return llvm::makeArrayRef(data(),
size());
299 unsigned size()
const {
return NumArguments; }
315 template<
typename ParmDecl,
typename ArgType>
321 ParmDecl *PrevDeclWithDefaultArg;
324 static_assert(
sizeof(Chain) ==
sizeof(
void *) * 2,
325 "non-pointer argument type?");
327 llvm::PointerUnion<ArgType, ParmDecl*, Chain*> ValueOrInherited;
329 static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
331 if (
auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
333 assert(!Parm->getDefaultArgStorage()
334 .ValueOrInherited.template is<ParmDecl *>() &&
335 "should only be one level of indirection");
343 bool isSet()
const {
return !ValueOrInherited.isNull(); }
347 bool isInherited()
const {
return ValueOrInherited.template is<ParmDecl*>(); }
351 ArgType
get()
const {
353 if (
const auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl *>())
354 Storage = &Prev->getDefaultArgStorage();
355 if (
const auto *C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
357 return Storage->ValueOrInherited.template get<ArgType>();
363 if (
const auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>())
365 if (
const auto *C = ValueOrInherited.template dyn_cast<Chain *>())
366 return C->PrevDeclWithDefaultArg;
371 void set(ArgType Arg) {
372 assert(!isSet() &&
"default argument already set");
373 ValueOrInherited = Arg;
378 assert(!isInherited() &&
"default argument already inherited");
379 InheritedFrom = getParmOwningDefaultArg(InheritedFrom);
381 ValueOrInherited = InheritedFrom;
384 Chain{InheritedFrom, ValueOrInherited.template get<ArgType>()};
389 ValueOrInherited = ArgType();
403 void anchor()
override;
422 return TemplateParams;
440 return K >= firstTemplate && K <= lastTemplate;
445 TemplatedDecl->getSourceRange().getEnd());
453 TemplateParams = TParams;
460 assert(!TemplatedDecl &&
"TemplatedDecl already set!");
461 assert(!TemplateParams &&
"TemplateParams already set!");
462 TemplatedDecl = templatedDecl;
463 TemplateParams = templateParams;
471 :
public llvm::FoldingSetNode,
473 MemberSpecializationInfo *> {
476 llvm::PointerIntPair<FunctionDecl *, 1, bool> Function;
482 llvm::PointerIntPair<FunctionTemplateDecl *, 2> Template;
503 : Function(FD, MSInfo ? 1 : 0), Template(Template, TSK - 1),
504 TemplateArguments(TemplateArgs),
505 TemplateArgumentsAsWritten(TemplateArgsAsWritten),
506 PointOfInstantiation(POI) {
508 getTrailingObjects<MemberSpecializationInfo *>()[0] = MSInfo;
512 return Function.getInt();
551 "Cannot encode TSK_Undeclared for a function template specialization");
552 Template.setInt(TSK - 1);
561 return PointOfInstantiation;
567 PointOfInstantiation = POI;
602 ? getTrailingObjects<MemberSpecializationInfo *>()[0]
607 Profile(ID, TemplateArguments->
asArray(), getFunction()->getASTContext());
613 ID.AddInteger(TemplateArgs.size());
615 TemplateArg.Profile(ID, Context);
625 llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
634 : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
636 "Cannot encode undeclared template specializations for members");
655 "Cannot encode undeclared template specializations for members");
656 MemberAndTSK.setInt(TSK - 1);
663 return PointOfInstantiation;
668 PointOfInstantiation = POI;
689 FunctionTemplateDecl *> {
691 unsigned NumTemplates;
723 assert(I < getNumTemplates() &&
"template index out of range");
724 return getTrailingObjects<FunctionTemplateDecl *>()[I];
729 return getTrailingObjects<TemplateArgumentLoc>();
737 assert(I < getNumTemplateArgs() &&
"template arg index out of range");
738 return getTemplateArgs()[I];
746 return AngleLocs.
getEnd();
757 return getNextRedeclaration();
761 return getPreviousDecl();
765 return getMostRecentDecl();
768 void anchor()
override;
778 return D->getTemplateArgs().asArray();
782 template <
typename EntryType,
typename SETraits = SpecEntryTraits<EntryType>,
783 typename DeclType =
typename SETraits::DeclType>
785 : llvm::iterator_adaptor_base<
786 SpecIterator<EntryType, SETraits, DeclType>,
787 typename llvm::FoldingSetVector<EntryType>::iterator,
788 typename std::iterator_traits<typename llvm::FoldingSetVector<
789 EntryType>::iterator>::iterator_category,
790 DeclType *, ptrdiff_t, DeclType *, DeclType *> {
793 typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
797 return SETraits::getDecl(&*this->I)->getMostRecentDecl();
803 template <
typename EntryType>
809 void loadLazySpecializationsImpl()
const;
811 template <
class EntryType,
typename ...ProfileArguments>
813 findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
814 void *&InsertPos, ProfileArguments &&...ProfileArgs);
816 template <
class Derived,
class EntryType>
817 void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
818 EntryType *Entry,
void *InsertPos);
828 llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
836 uint32_t *LazySpecializations =
nullptr;
860 template <
class decl_type>
friend class RedeclarableTemplate;
864 return getFirstDecl();
867 return getFirstDecl();
889 return getCommonPtr()->InstantiatedFromMember.getInt();
894 assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
895 "Only member templates can be member template specializations");
896 getCommonPtr()->InstantiatedFromMember.setInt(
true);
936 return getCommonPtr()->InstantiatedFromMember.getPointer();
940 assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
941 getCommonPtr()->InstantiatedFromMember.setPointer(TD);
947 using redeclarable_base::redecls_begin;
948 using redeclarable_base::redecls_end;
949 using redeclarable_base::redecls;
950 using redeclarable_base::getPreviousDecl;
951 using redeclarable_base::getMostRecentDecl;
952 using redeclarable_base::isFirstDecl;
958 return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate;
1014 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
1015 getSpecializations()
const;
1029 void LoadLazySpecializations()
const;
1039 return getTemplatedDecl()->isThisDeclarationADefinition();
1048 return cast<FunctionTemplateDecl>(
1052 return cast<FunctionTemplateDecl>(
1059 return cast_or_null<FunctionTemplateDecl>(
1063 return cast_or_null<FunctionTemplateDecl>(
1068 return cast<FunctionTemplateDecl>(
1070 ->getMostRecentDecl());
1077 return cast_or_null<FunctionTemplateDecl>(
1089 return makeSpecIterator(getSpecializations(),
false);
1093 return makeSpecIterator(getSpecializations(),
true);
1191 bool HasTypeConstraint : 1;
1196 bool TypeConstraintInitialized : 1;
1201 bool ExpandedParameterPack : 1;
1204 unsigned NumExpanded = 0;
1213 bool Typename,
bool HasTypeConstraint,
1215 :
TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename),
1216 HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(
false),
1217 ExpandedParameterPack(NumExpanded),
1218 NumExpanded(NumExpanded ? *NumExpanded : 0) {}
1224 unsigned D,
unsigned P,
1227 bool HasTypeConstraint =
false,
1229 static TemplateTypeParmDecl *CreateDeserialized(
const ASTContext &C,
1231 static TemplateTypeParmDecl *CreateDeserialized(
const ASTContext &C,
1233 bool HasTypeConstraint);
1241 return Typename && !HasTypeConstraint;
1252 return DefaultArgument.
get()->getType();
1257 return DefaultArgument.
get();
1271 DefaultArgument.
set(DefArg);
1277 TemplateTypeParmDecl *Prev) {
1283 DefaultArgument.
clear();
1294 unsigned getIndex()
const;
1297 bool isParameterPack()
const;
1304 if (!isParameterPack())
1307 if (TC->hasExplicitTemplateArgs())
1308 for (
const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
1309 if (ArgLoc.getArgument().containsUnexpandedParameterPack())
1339 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1346 return TypeConstraintInitialized ? getTrailingObjects<TypeConstraint>() :
1354 Expr *ImmediatelyDeclaredConstraint);
1358 return HasTypeConstraint;
1367 if (HasTypeConstraint)
1368 AC.push_back(getTypeConstraint()->getImmediatelyDeclaredConstraint());
1383 class NonTypeTemplateParmDecl final
1387 std::pair<QualType, TypeSourceInfo *>,
1406 bool ExpandedParameterPack =
false;
1409 unsigned NumExpandedTypes = 0;
1412 OverloadToken<std::pair<QualType, TypeSourceInfo *>>)
const {
1413 return NumExpandedTypes;
1420 :
DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
1431 static NonTypeTemplateParmDecl *
1436 static NonTypeTemplateParmDecl *
1442 static NonTypeTemplateParmDecl *CreateDeserialized(
ASTContext &C,
1444 bool HasTypeConstraint);
1445 static NonTypeTemplateParmDecl *CreateDeserialized(
ASTContext &C,
1447 unsigned NumExpandedTypes,
1448 bool HasTypeConstraint);
1481 NonTypeTemplateParmDecl *Parm) {
1537 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1538 return NumExpandedTypes;
1544 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1545 auto TypesAndInfos =
1546 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1547 return TypesAndInfos[I].first;
1553 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1554 auto TypesAndInfos =
1555 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1556 return TypesAndInfos[I].second;
1562 return hasPlaceholderTypeConstraint() ? *getTrailingObjects<Expr *>() :
1567 *getTrailingObjects<Expr *>() = E;
1573 auto *AT = getType()->getContainedAutoType();
1574 return AT && AT->isConstrained();
1584 if (
Expr *E = getPlaceholderTypeConstraint())
1604 TemplateParameterList *> {
1608 DefArgStorage DefaultArgument;
1616 bool ExpandedParameterPack =
false;
1619 unsigned NumExpandedParams = 0;
1622 unsigned D,
unsigned P,
bool ParameterPack,
1624 :
TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
1628 unsigned D,
unsigned P,
1632 void anchor()
override;
1641 unsigned P,
bool ParameterPack,
1655 unsigned NumExpansions);
1676 return ParameterPack &&
1677 getTemplateParameters()->containsUnexpandedParameterPack();
1703 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1704 return NumExpandedParams;
1710 assert(I < NumExpandedParams &&
"Out-of-range expansion type index");
1711 return getTrailingObjects<TemplateParameterList *>()[I];
1723 return DefaultArgument.
isSet() ? *DefaultArgument.
get() : NoneLoc;
1750 if (hasDefaultArgument() && !defaultArgumentWasInherited())
1751 End = getDefaultArgument().getSourceRange().getEnd();
1769 void anchor()
override;
1807 struct SpecializedPartialSpecialization {
1818 llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1819 SpecializedTemplate;
1822 struct ExplicitSpecializationInfo {
1832 ExplicitSpecializationInfo() =
default;
1837 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
1847 unsigned SpecializationKind : 3;
1872 void getNameForDiagnostic(raw_ostream &OS,
const PrintingPolicy &Policy,
1873 bool Qualified)
const override;
1881 return cast<ClassTemplateSpecializationDecl>(
1882 getMostRecentNonInjectedDecl());
1891 return *TemplateArgs;
1914 return isExplicitSpecialization() &&
1915 isa<CXXRecordDecl>(getLexicalDeclContext());
1927 SpecializationKind = TSK;
1932 return PointOfInstantiation;
1936 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
1937 PointOfInstantiation = Loc;
1948 return llvm::PointerUnion<ClassTemplateDecl *,
1951 return getSpecializedTemplateOrPartial();
1956 llvm::PointerUnion<ClassTemplateDecl *,
1959 if (
const auto *PartialSpec =
1960 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1961 return PartialSpec->PartialSpecialization;
1963 return SpecializedTemplate.get<ClassTemplateDecl*>();
1978 if (
const auto *PartialSpec =
1979 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1980 return *PartialSpec->TemplateArgs;
1982 return getTemplateArgs();
1990 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
1991 "Already set to a class template partial specialization!");
1992 auto *PS =
new (getASTContext()) SpecializedPartialSpecialization();
1993 PS->PartialSpecialization = PartialSpec;
1994 PS->TemplateArgs = TemplateArgs;
1995 SpecializedTemplate = PS;
2001 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
2002 "Previously set to a class template partial specialization!");
2003 SpecializedTemplate = TemplDecl;
2010 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2011 ExplicitInfo->TypeAsWritten = T;
2017 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2022 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2028 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2029 ExplicitInfo->ExternLoc = Loc;
2035 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2036 ExplicitInfo->TemplateKeywordLoc = Loc;
2041 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2047 Profile(ID, TemplateArgs->
asArray(), getASTContext());
2053 ID.AddInteger(TemplateArgs.size());
2055 TemplateArg.Profile(ID, Context);
2061 return K >= firstClassTemplateSpecialization &&
2062 K <= lastClassTemplateSpecialization;
2080 llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
2081 InstantiatedFromMember;
2095 InstantiatedFromMember(
nullptr,
false) {}
2097 void anchor()
override;
2117 return cast<ClassTemplatePartialSpecializationDecl>(
2119 this)->getMostRecentDecl());
2124 return TemplateParams;
2143 return ArgsAsWritten;
2168 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2169 return First->InstantiatedFromMember.getPointer();
2173 return getInstantiatedFromMember();
2178 auto *
First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2179 First->InstantiatedFromMember.setPointer(PartialSpec);
2200 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2201 return First->InstantiatedFromMember.getInt();
2206 auto *
First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2207 assert(
First->InstantiatedFromMember.getPointer() &&
2208 "Only member templates can be member template specializations");
2209 return First->InstantiatedFromMember.setInt(
true);
2216 assert(getTypeForDecl() &&
"partial specialization has no type set!");
2217 return cast<InjectedClassNameType>(getTypeForDecl())
2218 ->getInjectedSpecializationType();
2222 Profile(ID, getTemplateArgs().
asArray(), getTemplateParameters(),
2233 return K == ClassTemplatePartialSpecialization;
2249 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>
2259 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
2260 getSpecializations()
const;
2264 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
2265 getPartialSpecializations();
2283 void LoadLazySpecializations()
const;
2293 return getTemplatedDecl()->isThisDeclarationADefinition();
2316 return cast<ClassTemplateDecl>(
2320 return cast<ClassTemplateDecl>(
2327 return cast_or_null<ClassTemplateDecl>(
2331 return cast_or_null<ClassTemplateDecl>(
2333 this)->getPreviousDecl());
2337 return cast<ClassTemplateDecl>(
2345 return cast_or_null<ClassTemplateDecl>(
2361 void getPartialSpecializations(
2383 findPartialSpecInstantiatedFromMember(
2400 QualType getInjectedClassNameSpecialization();
2410 return makeSpecIterator(getSpecializations(),
false);
2414 return makeSpecIterator(getSpecializations(),
true);
2436 virtual void anchor();
2443 unsigned NumParams = 0;
2457 :
Decl(
Decl::FriendTemplate, DC, Loc), NumParams(Params.
size()),
2458 Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
2492 assert(i <= NumParams);
2538 return cast<TypeAliasTemplateDecl>(
2542 return cast<TypeAliasTemplateDecl>(
2549 return cast_or_null<TypeAliasTemplateDecl>(
2553 return cast_or_null<TypeAliasTemplateDecl>(
2555 this)->getPreviousDecl());
2559 return cast_or_null<TypeAliasTemplateDecl>(
2602 :
Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc),
2603 Specialization(FD), TemplateArgs(TemplArgs) {}
2606 :
Decl(Decl::ClassScopeFunctionSpecialization, Empty) {}
2608 virtual void anchor();
2617 return TemplateArgs;
2622 bool HasExplicitTemplateArgs,
2626 HasExplicitTemplateArgs
2638 return K == Decl::ClassScopeFunctionSpecialization;
2656 public llvm::FoldingSetNode {
2661 struct SpecializedPartialSpecialization {
2672 llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2673 SpecializedTemplate;
2676 struct ExplicitSpecializationInfo {
2686 ExplicitSpecializationInfo() =
default;
2691 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
2702 unsigned SpecializationKind : 3;
2708 unsigned IsCompleteDefinition : 1;
2733 void getNameForDiagnostic(raw_ostream &OS,
const PrintingPolicy &Policy,
2734 bool Qualified)
const override;
2737 VarDecl *Recent =
static_cast<VarDecl *
>(
this)->getMostRecentDecl();
2738 return cast<VarTemplateSpecializationDecl>(Recent);
2752 return TemplateArgsInfo;
2766 return isExplicitSpecialization() &&
2767 isa<CXXRecordDecl>(getLexicalDeclContext());
2779 SpecializationKind = TSK;
2784 return PointOfInstantiation;
2788 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
2789 PointOfInstantiation = Loc;
2798 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2804 return getSpecializedTemplateOrPartial();
2809 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2811 if (
const auto *PartialSpec =
2812 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2813 return PartialSpec->PartialSpecialization;
2830 if (
const auto *PartialSpec =
2831 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2832 return *PartialSpec->TemplateArgs;
2834 return getTemplateArgs();
2842 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2843 "Already set to a variable template partial specialization!");
2844 auto *PS =
new (getASTContext()) SpecializedPartialSpecialization();
2845 PS->PartialSpecialization = PartialSpec;
2846 PS->TemplateArgs = TemplateArgs;
2847 SpecializedTemplate = PS;
2853 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2854 "Previously set to a variable template partial specialization!");
2855 SpecializedTemplate = TemplDecl;
2862 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2863 ExplicitInfo->TypeAsWritten = T;
2869 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2874 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2880 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2881 ExplicitInfo->ExternLoc = Loc;
2887 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2888 ExplicitInfo->TemplateKeywordLoc = Loc;
2893 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2897 Profile(ID, TemplateArgs->
asArray(), getASTContext());
2903 ID.AddInteger(TemplateArgs.size());
2905 TemplateArg.Profile(ID, Context);
2911 return K >= firstVarTemplateSpecialization &&
2912 K <= lastVarTemplateSpecialization;
2930 llvm::PointerIntPair<VarTemplatePartialSpecializationDecl *, 1, bool>
2931 InstantiatedFromMember;
2943 InstantiatedFromMember(
nullptr,
false) {}
2945 void anchor()
override;
2962 return cast<VarTemplatePartialSpecializationDecl>(
2964 this)->getMostRecentDecl());
2969 return TemplateParams;
2974 return ArgsAsWritten;
3013 cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
3014 return First->InstantiatedFromMember.getPointer();
3019 auto *
First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
3020 First->InstantiatedFromMember.setPointer(PartialSpec);
3041 cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
3042 return First->InstantiatedFromMember.getInt();
3047 auto *
First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
3048 assert(
First->InstantiatedFromMember.getPointer() &&
3049 "Only member templates can be member template specializations");
3050 return First->InstantiatedFromMember.setInt(
true);
3054 Profile(ID, getTemplateArgs().
asArray(), getTemplateParameters(),
3065 return K == VarTemplatePartialSpecialization;
3081 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>
3088 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
3089 getSpecializations()
const;
3093 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
3094 getPartialSpecializations();
3112 void LoadLazySpecializations()
const;
3116 return static_cast<VarDecl *
>(TemplatedDecl);
3122 return getTemplatedDecl()->isThisDeclarationADefinition();
3155 return cast_or_null<VarTemplateDecl>(
3159 return cast_or_null<VarTemplateDecl>(
3161 this)->getPreviousDecl());
3165 return cast<VarTemplateDecl>(
3173 return cast_or_null<VarTemplateDecl>(
3189 void getPartialSpecializations(
3213 return makeSpecIterator(getSpecializations(),
false);
3217 return makeSpecIterator(getSpecializations(),
true);
3233 ConstraintExpr(ConstraintExpr) {};
3238 Expr *ConstraintExpr);
3242 return ConstraintExpr;
3251 return isa<TemplateTypeParmDecl>(getTemplateParameters()->getParam(0));
3264 if (
auto *PD = P.dyn_cast<TemplateTypeParmDecl *>())
3266 if (
auto *PD = P.dyn_cast<NonTypeTemplateParmDecl *>())
3273 return TD && (isa<ClassTemplateDecl>(TD) ||
3274 isa<ClassTemplatePartialSpecializationDecl>(TD) ||
3275 isa<TypeAliasTemplateDecl>(TD) ||
3276 isa<TemplateTemplateParmDecl>(TD))
3283 #endif // LLVM_CLANG_AST_DECLTEMPLATE_H bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
void setInstantiationOf(ClassTemplateDecl *TemplDecl)
Note that this class template specialization is an instantiation of the given class template...
spec_iterator spec_begin() const
Represents a function declaration or definition.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
llvm::iterator_range< redecl_iterator > redecl_range
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params)
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
A (possibly-)qualified type.
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
VarTemplateSpecializationDecl * getMostRecentDecl()
ArrayRef< const NamedDecl * > asArray() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
Get the specialization info if this function template specialization is also a member specialization:...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
bool isMemberSpecialization()
Determines whether this class template partial specialization template was a specialization of a memb...
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
C Language Family Type Representation.
spec_range specializations() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
spec_iterator spec_end() const
Decl - This represents one declaration (or definition), e.g.
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
TypeAliasTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
ArrayRef< NamedDecl * > asArray()
void setInheritedDefaultArgument(const ASTContext &C, NonTypeTemplateParmDecl *Parm)
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
Get the associated-constraints of this template parameter.
VarTemplatePartialSpecializationDecl * getMostRecentDecl()
bool isExplicitSpecialization() const
const TypeAliasTemplateDecl * getPreviousDecl() const
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
void removeDefaultArgument()
Removes the default argument of this template parameter.
Declaration of a variable template.
size_t numTrailingObjects(OverloadToken< Expr *>) const
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
static bool classofKind(Kind K)
A container of type source information.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
static bool classofKind(Kind K)
const ClassTemplateDecl * getCanonicalDecl() const
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
unsigned getDepth() const
Get the nesting depth of the template parameter.
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
Represents a variable declaration or definition.
Declaration of a redeclarable template.
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
bool hasAssociatedConstraints() const
static bool classofKind(Kind K)
const TemplateArgumentLoc * getTemplateArgs() const
Returns the explicit template arguments that were given.
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
SourceLocation getLAngleLoc() const
TemplateParmPosition(unsigned D, unsigned P)
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. ...
static bool classofKind(Kind K)
static const NamedDecl * getDefinition(const Decl *D)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Provides information about a dependent function-template specialization declaration.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
static bool classof(const Decl *D)
const VarTemplateDecl * getCanonicalDecl() const
static bool classof(const Decl *D)
llvm::iterator_range< spec_iterator > spec_range
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
bool isTemplateExplicitInstantiationOrSpecialization(TemplateSpecializationKind Kind)
True if this template specialization kind is an explicit specialization, explicit instantiation decla...
Provides common interface for the Decls that can be redeclared.
TemplateArgumentList(const TemplateArgumentList *Other)
Produces a shallow copy of the given template argument list.
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
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.
void setInstantiationOf(VarTemplateDecl *TemplDecl)
Note that this variable template specialization is an instantiation of the given variable template...
Defines the position of a template parameter within a template parameter list.
bool isExpandedParameterPack() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
const DefArgStorage & getDefaultArgStorage() const
void * allocateDefaultArgStorageChain(const ASTContext &C)
ClassTemplateSpecializationDecl * getMostRecentDecl()
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
static bool classofKind(Kind K)
void Profile(llvm::FoldingSetNodeID &ID)
Declaration of a function specialization at template class scope.
SourceLocation getTemplateLoc() const
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type)...
llvm::iterator_range< spec_iterator > spec_range
TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
static bool classof(const Decl *D)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Common * getCommonPtr() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, const TemplateArgumentListInfo &TemplateArgs)
const RedeclarableTemplateDecl * getCanonicalDecl() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void set(ArgType Arg)
Set the default argument.
bool isInherited() const
Determine whether the default argument for this parameter was inherited from a previous declaration o...
A convenient class for passing around template argument information.
void setDepth(unsigned D)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
static bool classof(const Decl *D)
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
static bool classofKind(Kind K)
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
Represents a declaration of a type.
A set of unresolved declarations.
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or nullptr if this template w...
void setInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *PartialSpec)
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
const TemplateArgument & operator[](unsigned Idx) const
Retrieve the template argument at a given index.
void setSpecializationKind(TemplateSpecializationKind TSK)
spec_range specializations() const
ArgType get() const
Get the default argument's value.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMemberTemplate() const
TemplateParameterList * getTemplateParameterList(unsigned i) const
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
static bool classofKind(Kind K)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
SourceLocation PointOfInstantiation
The point at which this function template specialization was first instantiated.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
const TypeAliasTemplateDecl * getCanonicalDecl() const
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
bool isExplicitSpecialization() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
bool isExplicitSpecialization() const
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
const VarTemplateDecl * getMostRecentDecl() const
static bool classof(const Decl *D)
Sema - This implements semantic analysis and AST building for C.
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Represents the declaration of a typedef-name via a C++11 alias-declaration.
bool isExplicitSpecialization() const
Represents a ValueDecl that came out of a declarator.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
void clear()
Remove the default argument, even if it was inherited.
unsigned getNumExpansionParameters() const
Retrieves the number of parameters in an expanded parameter pack.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
spec_range specializations() const
const NamedDecl * getParam(unsigned Idx) const
const FunctionTemplateDecl * getMostRecentDecl() const
bool hasAssociatedConstraints() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static bool classof(const Decl *D)
QualType getInjectedSpecializationType() const
Retrieves the injected specialization type for this partial specialization.
llvm::iterator_range< spec_iterator > spec_range
This represents one expression.
void setCompleteDefinition()
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template.
const VarTemplateDecl * getPreviousDecl() const
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
void setInherited(const ASTContext &C, ParmDecl *InheritedFrom)
Set that the default argument was inherited from another parameter.
static bool classof(const Decl *D)
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, SourceLocation POI=SourceLocation())
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
static bool classof(const Decl *D)
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
Get the associated-constraints of this template parameter.
spec_iterator spec_end() const
Data that is common to all of the declarations of a given variable template.
spec_iterator spec_end() const
void setMemberSpecialization()
Note that this member template is a specialization.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
spec_iterator spec_begin() const
bool isTypeConcept() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
static bool classof(const Decl *D)
StorageClass
Storage classes.
Declaration of an alias template.
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i'th template candidate.
static ArrayRef< TemplateArgument > getTemplateArgs(EntryType *D)
void setPointOfInstantiation(SourceLocation Loc)
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getEnd() const
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
BuiltinTemplateKind getBuiltinTemplateKind() const
Data that is common to all of the declarations of a given class template.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static bool classofKind(Kind K)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
static DeclType * getDecl(EntryType *D)
SourceLocation getEndLoc() const LLVM_READONLY
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
void setPointOfInstantiation(SourceLocation POI)
Set the (first) point of instantiation of this function template specialization.
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
OnStackType
Type used to indicate that the template argument list itself is a stack object.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
static bool classofKind(Kind K)
Stores a list of template parameters and the associated requires-clause (if any) for a TemplateDecl a...
spec_iterator spec_begin() const
QualType InjectedClassNameType
The injected-class-name type for this class template.
static bool classofKind(Kind K)
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
ClassTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this class template, or nullptr if no such declaration exists...
DeclType * operator->() const
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
static bool classof(const Decl *D)
const FunctionTemplateDecl * getPreviousDecl() const
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
bool isAbbreviated() const
Return whether this function template is an abbreviated function template, e.g.
void setPosition(unsigned P)
const Expr * getRequiresClause() const
The constraint-expression of the associated requires-clause.
Represents a static or instance method of a struct/union/class.
void Profile(llvm::FoldingSetNodeID &ID) const
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
void Profile(llvm::FoldingSetNodeID &ID) const
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
Data that is common to all of the declarations of a given function template.
void Profile(llvm::FoldingSetNodeID &ID) const
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
FunctionDecl * getFunction() const
Retrieve the declaration of the function template specialization.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
static bool classof(const Decl *D)
Common * getCommonPtr() const
const TemplateArgumentListInfo & getTemplateArgsInfo() const
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void init(NamedDecl *templatedDecl, TemplateParameterList *templateParams)
Initialize the underlying templated declaration and template parameters.
ConceptDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
void setPointOfInstantiation(SourceLocation Loc)
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)
ClassTemplateDecl * getMostRecentDecl()
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
SourceLocation getRAngleLoc() const
size_t numTrailingObjects(OverloadToken< NamedDecl *>) const
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
static bool classofKind(Kind K)
static bool classofKind(Kind K)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
SourceLocation getRAngleLoc() const
static bool classofKind(Kind K)
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this variable template specialization is an instantiation of a template (rather than an explicit s...
void setDeclaredWithTypename(bool withTypename)
Set whether this template type parameter was declared with the 'typename' or 'class' keyword...
Represents a pack expansion of types.
NamedDecl * TemplatedDecl
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
Defines various enumerations that describe declaration and type specifiers.
bool hasPlaceholderTypeConstraint() const
Determine whether this non-type template parameter's type has a placeholder with a type-constraint...
Represents a template argument.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
TagTypeKind
The kind of a tag type.
void setPlaceholderTypeConstraint(Expr *E)
void setMemberSpecialization()
Note that this member template is a specialization.
const ClassTemplateDecl * getPreviousDecl() const
void removeDefaultArgument()
Removes the default argument of this template parameter.
Dataflow Directional Tag Classes.
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...
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool hasExplicitTemplateArgs() const
llvm::PointerIntPair< RedeclarableTemplateDecl *, 1, bool > InstantiatedFromMember
The template from which this was most directly instantiated (or null).
static bool classof(const Decl *D)
The base class of all kinds of template declarations (e.g., class, function, etc.).
static ArrayRef< TemplateArgument > getTemplateArgs(FunctionTemplateSpecializationInfo *I)
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
Reads an AST files chain containing the contents of a translation unit.
static bool classof(const Decl *D)
static bool classofKind(Kind K)
void setInheritedDefaultArgument(const ASTContext &C, TemplateTypeParmDecl *Prev)
Set that this default argument was inherited from another parameter.
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
unsigned getNumTemplateParameters() const
The name of a declaration.
static bool classofKind(Kind K)
static bool classof(const Decl *D)
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
bool isClassScopeExplicitSpecialization() const
Is this an explicit specialization at class scope (within the class that owns the primary template)...
bool isClassScopeExplicitSpecialization() const
TemplateParameterList * TemplateParams
void setTemplateParameters(TemplateParameterList *TParams)
llvm::iterator_range< redecl_iterator > redecl_range
Storage for a default argument.
bool hasParameterPack() const
Determine whether this template parameter list contains a parameter pack.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
FixedSizeTemplateParameterListStorage(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
ClassTemplatePartialSpecializationDecl * getMostRecentDecl()
static bool classofKind(Kind K)
DeclType * operator*() const
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
const DefArgStorage & getDefaultArgStorage() const
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
static bool classofKind(Kind K)
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
Location wrapper for a TemplateArgument.
const_iterator end() const
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static DeclType * getDecl(FunctionTemplateSpecializationInfo *I)
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or nullptr if no such declaration exists...
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
TypeAliasTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
static bool classof(const Decl *D)
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
const ClassTemplateDecl * getMostRecentDecl() const
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this variable template specialization is actually an instantiation of the given variable te...
SpecIterator(typename llvm::FoldingSetVector< EntryType >::iterator SetIter)
A template argument list.
redeclarable_base::redecl_iterator redecl_iterator
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Defines the clang::SourceLocation class and associated facilities.
VarTemplateDecl * getMostRecentDecl()
static bool classof(const Decl *D)
Represents a C++ struct/union/class.
TypeAliasTemplateDecl * getInstantiatedFromMemberTemplate() const
Provides information a specialization of a member of a class template, which may be a member function...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static bool classof(const Decl *D)
VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
Declaration of a class template.
VarTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
CXXMethodDecl * getSpecialization() const
void removeDefaultArgument()
Removes the default argument of this template parameter.
static SpecIterator< EntryType > makeSpecIterator(llvm::FoldingSetVector< EntryType > &Specs, bool isEnd)
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
const_iterator begin() const
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
bool hasAssociatedConstraints() const
Kind
Lists the kind of concrete classes of Decl.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
Common * getCommonPtr() const
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
bool isSet() const
Determine whether there is a default argument for this parameter.
void setMemberSpecialization()
Note that this member template is a specialization.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
QualType getDefaultArgument() const
Retrieve the default argument, if any.
void Profile(llvm::FoldingSetNodeID &ID) const
const FunctionTemplateDecl * getCanonicalDecl() const
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
SourceLocation getLAngleLoc() const
NamedDecl * getAsNamedDecl(TemplateParameter P)
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
Declaration of a friend template.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
Expr * getConstraintExpr() const
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type)...
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
This file provides AST data structures related to concepts.
SourceLocation getBegin() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
SourceRange getSourceRange() const LLVM_READONLY
TrailingObjects::FixedSizeStorageOwner FixedSizeStorageOwner
Declaration of a template function.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
FunctionTemplateDecl * getMostRecentDecl()
TemplateArgumentList(OnStackType, ArrayRef< TemplateArgument > Args)
Construct a new, temporary template argument list on the stack.