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 (
auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl*>())
325 Storage = &Prev->getDefaultArgStorage();
326 if (
auto *C = Storage->ValueOrInherited.template dyn_cast<Chain*>())
328 return Storage->ValueOrInherited.template get<ArgType>();
334 if (
auto *D = ValueOrInherited.template dyn_cast<ParmDecl*>())
336 if (
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());
478 if (
auto *
const CTDI =
480 CTDI->setTemplateParameters(TParams);
482 TemplateParams = TParams;
487 assert(isCanonicalDecl() &&
488 "Attaching associated constraints to non-canonical Decl");
490 ->setAssociatedConstraints(AC);
496 void init(
NamedDecl *templatedDecl, TemplateParameterList* templateParams) {
497 assert(!TemplatedDecl &&
"TemplatedDecl already set!");
498 assert(!TemplateParams &&
"TemplateParams already set!");
499 TemplatedDecl = templatedDecl;
500 TemplateParams = templateParams;
514 : Function(FD), Template(Template, TSK - 1),
515 TemplateArguments(TemplateArgs),
516 TemplateArgumentsAsWritten(TemplateArgsAsWritten),
517 PointOfInstantiation(POI) {}
535 llvm::PointerIntPair<FunctionTemplateDecl *, 2>
Template;
571 "Cannot encode TSK_Undeclared for a function template specialization");
572 Template.setInt(TSK - 1);
581 return PointOfInstantiation;
587 PointOfInstantiation = POI;
591 Profile(ID, TemplateArguments->
asArray(),
598 ID.AddInteger(TemplateArgs.size());
600 TemplateArg.Profile(ID, Context);
610 llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
619 : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
621 "Cannot encode undeclared template specializations for members");
640 "Cannot encode undeclared template specializations for members");
641 MemberAndTSK.setInt(TSK - 1);
648 return PointOfInstantiation;
653 PointOfInstantiation = POI;
674 FunctionTemplateDecl *> {
676 unsigned NumTemplates;
708 assert(I < getNumTemplates() &&
"template index out of range");
709 return getTrailingObjects<FunctionTemplateDecl *>()[I];
714 return getTrailingObjects<TemplateArgumentLoc>();
722 assert(I < getNumTemplateArgs() &&
"template arg index out of range");
723 return getTemplateArgs()[I];
731 return AngleLocs.
getEnd();
742 return getNextRedeclaration();
746 return getPreviousDecl();
750 return getMostRecentDecl();
762 return D->getTemplateArgs().asArray();
766 template <
typename EntryType,
typename SETraits = SpecEntryTraits<EntryType>,
767 typename DeclType =
typename SETraits::DeclType>
769 : llvm::iterator_adaptor_base<
770 SpecIterator<EntryType, SETraits, DeclType>,
771 typename llvm::FoldingSetVector<EntryType>::iterator,
772 typename std::iterator_traits<typename llvm::FoldingSetVector<
773 EntryType>::iterator>::iterator_category,
774 DeclType *, ptrdiff_t, DeclType *, DeclType *> {
777 typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
781 return SETraits::getDecl(&*this->I)->getMostRecentDecl();
787 template <
typename EntryType>
793 void loadLazySpecializationsImpl()
const;
796 findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
799 template <
class Derived,
class EntryType>
800 void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
801 EntryType *Entry,
void *InsertPos);
811 llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
819 uint32_t *LazySpecializations =
nullptr;
850 template <
class decl_type>
friend class RedeclarableTemplate;
854 return getFirstDecl();
857 return getFirstDecl();
879 return getCommonPtr()->InstantiatedFromMember.getInt();
884 assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
885 "Only member templates can be member template specializations");
886 getCommonPtr()->InstantiatedFromMember.setInt(
true);
926 return getCommonPtr()->InstantiatedFromMember.getPointer();
930 assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
931 getCommonPtr()->InstantiatedFromMember.setPointer(TD);
937 using redeclarable_base::redecls_begin;
938 using redeclarable_base::redecls_end;
939 using redeclarable_base::redecls;
940 using redeclarable_base::getPreviousDecl;
941 using redeclarable_base::getMostRecentDecl;
942 using redeclarable_base::isFirstDecl;
948 return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate;
1004 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
1005 getSpecializations()
const;
1019 void LoadLazySpecializations()
const;
1029 return getTemplatedDecl()->isThisDeclarationADefinition();
1038 return cast<FunctionTemplateDecl>(
1042 return cast<FunctionTemplateDecl>(
1049 return cast_or_null<FunctionTemplateDecl>(
1053 return cast_or_null<FunctionTemplateDecl>(
1058 return cast<FunctionTemplateDecl>(
1060 ->getMostRecentDecl());
1067 return cast_or_null<FunctionTemplateDecl>(
1079 return makeSpecIterator(getSpecializations(),
false);
1083 return makeSpecIterator(getSpecializations(),
true);
1171 :
TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename) {}
1177 unsigned D,
unsigned P,
1179 bool ParameterPack);
1180 static TemplateTypeParmDecl *CreateDeserialized(
const ASTContext &C,
1197 return DefaultArgument.
get()->getType();
1202 return DefaultArgument.
get();
1216 DefaultArgument.
set(DefArg);
1222 TemplateTypeParmDecl *Prev) {
1228 DefaultArgument.
clear();
1239 unsigned getIndex()
const;
1242 bool isParameterPack()
const;
1256 class NonTypeTemplateParmDecl final
1260 std::pair<QualType, TypeSourceInfo *>> {
1278 bool ExpandedParameterPack =
false;
1281 unsigned NumExpandedTypes = 0;
1284 OverloadToken<std::pair<QualType, TypeSourceInfo *>>)
const {
1285 return NumExpandedTypes;
1292 :
DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
1303 static NonTypeTemplateParmDecl *
1308 static NonTypeTemplateParmDecl *
1314 static NonTypeTemplateParmDecl *CreateDeserialized(
ASTContext &C,
1316 static NonTypeTemplateParmDecl *CreateDeserialized(
ASTContext &C,
1318 unsigned NumExpandedTypes);
1351 NonTypeTemplateParmDecl *Parm) {
1407 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1408 return NumExpandedTypes;
1414 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1415 auto TypesAndInfos =
1416 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1417 return TypesAndInfos[I].first;
1423 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1424 auto TypesAndInfos =
1425 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1426 return TypesAndInfos[I].second;
1445 TemplateParameterList *> {
1449 DefArgStorage DefaultArgument;
1457 bool ExpandedParameterPack =
false;
1460 unsigned NumExpandedParams = 0;
1463 unsigned D,
unsigned P,
bool ParameterPack,
1465 :
TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
1469 unsigned D,
unsigned P,
1473 void anchor()
override;
1482 unsigned P,
bool ParameterPack,
1496 unsigned NumExpansions);
1517 return ParameterPack &&
1518 getTemplateParameters()->containsUnexpandedParameterPack();
1544 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1545 return NumExpandedParams;
1551 assert(I < NumExpandedParams &&
"Out-of-range expansion type index");
1552 return getTrailingObjects<TemplateParameterList *>()[I];
1564 return DefaultArgument.
isSet() ? *DefaultArgument.
get() :
None;
1591 if (hasDefaultArgument() && !defaultArgumentWasInherited())
1592 End = getDefaultArgument().getSourceRange().getEnd();
1610 void anchor()
override;
1648 struct SpecializedPartialSpecialization {
1659 llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1660 SpecializedTemplate;
1663 struct ExplicitSpecializationInfo {
1673 ExplicitSpecializationInfo() =
default;
1678 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
1688 unsigned SpecializationKind : 3;
1713 void getNameForDiagnostic(raw_ostream &OS,
const PrintingPolicy &Policy,
1714 bool Qualified)
const override;
1723 this)->getMostRecentDecl();
1724 while (!isa<ClassTemplateSpecializationDecl>(Recent)) {
1729 return cast<ClassTemplateSpecializationDecl>(Recent);
1738 return *TemplateArgs;
1760 SpecializationKind = TSK;
1765 return PointOfInstantiation;
1769 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
1770 PointOfInstantiation = Loc;
1781 return llvm::PointerUnion<ClassTemplateDecl *,
1784 return getSpecializedTemplateOrPartial();
1789 llvm::PointerUnion<ClassTemplateDecl *,
1792 if (SpecializedPartialSpecialization *PartialSpec
1793 = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
1794 return PartialSpec->PartialSpecialization;
1796 return SpecializedTemplate.get<ClassTemplateDecl*>();
1811 if (SpecializedPartialSpecialization *PartialSpec
1812 = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
1813 return *PartialSpec->TemplateArgs;
1815 return getTemplateArgs();
1823 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
1824 "Already set to a class template partial specialization!");
1825 SpecializedPartialSpecialization *PS
1826 =
new (getASTContext()) SpecializedPartialSpecialization();
1827 PS->PartialSpecialization = PartialSpec;
1828 PS->TemplateArgs = TemplateArgs;
1829 SpecializedTemplate = PS;
1835 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
1836 "Previously set to a class template partial specialization!");
1837 SpecializedTemplate = TemplDecl;
1844 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1845 ExplicitInfo->TypeAsWritten =
T;
1851 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
1856 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
1862 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1863 ExplicitInfo->ExternLoc = Loc;
1869 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1870 ExplicitInfo->TemplateKeywordLoc = Loc;
1875 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
1881 Profile(ID, TemplateArgs->
asArray(), getASTContext());
1887 ID.AddInteger(TemplateArgs.size());
1889 TemplateArg.Profile(ID, Context);
1895 return K >= firstClassTemplateSpecialization &&
1896 K <= lastClassTemplateSpecialization;
1914 llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
1915 InstantiatedFromMember;
1929 InstantiatedFromMember(
nullptr,
false) {}
1931 void anchor()
override;
1951 return cast<ClassTemplatePartialSpecializationDecl>(
1953 this)->getMostRecentDecl());
1958 return TemplateParams;
1963 return ArgsAsWritten;
1988 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
1989 return First->InstantiatedFromMember.getPointer();
1993 return getInstantiatedFromMember();
1999 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2000 First->InstantiatedFromMember.setPointer(PartialSpec);
2021 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2022 return First->InstantiatedFromMember.getInt();
2028 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2029 assert(First->InstantiatedFromMember.getPointer() &&
2030 "Only member templates can be member template specializations");
2031 return First->InstantiatedFromMember.setInt(
true);
2038 assert(getTypeForDecl() &&
"partial specialization has no type set!");
2039 return cast<InjectedClassNameType>(getTypeForDecl())
2040 ->getInjectedSpecializationType();
2048 return K == ClassTemplatePartialSpecialization;
2064 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>
2074 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
2075 getSpecializations()
const;
2079 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
2080 getPartialSpecializations();
2104 void LoadLazySpecializations()
const;
2114 return getTemplatedDecl()->isThisDeclarationADefinition();
2124 Expr *AssociatedConstraints =
nullptr);
2139 return cast<ClassTemplateDecl>(
2143 return cast<ClassTemplateDecl>(
2150 return cast_or_null<ClassTemplateDecl>(
2154 return cast_or_null<ClassTemplateDecl>(
2156 this)->getPreviousDecl());
2160 return cast<ClassTemplateDecl>(
2168 return cast_or_null<ClassTemplateDecl>(
2183 void getPartialSpecializations(
2205 findPartialSpecInstantiatedFromMember(
2222 QualType getInjectedClassNameSpecialization();
2232 return makeSpecIterator(getSpecializations(),
false);
2236 return makeSpecIterator(getSpecializations(),
true);
2258 virtual void anchor();
2265 unsigned NumParams = 0;
2279 :
Decl(
Decl::FriendTemplate, DC, Loc), NumParams(Params.
size()),
2280 Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
2314 assert(i <= NumParams);
2360 return cast<TypeAliasTemplateDecl>(
2364 return cast<TypeAliasTemplateDecl>(
2371 return cast_or_null<TypeAliasTemplateDecl>(
2375 return cast_or_null<TypeAliasTemplateDecl>(
2377 this)->getPreviousDecl());
2381 return cast_or_null<TypeAliasTemplateDecl>(
2418 bool HasExplicitTemplateArgs;
2424 :
Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc),
2425 Specialization(FD), HasExplicitTemplateArgs(Args),
2426 TemplateArgs(std::move(TemplArgs)) {}
2429 :
Decl(Decl::ClassScopeFunctionSpecialization, Empty) {}
2431 virtual void anchor();
2445 bool HasExplicitTemplateArgs,
2448 DC, Loc, FD, HasExplicitTemplateArgs, std::move(TemplateArgs));
2458 return K == Decl::ClassScopeFunctionSpecialization;
2480 public llvm::FoldingSetNode {
2485 struct SpecializedPartialSpecialization {
2496 llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2497 SpecializedTemplate;
2500 struct ExplicitSpecializationInfo {
2510 ExplicitSpecializationInfo() =
default;
2515 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
2526 unsigned SpecializationKind : 3;
2532 unsigned IsCompleteDefinition : 1;
2557 void getNameForDiagnostic(raw_ostream &OS,
const PrintingPolicy &Policy,
2558 bool Qualified)
const override;
2561 VarDecl *Recent =
static_cast<VarDecl *
>(
this)->getMostRecentDecl();
2562 return cast<VarTemplateSpecializationDecl>(Recent);
2576 return TemplateArgsInfo;
2598 SpecializationKind = TSK;
2603 return PointOfInstantiation;
2607 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
2608 PointOfInstantiation = Loc;
2617 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2623 return getSpecializedTemplateOrPartial();
2628 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2630 if (SpecializedPartialSpecialization *PartialSpec =
2631 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2632 return PartialSpec->PartialSpecialization;
2649 if (SpecializedPartialSpecialization *PartialSpec =
2650 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2651 return *PartialSpec->TemplateArgs;
2653 return getTemplateArgs();
2661 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2662 "Already set to a variable template partial specialization!");
2663 SpecializedPartialSpecialization *PS =
2664 new (getASTContext()) SpecializedPartialSpecialization();
2665 PS->PartialSpecialization = PartialSpec;
2666 PS->TemplateArgs = TemplateArgs;
2667 SpecializedTemplate = PS;
2673 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2674 "Previously set to a variable template partial specialization!");
2675 SpecializedTemplate = TemplDecl;
2682 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2683 ExplicitInfo->TypeAsWritten =
T;
2689 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2694 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2700 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2701 ExplicitInfo->ExternLoc = Loc;
2707 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
2708 ExplicitInfo->TemplateKeywordLoc = Loc;
2713 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2717 Profile(ID, TemplateArgs->
asArray(), getASTContext());
2723 ID.AddInteger(TemplateArgs.size());
2725 TemplateArg.Profile(ID, Context);
2731 return K >= firstVarTemplateSpecialization &&
2732 K <= lastVarTemplateSpecialization;
2750 llvm::PointerIntPair<VarTemplatePartialSpecializationDecl *, 1, bool>
2751 InstantiatedFromMember;
2763 InstantiatedFromMember(
nullptr,
false) {}
2765 void anchor()
override;
2782 return cast<VarTemplatePartialSpecializationDecl>(
2784 this)->getMostRecentDecl());
2789 return TemplateParams;
2794 return ArgsAsWritten;
2819 cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2820 return First->InstantiatedFromMember.getPointer();
2826 cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2827 First->InstantiatedFromMember.setPointer(PartialSpec);
2848 cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2849 return First->InstantiatedFromMember.getInt();
2855 cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2856 assert(First->InstantiatedFromMember.getPointer() &&
2857 "Only member templates can be member template specializations");
2858 return First->InstantiatedFromMember.setInt(
true);
2864 return K == VarTemplatePartialSpecialization;
2880 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>
2887 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
2888 getSpecializations()
const;
2892 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
2893 getPartialSpecializations();
2911 void LoadLazySpecializations()
const;
2915 return static_cast<VarDecl *
>(TemplatedDecl);
2921 return getTemplatedDecl()->isThisDeclarationADefinition();
2954 return cast_or_null<VarTemplateDecl>(
2958 return cast_or_null<VarTemplateDecl>(
2960 this)->getPreviousDecl());
2964 return cast<VarTemplateDecl>(
2972 return cast_or_null<VarTemplateDecl>(
2987 void getPartialSpecializations(
3011 return makeSpecIterator(getSpecializations(),
false);
3015 return makeSpecIterator(getSpecializations(),
true);
3024 if (
auto *PD = P.dyn_cast<TemplateTypeParmDecl*>())
3026 if (
auto *PD = P.dyn_cast<NonTypeTemplateParmDecl*>())
3033 return TD && (isa<ClassTemplateDecl>(TD) ||
3034 isa<ClassTemplatePartialSpecializationDecl>(TD) ||
3035 isa<TypeAliasTemplateDecl>(TD) ||
3036 isa<TemplateTemplateParmDecl>(TD))
3043 #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
An instance of this class is created to represent 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.
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.
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.
VarDecl - An instance of this class is created to represent 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)
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.
CXXRecordDecl * getPreviousDecl()
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)
TypeDecl - 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...
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x 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)
const FunctionProtoType * T
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.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
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.
NamedDecl - This represents a decl with 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.