15 #ifndef LLVM_CLANG_AST_DECLTEMPLATE_H 16 #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;
55 class UnresolvedSetImpl;
56 class VarTemplateDecl;
57 class VarTemplatePartialSpecializationDecl;
61 llvm::PointerUnion3<TemplateTypeParmDecl *, NonTypeTemplateParmDecl *,
79 unsigned NumParams : 30;
83 unsigned ContainsUnexpandedParameterPack : 1;
86 unsigned HasRequiresClause : 1;
91 Expr *RequiresClause);
98 return HasRequiresClause;
102 template <
size_t N,
bool HasRequiresClause>
111 Expr *RequiresClause);
124 unsigned size()
const {
return NumParams; }
127 return llvm::makeArrayRef(
begin(),
end());
130 return llvm::makeArrayRef(
begin(),
size());
134 assert(Idx <
size() &&
"Template parameter index out-of-range");
138 assert(Idx <
size() &&
"Template parameter index out-of-range");
159 return ContainsUnexpandedParameterPack;
164 return HasRequiresClause ? *getTrailingObjects<Expr *>() :
nullptr;
169 return HasRequiresClause ? *getTrailingObjects<Expr *>() :
nullptr;
188 template <
size_t N,
bool HasRequiresClause>
191 typename TemplateParameterList::FixedSizeStorage<
193 N, HasRequiresClause ? 1u : 0u
201 Expr *RequiresClause)
203 (assert(N == Params.
size()),
204 assert(HasRequiresClause == static_cast<
bool>(RequiresClause)),
206 TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
217 unsigned NumArguments;
243 : Arguments(Args.data()), NumArguments(Args.
size()) {}
252 : Arguments(Other->data()), NumArguments(Other->
size()) {}
256 assert(Idx < NumArguments &&
"Invalid template argument index");
265 return llvm::makeArrayRef(data(),
size());
270 unsigned size()
const {
return NumArguments; }
286 template<
typename ParmDecl,
typename ArgType>
292 ParmDecl *PrevDeclWithDefaultArg;
295 static_assert(
sizeof(Chain) ==
sizeof(
void *) * 2,
296 "non-pointer argument type?");
298 llvm::PointerUnion3<ArgType, ParmDecl*, Chain*> ValueOrInherited;
300 static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
302 if (
auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
304 assert(!Parm->getDefaultArgStorage()
305 .ValueOrInherited.template is<ParmDecl *>() &&
306 "should only be one level of indirection");
314 bool isSet()
const {
return !ValueOrInherited.isNull(); }
318 bool isInherited()
const {
return ValueOrInherited.template is<ParmDecl*>(); }
322 ArgType
get()
const {
324 if (
const auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl *>())
325 Storage = &Prev->getDefaultArgStorage();
326 if (
const auto *C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
328 return Storage->ValueOrInherited.template get<ArgType>();
334 if (
const auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>())
336 if (
const auto *C = ValueOrInherited.template dyn_cast<Chain *>())
337 return C->PrevDeclWithDefaultArg;
342 void set(ArgType Arg) {
343 assert(!isSet() &&
"default argument already set");
344 ValueOrInherited = Arg;
349 assert(!isInherited() &&
"default argument already inherited");
350 InheritedFrom = getParmOwningDefaultArg(InheritedFrom);
352 ValueOrInherited = InheritedFrom;
355 Chain{InheritedFrom, ValueOrInherited.template get<ArgType>()};
360 ValueOrInherited = ArgType();
377 return TemplateParams;
384 TemplateParams = TParams;
390 Expr *AssociatedConstraints =
nullptr;
400 void anchor()
override;
408 :
NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),
409 TemplateParams(CTDI) {
410 this->setTemplateParameters(Params);
421 :
NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl),
422 TemplateParams(CTDI) {
423 this->setTemplateParameters(Params);
428 :
TemplateDecl(nullptr, DK, DC, L, Name, Params, Decl) {}
433 const auto *
const CTDI =
447 const auto *
const CTDI =
459 return K >= firstTemplate && K <= lastTemplate;
464 TemplatedDecl->getSourceRange().getEnd());
479 if (
auto *
const CTDI =
481 CTDI->setTemplateParameters(TParams);
483 TemplateParams = TParams;
488 assert(isCanonicalDecl() &&
489 "Attaching associated constraints to non-canonical Decl");
491 ->setAssociatedConstraints(AC);
497 void init(
NamedDecl *templatedDecl, TemplateParameterList* templateParams) {
498 assert(!TemplatedDecl &&
"TemplatedDecl already set!");
499 assert(!TemplateParams &&
"TemplateParams already set!");
500 TemplatedDecl = templatedDecl;
501 TemplateParams = templateParams;
515 : Function(FD), Template(Template, TSK - 1),
516 TemplateArguments(TemplateArgs),
517 TemplateArgumentsAsWritten(TemplateArgsAsWritten),
518 PointOfInstantiation(POI) {}
536 llvm::PointerIntPair<FunctionTemplateDecl *, 2>
Template;
572 "Cannot encode TSK_Undeclared for a function template specialization");
573 Template.setInt(TSK - 1);
582 return PointOfInstantiation;
588 PointOfInstantiation = POI;
592 Profile(ID, TemplateArguments->
asArray(),
599 ID.AddInteger(TemplateArgs.size());
601 TemplateArg.Profile(ID, Context);
611 llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
620 : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
622 "Cannot encode undeclared template specializations for members");
641 "Cannot encode undeclared template specializations for members");
642 MemberAndTSK.setInt(TSK - 1);
649 return PointOfInstantiation;
654 PointOfInstantiation = POI;
675 FunctionTemplateDecl *> {
677 unsigned NumTemplates;
709 assert(I < getNumTemplates() &&
"template index out of range");
710 return getTrailingObjects<FunctionTemplateDecl *>()[I];
715 return getTrailingObjects<TemplateArgumentLoc>();
723 assert(I < getNumTemplateArgs() &&
"template arg index out of range");
724 return getTemplateArgs()[I];
732 return AngleLocs.
getEnd();
743 return getNextRedeclaration();
747 return getPreviousDecl();
751 return getMostRecentDecl();
763 return D->getTemplateArgs().asArray();
767 template <
typename EntryType,
typename SETraits = SpecEntryTraits<EntryType>,
768 typename DeclType =
typename SETraits::DeclType>
770 : llvm::iterator_adaptor_base<
771 SpecIterator<EntryType, SETraits, DeclType>,
772 typename llvm::FoldingSetVector<EntryType>::iterator,
773 typename std::iterator_traits<typename llvm::FoldingSetVector<
774 EntryType>::iterator>::iterator_category,
775 DeclType *, ptrdiff_t, DeclType *, DeclType *> {
778 typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
782 return SETraits::getDecl(&*this->I)->getMostRecentDecl();
788 template <
typename EntryType>
794 void loadLazySpecializationsImpl()
const;
797 findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
800 template <
class Derived,
class EntryType>
801 void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
802 EntryType *Entry,
void *InsertPos);
812 llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
820 uint32_t *LazySpecializations =
nullptr;
851 template <
class decl_type>
friend class RedeclarableTemplate;
855 return getFirstDecl();
858 return getFirstDecl();
880 return getCommonPtr()->InstantiatedFromMember.getInt();
885 assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
886 "Only member templates can be member template specializations");
887 getCommonPtr()->InstantiatedFromMember.setInt(
true);
927 return getCommonPtr()->InstantiatedFromMember.getPointer();
931 assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
932 getCommonPtr()->InstantiatedFromMember.setPointer(TD);
938 using redeclarable_base::redecls_begin;
939 using redeclarable_base::redecls_end;
940 using redeclarable_base::redecls;
941 using redeclarable_base::getPreviousDecl;
942 using redeclarable_base::getMostRecentDecl;
943 using redeclarable_base::isFirstDecl;
949 return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate;
1005 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
1006 getSpecializations()
const;
1020 void LoadLazySpecializations()
const;
1030 return getTemplatedDecl()->isThisDeclarationADefinition();
1039 return cast<FunctionTemplateDecl>(
1043 return cast<FunctionTemplateDecl>(
1050 return cast_or_null<FunctionTemplateDecl>(
1054 return cast_or_null<FunctionTemplateDecl>(
1059 return cast<FunctionTemplateDecl>(
1061 ->getMostRecentDecl());
1068 return cast_or_null<FunctionTemplateDecl>(
1080 return makeSpecIterator(getSpecializations(),
false);
1084 return makeSpecIterator(getSpecializations(),
true);
1172 :
TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename) {}
1178 unsigned D,
unsigned P,
1180 bool ParameterPack);
1181 static TemplateTypeParmDecl *CreateDeserialized(
const ASTContext &C,
1198 return DefaultArgument.
get()->getType();
1203 return DefaultArgument.
get();
1217 DefaultArgument.
set(DefArg);
1223 TemplateTypeParmDecl *Prev) {
1229 DefaultArgument.
clear();
1240 unsigned getIndex()
const;
1243 bool isParameterPack()
const;
1257 class NonTypeTemplateParmDecl final
1261 std::pair<QualType, TypeSourceInfo *>> {
1279 bool ExpandedParameterPack =
false;
1282 unsigned NumExpandedTypes = 0;
1285 OverloadToken<std::pair<QualType, TypeSourceInfo *>>)
const {
1286 return NumExpandedTypes;
1293 :
DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
1304 static NonTypeTemplateParmDecl *
1309 static NonTypeTemplateParmDecl *
1315 static NonTypeTemplateParmDecl *CreateDeserialized(
ASTContext &C,
1317 static NonTypeTemplateParmDecl *CreateDeserialized(
ASTContext &C,
1319 unsigned NumExpandedTypes);
1352 NonTypeTemplateParmDecl *Parm) {
1408 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1409 return NumExpandedTypes;
1415 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1416 auto TypesAndInfos =
1417 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1418 return TypesAndInfos[I].first;
1424 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1425 auto TypesAndInfos =
1426 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1427 return TypesAndInfos[I].second;
1446 TemplateParameterList *> {
1450 DefArgStorage DefaultArgument;
1458 bool ExpandedParameterPack =
false;
1461 unsigned NumExpandedParams = 0;
1464 unsigned D,
unsigned P,
bool ParameterPack,
1466 :
TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
1470 unsigned D,
unsigned P,
1474 void anchor()
override;
1483 unsigned P,
bool ParameterPack,
1497 unsigned NumExpansions);
1518 return ParameterPack &&
1519 getTemplateParameters()->containsUnexpandedParameterPack();
1545 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1546 return NumExpandedParams;
1552 assert(I < NumExpandedParams &&
"Out-of-range expansion type index");
1553 return getTrailingObjects<TemplateParameterList *>()[I];
1565 return DefaultArgument.
isSet() ? *DefaultArgument.
get() :
None;
1592 if (hasDefaultArgument() && !defaultArgumentWasInherited())
1593 End = getDefaultArgument().getSourceRange().getEnd();
1611 void anchor()
override;
1649 struct SpecializedPartialSpecialization {
1660 llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1661 SpecializedTemplate;
1664 struct ExplicitSpecializationInfo {
1674 ExplicitSpecializationInfo() =
default;
1679 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
1689 unsigned SpecializationKind : 3;
1714 void getNameForDiagnostic(raw_ostream &OS,
const PrintingPolicy &Policy,
1715 bool Qualified)
const override;
1723 return cast<ClassTemplateSpecializationDecl>(
1724 getMostRecentNonInjectedDecl());
1733 return *TemplateArgs;
1755 SpecializationKind = TSK;
1760 return PointOfInstantiation;
1764 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
1765 PointOfInstantiation = Loc;
1776 return llvm::PointerUnion<ClassTemplateDecl *,
1779 return getSpecializedTemplateOrPartial();
1784 llvm::PointerUnion<ClassTemplateDecl *,
1787 if (
const auto *PartialSpec =
1788 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1789 return PartialSpec->PartialSpecialization;
1791 return SpecializedTemplate.get<ClassTemplateDecl*>();
1806 if (
const auto *PartialSpec =
1807 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1808 return *PartialSpec->TemplateArgs;
1810 return getTemplateArgs();
1818 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
1819 "Already set to a class template partial specialization!");
1820 auto *PS =
new (getASTContext()) SpecializedPartialSpecialization();
1821 PS->PartialSpecialization = PartialSpec;
1822 PS->TemplateArgs = TemplateArgs;
1823 SpecializedTemplate = PS;
1829 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
1830 "Previously set to a class template partial specialization!");
1831 SpecializedTemplate = TemplDecl;
1838 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1839 ExplicitInfo->TypeAsWritten = T;
1845 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
1850 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
1856 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1857 ExplicitInfo->ExternLoc = Loc;
1863 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1864 ExplicitInfo->TemplateKeywordLoc = Loc;
1869 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
1875 Profile(ID, TemplateArgs->
asArray(), getASTContext());
1881 ID.AddInteger(TemplateArgs.size());
1883 TemplateArg.Profile(ID, Context);
1889 return K >= firstClassTemplateSpecialization &&
1890 K <= lastClassTemplateSpecialization;
1908 llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
1909 InstantiatedFromMember;
1923 InstantiatedFromMember(
nullptr,
false) {}
1925 void anchor()
override;
1945 return cast<ClassTemplatePartialSpecializationDecl>(
1947 this)->getMostRecentDecl());
1952 return TemplateParams;
1957 return ArgsAsWritten;
1982 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
1983 return First->InstantiatedFromMember.getPointer();
1987 return getInstantiatedFromMember();
1992 auto *
First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
1993 First->InstantiatedFromMember.setPointer(PartialSpec);
2014 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2015 return First->InstantiatedFromMember.getInt();
2020 auto *
First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2021 assert(
First->InstantiatedFromMember.getPointer() &&
2022 "Only member templates can be member template specializations");
2023 return First->InstantiatedFromMember.setInt(
true);
2030 assert(getTypeForDecl() &&
"partial specialization has no type set!");
2031 return cast<InjectedClassNameType>(getTypeForDecl())
2032 ->getInjectedSpecializationType();
2040 return K == ClassTemplatePartialSpecialization;
2056 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>
2066 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
2067 getSpecializations()
const;
2071 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
2072 getPartialSpecializations();
2096 void LoadLazySpecializations()
const;
2106 return getTemplatedDecl()->isThisDeclarationADefinition();
2116 Expr *AssociatedConstraints =
nullptr);
2131 return cast<ClassTemplateDecl>(
2135 return cast<ClassTemplateDecl>(
2142 return cast_or_null<ClassTemplateDecl>(
2146 return cast_or_null<ClassTemplateDecl>(
2148 this)->getPreviousDecl());
2152 return cast<ClassTemplateDecl>(
2160 return cast_or_null<ClassTemplateDecl>(
2175 void getPartialSpecializations(
2197 findPartialSpecInstantiatedFromMember(
2214 QualType getInjectedClassNameSpecialization();
2224 return makeSpecIterator(getSpecializations(),
false);
2228 return makeSpecIterator(getSpecializations(),
true);
2250 virtual void anchor();
2257 unsigned NumParams = 0;
2271 :
Decl(
Decl::FriendTemplate, DC, Loc), NumParams(Params.
size()),
2272 Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
2306 assert(i <= NumParams);
2352 return cast<TypeAliasTemplateDecl>(
2356 return cast<TypeAliasTemplateDecl>(
2363 return cast_or_null<TypeAliasTemplateDecl>(
2367 return cast_or_null<TypeAliasTemplateDecl>(
2369 this)->getPreviousDecl());
2373 return cast_or_null<TypeAliasTemplateDecl>(
2410 bool HasExplicitTemplateArgs;
2416 :
Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc),
2417 Specialization(FD), HasExplicitTemplateArgs(Args),
2418 TemplateArgs(std::move(TemplArgs)) {}
2421 :
Decl(Decl::ClassScopeFunctionSpecialization, Empty) {}
2423 virtual void anchor();
2437 bool HasExplicitTemplateArgs,
2440 DC, Loc, FD, HasExplicitTemplateArgs, std::move(TemplateArgs));
2450 return K == Decl::ClassScopeFunctionSpecialization;
2472 public llvm::FoldingSetNode {
2477 struct SpecializedPartialSpecialization {
2488 llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2489 SpecializedTemplate;
2492 struct ExplicitSpecializationInfo {
2502 ExplicitSpecializationInfo() =
default;
2507 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
2518 unsigned SpecializationKind : 3;
2524 unsigned IsCompleteDefinition : 1;
2549 void getNameForDiagnostic(raw_ostream &OS,
const PrintingPolicy &Policy,
2550 bool Qualified)
const override;
2553 VarDecl *Recent =
static_cast<VarDecl *
>(
this)->getMostRecentDecl();
2554 return cast<VarTemplateSpecializationDecl>(Recent);
2568 return TemplateArgsInfo;
2590 SpecializationKind = TSK;
2595 return PointOfInstantiation;
2599 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
2600 PointOfInstantiation = Loc;
2609 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2615 return getSpecializedTemplateOrPartial();
2620 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2622 if (
const auto *PartialSpec =
2623 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2624 return PartialSpec->PartialSpecialization;
2641 if (
const auto *PartialSpec =
2642 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2643 return *PartialSpec->TemplateArgs;
2645 return getTemplateArgs();
2653 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2654 "Already set to a variable template partial specialization!");
2655 auto *PS =
new (getASTContext()) SpecializedPartialSpecialization();
2656 PS->PartialSpecialization = PartialSpec;
2657 PS->TemplateArgs = TemplateArgs;
2658 SpecializedTemplate = PS;
2664 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2665 "Previously set to a variable template partial specialization!");
2666 SpecializedTemplate = TemplDecl;
2673 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2674 ExplicitInfo->TypeAsWritten = T;
2680 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2685 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2691 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2692 ExplicitInfo->ExternLoc = Loc;
2698 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2699 ExplicitInfo->TemplateKeywordLoc = Loc;
2704 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2708 Profile(ID, TemplateArgs->
asArray(), getASTContext());
2714 ID.AddInteger(TemplateArgs.size());
2716 TemplateArg.Profile(ID, Context);
2722 return K >= firstVarTemplateSpecialization &&
2723 K <= lastVarTemplateSpecialization;
2741 llvm::PointerIntPair<VarTemplatePartialSpecializationDecl *, 1, bool>
2742 InstantiatedFromMember;
2754 InstantiatedFromMember(
nullptr,
false) {}
2756 void anchor()
override;
2773 return cast<VarTemplatePartialSpecializationDecl>(
2775 this)->getMostRecentDecl());
2780 return TemplateParams;
2785 return ArgsAsWritten;
2810 cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2811 return First->InstantiatedFromMember.getPointer();
2816 auto *
First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2817 First->InstantiatedFromMember.setPointer(PartialSpec);
2838 cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2839 return First->InstantiatedFromMember.getInt();
2844 auto *
First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2845 assert(
First->InstantiatedFromMember.getPointer() &&
2846 "Only member templates can be member template specializations");
2847 return First->InstantiatedFromMember.setInt(
true);
2853 return K == VarTemplatePartialSpecialization;
2869 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>
2876 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
2877 getSpecializations()
const;
2881 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
2882 getPartialSpecializations();
2900 void LoadLazySpecializations()
const;
2904 return static_cast<VarDecl *
>(TemplatedDecl);
2910 return getTemplatedDecl()->isThisDeclarationADefinition();
2943 return cast_or_null<VarTemplateDecl>(
2947 return cast_or_null<VarTemplateDecl>(
2949 this)->getPreviousDecl());
2953 return cast<VarTemplateDecl>(
2961 return cast_or_null<VarTemplateDecl>(
2976 void getPartialSpecializations(
3000 return makeSpecIterator(getSpecializations(),
false);
3004 return makeSpecIterator(getSpecializations(),
true);
3013 if (
auto *PD = P.dyn_cast<TemplateTypeParmDecl *>())
3015 if (
auto *PD = P.dyn_cast<NonTypeTemplateParmDecl *>())
3022 return TD && (isa<ClassTemplateDecl>(TD) ||
3023 isa<ClassTemplatePartialSpecializationDecl>(TD) ||
3024 isa<TypeAliasTemplateDecl>(TD) ||
3025 isa<TemplateTemplateParmDecl>(TD))
3032 #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...
static const Decl * getCanonicalDecl(const Decl *D)
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.
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
RedeclarableTemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
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.
FunctionDecl * Function
The function template specialization that this structure describes.
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.
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
static ClassTemplateDecl * getDefinition(ClassTemplateDecl *D)
VarTemplateSpecializationDecl * getMostRecentDecl()
ArrayRef< const NamedDecl * > asArray() 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.
FixedSizeTemplateParameterListStorage(SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
C Language Family Type Representation.
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, TemplateArgumentListInfo TemplateArgs)
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.
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.
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.
constexpr XRayInstrMask Function
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
const Expr * getRequiresClause() const
Get the constraint-expression from the associated requires-clause (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.
TemplateParameterList * getTemplateParameters() const
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.
llvm::PointerUnion< TemplateParameterList *, ConstrainedTemplateDeclInfo * > TemplateParams
The template parameter list and optional requires-clause associated with this declaration; alternativ...
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)
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 ...
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.
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)
Stores the template parameter list and associated constraints for TemplateDecl objects that track ass...
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. ...
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.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
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.
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
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
Expr - This represents one expression.
void setCompleteDefinition()
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template.
void setAssociatedConstraints(Expr *AC)
const VarTemplateDecl * getPreviousDecl() const
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
Expr * getAssociatedConstraints() const
void setInherited(const ASTContext &C, ParmDecl *InheritedFrom)
Set that the default argument was inherited from another parameter.
static bool classof(const Decl *D)
void setAssociatedConstraints(Expr *AC)
MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, SourceLocation POI=SourceLocation())
llvm::PointerIntPair< FunctionTemplateDecl *, 2 > Template
The function template from which this function template specialization was generated.
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
static bool classof(const Decl *D)
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.
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
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)
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.
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.
const TemplateArgumentListInfo & templateArgs() const
ASTContext & getASTContext() const LLVM_READONLY
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.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
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.
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.
void setPointOfInstantiation(SourceLocation Loc)
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
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.
TemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
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.
TemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params)
Defines various enumerations that describe declaration and type specifiers.
Represents a template argument.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
TagTypeKind
The kind of a tag type.
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.
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.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
unsigned getNumTemplateParameters() const
DeclarationName - The name of a declaration.
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
void setTemplateParameters(TemplateParameterList *TParams)
llvm::iterator_range< redecl_iterator > redecl_range
Storage for a default argument.
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...
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)
ClassTemplateDecl(ConstrainedTemplateDeclInfo *CTDI, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *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)
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
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.
TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
TypeAliasTemplateDecl * getInstantiatedFromMemberTemplate() const
Provides information a specialization of a member of a class template, which may be a member function...
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
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...
Expr * getAssociatedConstraints() const
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
void setTemplateParameters(TemplateParameterList *TParams)
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...
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.
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.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
FunctionTemplateDecl * getMostRecentDecl()
TemplateArgumentList(OnStackType, ArrayRef< TemplateArgument > Args)
Construct a new, temporary template argument list on the stack.