15 #ifndef LLVM_CLANG_AST_DECLTEMPLATE_H
16 #define LLVM_CLANG_AST_DECLTEMPLATE_H
21 #include "llvm/ADT/PointerUnion.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/TrailingObjects.h"
29 class TemplateParameterList;
31 class RedeclarableTemplateDecl;
32 class FunctionTemplateDecl;
33 class ClassTemplateDecl;
34 class ClassTemplatePartialSpecializationDecl;
35 class TemplateTypeParmDecl;
36 class NonTypeTemplateParmDecl;
37 class TemplateTemplateParmDecl;
38 class TypeAliasTemplateDecl;
39 class VarTemplateDecl;
62 unsigned NumParams : 30;
66 unsigned ContainsUnexpandedParameterPack : 1;
69 unsigned HasRequiresClause : 1;
77 return HasRequiresClause;
82 Expr *RequiresClause);
90 Expr *RequiresClause);
103 unsigned size()
const {
return NumParams; }
106 return llvm::makeArrayRef(
begin(),
end());
109 return llvm::makeArrayRef(
begin(),
size());
113 assert(Idx <
size() &&
"Template parameter index out-of-range");
118 assert(Idx <
size() &&
"Template parameter index out-of-range");
139 return ContainsUnexpandedParameterPack;
144 return HasRequiresClause ? *getTrailingObjects<Expr *>() :
nullptr;
149 return HasRequiresClause ? *getTrailingObjects<Expr *>() :
nullptr;
162 template <
size_t N,
bool HasRequiresClause>
173 template <
size_t N,
bool HasRequiresClause>
176 typename TemplateParameterList::FixedSizeStorage<
178 N, HasRequiresClause ? 1u : 0u
186 Expr *RequiresClause)
187 : FixedSizeStorageOwner(
188 (assert(N == Params.size()),
189 assert(HasRequiresClause == static_cast<
bool>(RequiresClause)),
191 TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
202 unsigned NumArguments;
226 : Arguments(Args.
data()), NumArguments(Args.
size()) {}
235 : Arguments(Other->
data()), NumArguments(Other->
size()) {}
239 assert(Idx < NumArguments &&
"Invalid template argument index");
248 return llvm::makeArrayRef(
data(),
size());
253 unsigned size()
const {
return NumArguments; }
271 template<
typename ParmDecl,
typename ArgType>
277 ParmDecl *PrevDeclWithDefaultArg;
280 static_assert(
sizeof(Chain) ==
sizeof(
void *) * 2,
281 "non-pointer argument type?");
283 llvm::PointerUnion3<ArgType, ParmDecl*, Chain*> ValueOrInherited;
285 static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
287 if (
auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl*>())
289 assert(!Parm->getDefaultArgStorage()
290 .ValueOrInherited.template is<ParmDecl *>() &&
291 "should only be one level of indirection");
299 bool isSet()
const {
return !ValueOrInherited.isNull(); }
302 bool isInherited()
const {
return ValueOrInherited.template is<ParmDecl*>(); }
305 ArgType
get()
const {
307 if (
auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl*>())
308 Storage = &Prev->getDefaultArgStorage();
309 if (
auto *C = Storage->ValueOrInherited.template dyn_cast<Chain*>())
311 return Storage->ValueOrInherited.template get<ArgType>();
316 if (
auto *D = ValueOrInherited.template dyn_cast<ParmDecl*>())
318 if (
auto *C = ValueOrInherited.template dyn_cast<Chain*>())
319 return C->PrevDeclWithDefaultArg;
324 assert(!
isSet() &&
"default argument already set");
325 ValueOrInherited = Arg;
329 assert(!
isInherited() &&
"default argument already inherited");
330 InheritedFrom = getParmOwningDefaultArg(InheritedFrom);
332 ValueOrInherited = InheritedFrom;
335 Chain{InheritedFrom, ValueOrInherited.template get<ArgType>()};
339 ValueOrInherited = ArgType();
356 return TemplateParams;
363 TemplateParams = TParams;
379 void anchor()
override;
387 TemplateParams(CTDI) {
388 this->setTemplateParameters(Params);
400 TemplateParams(CTDI) {
401 this->setTemplateParameters(Params);
406 :
TemplateDecl(nullptr, DK, DC, L, Name, Params, Decl) {}
411 const auto *
const CTDI =
425 const auto *
const CTDI =
436 return K >= firstTemplate && K <= lastTemplate;
440 return SourceRange(getTemplateParameters()->getTemplateLoc(),
441 TemplatedDecl.getPointer()->getSourceRange().getEnd());
445 bool isConcept()
const {
return TemplatedDecl.getInt(); }
465 if (
auto *
const CTDI =
467 CTDI->setTemplateParameters(TParams);
469 TemplateParams = TParams;
474 assert(isCanonicalDecl() &&
475 "Attaching associated constraints to non-canonical Decl");
477 ->setAssociatedConstraints(AC);
484 assert(!TemplatedDecl.getPointer() &&
"TemplatedDecl already set!");
485 assert(!TemplateParams &&
"TemplateParams already set!");
486 TemplatedDecl.setPointer(templatedDecl);
487 TemplateParams = templateParams;
502 Template(Template, TSK - 1),
503 TemplateArguments(TemplateArgs),
504 TemplateArgumentsAsWritten(TemplateArgsAsWritten),
505 PointOfInstantiation(POI) { }
523 llvm::PointerIntPair<FunctionTemplateDecl *, 2>
Template;
559 "Cannot encode TSK_Undeclared for a function template specialization");
560 Template.setInt(TSK - 1);
569 return PointOfInstantiation;
575 PointOfInstantiation = POI;
579 Profile(ID, TemplateArguments->asArray(),
580 Function->getASTContext());
586 ID.AddInteger(TemplateArgs.size());
588 TemplateArg.Profile(ID, Context);
598 llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
607 : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
609 "Cannot encode undeclared template specializations for members");
628 "Cannot encode undeclared template specializations for members");
629 MemberAndTSK.setInt(TSK - 1);
636 return PointOfInstantiation;
641 PointOfInstantiation = POI;
662 FunctionTemplateDecl *> {
664 unsigned NumTemplates;
672 size_t numTrailingObjects(OverloadToken<TemplateArgumentLoc>)
const {
675 size_t numTrailingObjects(OverloadToken<FunctionTemplateDecl *>)
const {
694 assert(I < getNumTemplates() &&
"template index out of range");
695 return getTrailingObjects<FunctionTemplateDecl *>()[I];
700 return getTrailingObjects<TemplateArgumentLoc>();
708 assert(I < getNumTemplateArgs() &&
"template arg index out of range");
709 return getTemplateArgs()[
I];
713 return AngleLocs.getBegin();
717 return AngleLocs.getEnd();
729 return getNextRedeclaration();
732 return getPreviousDecl();
735 return getMostRecentDecl();
746 return D->getTemplateArgs().asArray();
750 template <
typename EntryType,
typename SETraits = SpecEntryTraits<EntryType>,
751 typename DeclType =
typename SETraits::DeclType>
753 : llvm::iterator_adaptor_base<
754 SpecIterator<EntryType, SETraits, DeclType>,
755 typename llvm::FoldingSetVector<EntryType>::iterator,
756 typename std::iterator_traits<typename llvm::FoldingSetVector<
757 EntryType>::iterator>::iterator_category,
758 DeclType *, ptrdiff_t, DeclType *, DeclType *> {
761 typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
762 :
SpecIterator::iterator_adaptor_base(std::move(SetIter)) {}
765 return SETraits::getDecl(&*this->
I)->getMostRecentDecl();
770 template <
typename EntryType>
771 static SpecIterator<EntryType>
776 template <
class EntryType>
typename SpecEntryTraits<EntryType>::DeclType*
777 findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
780 template <
class Derived,
class EntryType>
781 void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
782 EntryType *Entry,
void *InsertPos);
792 llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
821 template <
class decl_type>
friend class RedeclarableTemplate;
825 return getFirstDecl();
828 return getFirstDecl();
850 return getCommonPtr()->InstantiatedFromMember.getInt();
855 assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
856 "Only member templates can be member template specializations");
857 getCommonPtr()->InstantiatedFromMember.setInt(
true);
897 return getCommonPtr()->InstantiatedFromMember.getPointer();
901 assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
902 getCommonPtr()->InstantiatedFromMember.setPointer(TD);
907 using redeclarable_base::redecls_begin;
908 using redeclarable_base::redecls_end;
909 using redeclarable_base::redecls;
910 using redeclarable_base::getPreviousDecl;
911 using redeclarable_base::getMostRecentDecl;
912 using redeclarable_base::isFirstDecl;
917 return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate;
944 Common() : InjectedArgs(), LazySpecializations() { }
983 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
984 getSpecializations()
const;
995 void LoadLazySpecializations()
const;
999 return static_cast<FunctionDecl *
>(TemplatedDecl.getPointer());
1005 return getTemplatedDecl()->isThisDeclarationADefinition();
1014 return cast<FunctionTemplateDecl>(
1018 return cast<FunctionTemplateDecl>(
1025 return cast_or_null<FunctionTemplateDecl>(
1032 return cast_or_null<FunctionTemplateDecl>(
1037 return cast<FunctionTemplateDecl>(
1039 ->getMostRecentDecl());
1046 return cast_or_null<FunctionTemplateDecl>(
1057 return makeSpecIterator(getSpecializations(),
false);
1061 return makeSpecIterator(getSpecializations(),
true);
1151 :
TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename),
1152 DefaultArgument() { }
1161 unsigned D,
unsigned P,
1163 bool ParameterPack);
1181 return DefaultArgument.get()->getType();
1186 return DefaultArgument.get();
1195 return DefaultArgument.isInherited();
1200 DefaultArgument.set(DefArg);
1206 DefaultArgument.setInherited(C, Prev);
1211 DefaultArgument.clear();
1219 unsigned getDepth()
const;
1222 unsigned getIndex()
const;
1225 bool isParameterPack()
const;
1230 static
bool classof(const
Decl *D) {
return classofKind(D->getKind()); }
1243 std::pair<QualType, TypeSourceInfo *>> {
1258 bool ExpandedParameterPack;
1261 unsigned NumExpandedTypes;
1263 size_t numTrailingObjects(
1264 OverloadToken<std::pair<QualType, TypeSourceInfo *>>)
const {
1265 return NumExpandedTypes;
1272 :
DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
1274 ExpandedParameterPack(
false), NumExpandedTypes(0)
1303 unsigned NumExpandedTypes);
1328 return DefaultArgument.isInherited();
1337 DefaultArgument.setInherited(C, Parm);
1392 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1393 return NumExpandedTypes;
1399 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1400 auto TypesAndInfos =
1401 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1402 return TypesAndInfos[
I].first;
1408 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1409 auto TypesAndInfos =
1410 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1411 return TypesAndInfos[
I].second;
1430 TemplateParameterList *> {
1431 void anchor()
override;
1444 bool ExpandedParameterPack;
1447 unsigned NumExpandedParams;
1450 unsigned D,
unsigned P,
bool ParameterPack,
1452 :
TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
1454 ExpandedParameterPack(
false), NumExpandedParams(0)
1458 unsigned D,
unsigned P,
1465 unsigned P,
bool ParameterPack,
1479 unsigned NumExpansions);
1500 return ParameterPack &&
1501 getTemplateParameters()->containsUnexpandedParameterPack();
1527 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1528 return NumExpandedParams;
1534 assert(I < NumExpandedParams &&
"Out-of-range expansion type index");
1535 return getTrailingObjects<TemplateParameterList *>()[I];
1547 return DefaultArgument.isSet() ? *DefaultArgument.get() :
None;
1556 return DefaultArgument.isInherited();
1566 DefaultArgument.setInherited(C, Prev);
1574 if (hasDefaultArgument() && !defaultArgumentWasInherited())
1575 End = getDefaultArgument().getSourceRange().getEnd();
1576 return SourceRange(getTemplateParameters()->getTemplateLoc(), End);
1592 void anchor()
override;
1636 struct SpecializedPartialSpecialization {
1647 llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1648 SpecializedTemplate;
1651 struct ExplicitSpecializationInfo {
1659 ExplicitSpecializationInfo()
1660 : TypeAsWritten(
nullptr), ExternLoc(), TemplateKeywordLoc() {}
1665 ExplicitSpecializationInfo *ExplicitInfo;
1675 unsigned SpecializationKind : 3;
1697 void getNameForDiagnostic(raw_ostream &OS,
const PrintingPolicy &Policy,
1698 bool Qualified)
const override;
1707 this)->getMostRecentDecl();
1708 while (!isa<ClassTemplateSpecializationDecl>(Recent)) {
1713 return cast<ClassTemplateSpecializationDecl>(Recent);
1722 return *TemplateArgs;
1744 SpecializationKind = TSK;
1749 return PointOfInstantiation;
1753 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
1754 PointOfInstantiation = Loc;
1768 return getSpecializedTemplateOrPartial();
1776 if (SpecializedPartialSpecialization *PartialSpec
1777 = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
1778 return PartialSpec->PartialSpecialization;
1795 if (SpecializedPartialSpecialization *PartialSpec
1796 = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
1797 return *PartialSpec->TemplateArgs;
1799 return getTemplateArgs();
1807 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
1808 "Already set to a class template partial specialization!");
1809 SpecializedPartialSpecialization *PS
1810 =
new (getASTContext()) SpecializedPartialSpecialization();
1811 PS->PartialSpecialization = PartialSpec;
1812 PS->TemplateArgs = TemplateArgs;
1813 SpecializedTemplate = PS;
1819 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
1820 "Previously set to a class template partial specialization!");
1821 SpecializedTemplate = TemplDecl;
1828 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1829 ExplicitInfo->TypeAsWritten = T;
1834 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
1839 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
1844 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1845 ExplicitInfo->ExternLoc = Loc;
1851 ExplicitInfo =
new (getASTContext()) ExplicitSpecializationInfo;
1852 ExplicitInfo->TemplateKeywordLoc = Loc;
1856 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
1861 void Profile(llvm::FoldingSetNodeID &ID)
const {
1862 Profile(ID, TemplateArgs->asArray(), getASTContext());
1868 ID.AddInteger(TemplateArgs.size());
1870 TemplateArg.Profile(ID, Context);
1875 return K >= firstClassTemplateSpecialization &&
1876 K <= lastClassTemplateSpecialization;
1885 void anchor()
override;
1899 llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
1900 InstantiatedFromMember;
1914 TemplateParams(
nullptr), ArgsAsWritten(
nullptr),
1915 InstantiatedFromMember(
nullptr,
false) {}
1932 return cast<ClassTemplatePartialSpecializationDecl>(
1934 this)->getMostRecentDecl());
1939 return TemplateParams;
1944 return ArgsAsWritten;
1969 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
1970 return First->InstantiatedFromMember.getPointer();
1974 return getInstantiatedFromMember();
1980 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
1981 First->InstantiatedFromMember.setPointer(PartialSpec);
2002 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2003 return First->InstantiatedFromMember.getInt();
2009 cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2010 assert(First->InstantiatedFromMember.getPointer() &&
2011 "Only member templates can be member template specializations");
2012 return First->InstantiatedFromMember.setInt(
true);
2019 assert(getTypeForDecl() &&
"partial specialization has no type set!");
2020 return cast<InjectedClassNameType>(getTypeForDecl())
2021 ->getInjectedSpecializationType();
2028 return K == ClassTemplatePartialSpecialization;
2049 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>
2064 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
2065 getSpecializations()
const;
2069 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
2070 getPartialSpecializations();
2091 void LoadLazySpecializations()
const;
2095 return static_cast<CXXRecordDecl *
>(TemplatedDecl.getPointer());
2101 return getTemplatedDecl()->isThisDeclarationADefinition();
2111 Expr *AssociatedConstraints =
nullptr);
2126 return cast<ClassTemplateDecl>(
2130 return cast<ClassTemplateDecl>(
2137 return cast_or_null<ClassTemplateDecl>(
2144 return cast_or_null<ClassTemplateDecl>(
2146 this)->getPreviousDecl());
2150 return cast<ClassTemplateDecl>(
2158 return cast_or_null<ClassTemplateDecl>(
2173 void getPartialSpecializations(
2195 findPartialSpecInstantiatedFromMember(
2212 QualType getInjectedClassNameSpecialization();
2222 return makeSpecIterator(getSpecializations(),
false);
2226 return makeSpecIterator(getSpecializations(),
true);
2251 virtual void anchor();
2271 :
Decl(
Decl::FriendTemplate, DC, Loc), NumParams(Params.size()),
2272 Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
2275 :
Decl(
Decl::FriendTemplate, Empty),
2281 static FriendTemplateDecl *
2282 Create(ASTContext &
Context, DeclContext *DC, SourceLocation Loc,
2283 MutableArrayRef<TemplateParameterList *> Params, FriendUnion Friend,
2284 SourceLocation FriendLoc);
2286 static FriendTemplateDecl *CreateDeserialized(ASTContext &C,
unsigned ID);
2308 assert(i <= NumParams);
2348 return static_cast<TypeAliasDecl *
>(TemplatedDecl.getPointer());
2353 return cast<TypeAliasTemplateDecl>(
2357 return cast<TypeAliasTemplateDecl>(
2364 return cast_or_null<TypeAliasTemplateDecl>(
2371 return cast_or_null<TypeAliasTemplateDecl>(
2373 this)->getPreviousDecl());
2377 return cast_or_null<TypeAliasTemplateDecl>(
2417 virtual void anchor();
2422 :
Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc),
2423 Specialization(FD), HasExplicitTemplateArgs(Args),
2424 TemplateArgs(std::move(TemplArgs)) {}
2427 :
Decl(Decl::ClassScopeFunctionSpecialization, Empty) {}
2430 bool HasExplicitTemplateArgs;
2442 bool HasExplicitTemplateArgs,
2445 DC, Loc, FD, HasExplicitTemplateArgs, std::move(TemplateArgs));
2454 return K == Decl::ClassScopeFunctionSpecialization;
2479 public llvm::FoldingSetNode {
2484 struct SpecializedPartialSpecialization {
2495 llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2496 SpecializedTemplate;
2499 struct ExplicitSpecializationInfo {
2507 ExplicitSpecializationInfo()
2508 : TypeAsWritten(
nullptr), ExternLoc(), TemplateKeywordLoc() {}
2513 ExplicitSpecializationInfo *ExplicitInfo;
2524 unsigned SpecializationKind : 3;
2546 bool Qualified)
const override;
2550 return cast<VarTemplateSpecializationDecl>(Recent);
2564 return TemplateArgsInfo;
2586 SpecializationKind = TSK;
2591 return PointOfInstantiation;
2595 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
2596 PointOfInstantiation = Loc;
2603 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2614 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2616 if (SpecializedPartialSpecialization *PartialSpec =
2617 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2618 return PartialSpec->PartialSpecialization;
2635 if (SpecializedPartialSpecialization *PartialSpec =
2636 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2637 return *PartialSpec->TemplateArgs;
2647 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2648 "Already set to a variable template partial specialization!");
2649 SpecializedPartialSpecialization *PS =
2651 PS->PartialSpecialization = PartialSpec;
2652 PS->TemplateArgs = TemplateArgs;
2653 SpecializedTemplate = PS;
2659 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2660 "Previously set to a variable template partial specialization!");
2661 SpecializedTemplate = TemplDecl;
2668 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2669 ExplicitInfo->TypeAsWritten = T;
2674 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2679 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2684 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2685 ExplicitInfo->ExternLoc = Loc;
2691 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2692 ExplicitInfo->TemplateKeywordLoc = Loc;
2696 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2706 ID.AddInteger(TemplateArgs.size());
2708 TemplateArg.Profile(ID, Context);
2713 return K >= firstVarTemplateSpecialization &&
2714 K <= lastVarTemplateSpecialization;
2723 void anchor()
override;
2737 llvm::PointerIntPair<VarTemplatePartialSpecializationDecl *, 1, bool>
2738 InstantiatedFromMember;
2749 TemplateParams(
nullptr), ArgsAsWritten(
nullptr),
2750 InstantiatedFromMember(
nullptr,
false) {}
2764 return cast<VarTemplatePartialSpecializationDecl>(
2771 return TemplateParams;
2776 return ArgsAsWritten;
2801 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
2802 return First->InstantiatedFromMember.getPointer();
2808 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
2809 First->InstantiatedFromMember.setPointer(PartialSpec);
2830 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
2831 return First->InstantiatedFromMember.getInt();
2837 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
2838 assert(First->InstantiatedFromMember.getPointer() &&
2839 "Only member templates can be member template specializations");
2840 return First->InstantiatedFromMember.setInt(
true);
2845 return K == VarTemplatePartialSpecialization;
2866 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>
2878 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
2883 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
2942 return cast_or_null<VarTemplateDecl>(
2949 return cast_or_null<VarTemplateDecl>(
2955 return cast<VarTemplateDecl>(
2963 return cast_or_null<VarTemplateDecl>(
3027 return TD && (isa<ClassTemplateDecl>(TD) ||
3028 isa<ClassTemplatePartialSpecializationDecl>(TD) ||
3029 isa<TypeAliasTemplateDecl>(TD) ||
3030 isa<TemplateTemplateParmDecl>(TD))
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
void setInstantiationOf(ClassTemplateDecl *TemplDecl)
Note that this class template specialization is an instantiation of the given class template...
ConstrainedTemplateDeclInfo()
static const Decl * getCanonicalDecl(const Decl *D)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
RedeclarableTemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
BuiltinTemplateKind getBuiltinTemplateKind() const
QualType getInjectedSpecializationType() const
Retrieves the injected specialization type for this partial specialization.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
const ClassTemplateDecl * getCanonicalDecl() const
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params)
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
A (possibly-)qualified type.
FunctionDecl * Function
The function template specialization that this structure describes.
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
redeclarable_base::redecl_range redecl_range
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
spec_range specializations() const
SpecIterator< FunctionTemplateSpecializationInfo > spec_iterator
VarTemplateSpecializationDecl * getMostRecentDecl()
CXXMethodDecl * getSpecialization() const
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
bool isMemberSpecialization()
Determines whether this class template partial specialization template was a specialization of a memb...
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, TemplateArgumentListInfo TemplateArgs)
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
Decl - This represents one declaration (or definition), e.g.
DeclType * operator*() const
TypeAliasTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or NULL if no such declaration exists...
ArrayRef< NamedDecl * > asArray()
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
void setInheritedDefaultArgument(const ASTContext &C, NonTypeTemplateParmDecl *Parm)
VarTemplatePartialSpecializationDecl * getMostRecentDecl()
const Expr * getRequiresClause() const
Get the constraint-expression from the associated requires-clause (if any)
void removeDefaultArgument()
Removes the default argument of this template parameter.
Declaration of a variable template.
void setSpecializationKind(TemplateSpecializationKind TSK)
NamedDecl * getParam(unsigned Idx)
static bool classofKind(Kind K)
A container of type source information.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
static bool classofKind(Kind K)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i'th template candidate.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
bool hasExplicitTemplateArgs() const
const TemplateArgumentListInfo & templateArgs() const
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Declaration of a redeclarable template.
llvm::iterator_range< spec_iterator > spec_range
llvm::PointerUnion< TemplateParameterList *, ConstrainedTemplateDeclInfo * > TemplateParams
The template parameter list and optional requires-clause associated with this declaration; alternativ...
static bool classofKind(Kind K)
Represents a variable template specialization, which refers to a variable template with a given set o...
TemplateParmPosition(unsigned D, unsigned P)
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
SourceLocation getRAngleLoc() const
static bool classofKind(Kind K)
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...
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
static bool classof(const Decl *D)
static bool classof(const Decl *D)
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.
llvm::iterator_range< spec_iterator > spec_range
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.
spec_iterator spec_begin() const
TemplateParameterList * TemplateParams
VarTemplateSpecializationDecl(Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
CXXRecordDecl * getPreviousDecl()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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.
Common * getCommonPtr() const
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void * allocateDefaultArgStorageChain(const ASTContext &C)
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
ClassTemplateSpecializationDecl * getMostRecentDecl()
static bool classofKind(Kind K)
void Profile(llvm::FoldingSetNodeID &ID)
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type)...
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
Stores the template parameter list and associated constraints for TemplateDecl objects that track ass...
Declaration of a function specialization at template class scope.
bool isExplicitSpecialization() const
SpecIterator< VarTemplateSpecializationDecl > spec_iterator
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...
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
static bool classof(const Decl *D)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
const DefArgStorage & getDefaultArgStorage() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
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.
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getLAngleLoc() const
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void set(ArgType Arg)
Set the default argument.
A convenient class for passing around template argument information.
void setDepth(unsigned D)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
NamedDecl ** iterator
Iterates through the template parameters in this list.
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known ownly by...
static bool classof(const Decl *D)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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.
unsigned getNumTemplateParameters() const
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...
QualType getDefaultArgument() const
Retrieve the default argument, if any.
void setSpecializationKind(TemplateSpecializationKind TSK)
static bool classofKind(Kind K)
SourceLocation PointOfInstantiation
The point at which this function template specialization was first instantiated.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
detail::InMemoryDirectory::const_iterator I
redeclarable_base::redecl_iterator redecl_iterator
bool isInherited() const
Determine whether the default argument for this parameter was inherited from a previous declaration o...
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
const VarTemplateDecl * getCanonicalDecl() const
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
SpecIterator< ClassTemplateSpecializationDecl > spec_iterator
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
llvm::iterator_range< redecl_iterator > redecl_range
static bool classof(const Decl *D)
const NamedDecl * getParam(unsigned Idx) const
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.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
Represents a ValueDecl that came out of a declarator.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
size_t numTrailingObjects(OverloadToken< NamedDecl * >) const
void Profile(llvm::FoldingSetNodeID &ID) const
void clear()
Remove the default argument, even if it was inherited.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
static bool classof(const Decl *D)
llvm::PointerIntPair< NamedDecl *, 1, bool > TemplatedDecl
The named declaration from which this template was instantiated.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMemberTemplate() const
Expr - This represents one expression.
void setAssociatedConstraints(Expr *AC)
Expr * AssociatedConstraints
bool isExplicitSpecialization() const
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
void setInherited(const ASTContext &C, ParmDecl *InheritedFrom)
Set that the default argument was inherited from another parameter.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
const VarTemplateDecl * getPreviousDecl() const
Retrieve the previous declaration of this variable template, or NULL if no such declaration exists...
static bool classof(const Decl *D)
void setAssociatedConstraints(Expr *AC)
llvm::iterator_range< spec_iterator > spec_range
Declaration of a template type parameter.
const TypeAliasTemplateDecl * getCanonicalDecl() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type)...
MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, SourceLocation POI=SourceLocation())
const FunctionTemplateDecl * getCanonicalDecl() const
llvm::PointerIntPair< FunctionTemplateDecl *, 2 > Template
The function template from which this function template specialization was generated.
static bool classof(const Decl *D)
const RedeclarableTemplateDecl * getCanonicalDecl() const
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
size_t numTrailingObjects(OverloadToken< Expr * >) const
Data that is common to all of the declarations of a given variable template.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
void setMemberSpecialization()
Note that this member template is a specialization.
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
spec_iterator spec_end() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
static bool classof(const Decl *D)
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
StorageClass
Storage classes.
Declaration of an alias template.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
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.
const TemplateArgumentLoc * getTemplateArgs() const
Returns the explicit template arguments that were given.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Data that is common to all of the declarations of a given class template.
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static bool classofKind(Kind K)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
static DeclType * getDecl(EntryType *D)
VarDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
spec_iterator spec_end() const
void setPointOfInstantiation(SourceLocation POI)
Set the (first) point of instantiation of this function template specialization.
OnStackType
Type used to indicate that the template argument list itself is a stack object.
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
static bool classofKind(Kind K)
spec_iterator spec_begin() const
Stores a list of template parameters and the associated requires-clause (if any) for a TemplateDecl a...
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
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.
TemplateParameterList * getTemplateParameters() const
Encodes a location in the source.
ClassTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this class template, or NULL if no such declaration exists...
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
const TemplateArgumentListInfo & getTemplateArgsInfo() const
const TemplateArgument & operator[](unsigned Idx) const
Retrieve the template argument at a given index.
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool isValid() const
Return true if this is a valid SourceLocation object.
static bool classof(const Decl *D)
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
ASTContext & getASTContext() const LLVM_READONLY
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.
void setPosition(unsigned P)
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or NULL if this template was ...
Represents a static or instance method of a struct/union/class.
TypeAliasTemplateDecl * getInstantiatedFromMemberTemplate() const
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...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Data that is common to all of the declarations of a given function template.
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
const ClassTemplateDecl * getMostRecentDecl() const
static bool classof(const Decl *D)
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
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 NULL if no such declaration exists...
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
ClassTemplateDecl * getMostRecentDecl()
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
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 TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
static bool classofKind(Kind K)
void setDeclaredWithTypename(bool withTypename)
Set whether this template type parameter was declared with the 'typename' or 'class' keyword...
Represents a pack expansion of types.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
TemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params)
Represents a template argument.
TagTypeKind
The kind of a tag type.
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
void setMemberSpecialization()
Note that this member template is a specialization.
void removeDefaultArgument()
Removes the default argument of this template parameter.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
FixedSizeTemplateParameterListStorage(SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
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)
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
bool isExplicitSpecialization() const
spec_iterator spec_begin() const
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.
const DefArgStorage & getDefaultArgStorage() const
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
DeclarationName - The name of a declaration.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
void setTemplateParameters(TemplateParameterList *TParams)
Storage for a default argument.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization. ...
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known only by ...
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
ClassTemplatePartialSpecializationDecl * getMostRecentDecl()
static bool classofKind(Kind K)
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this variable template specialization is an instantiation of a template (rather than an explicit s...
unsigned getDepth() const
Get the nesting depth of the template parameter.
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
getNameForDiagnostic - Appends a human-readable name for this declaration into the given stream...
spec_range specializations() const
spec_range specializations() 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)
Common * getCommonPtr() const
const_iterator end() const
Location wrapper for a TemplateArgument.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
Expr * getAssociatedConstraints() const
static bool classof(const OMPClause *T)
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
DeclType * operator->() const
static DeclType * getDecl(FunctionTemplateSpecializationInfo *I)
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or NULL 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.
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
TypeAliasTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
const VarTemplateDecl * getMostRecentDecl() const
bool isConcept() const
Whether this is a (C++ Concepts TS) function or variable concept.
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)
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const FunctionTemplateDecl * getPreviousDecl() const
Retrieve the previous declaration of this function template, or NULL if no such declaration exists...
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
TemplateArgument * InjectedArgs
The set of "injected" template arguments used within this function template.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
bool isSet() const
Determine whether there is a default argument for this parameter.
VarTemplateDecl * getMostRecentDecl()
static bool classof(const Decl *D)
Represents a C++ struct/union/class.
ArrayRef< const NamedDecl * > asArray() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
CommonBase * newCommon(ASTContext &C) const override
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
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)
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Declaration of a class template.
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
VarTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
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.
uint32_t * LazySpecializations
If non-null, points to an array of specializations known only by their external declaration IDs...
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
const ClassTemplateDecl * getPreviousDecl() const
Retrieve the previous declaration of this class template, or NULL if no such declaration exists...
Kind
Lists the kind of concrete classes of Decl.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
TemplateParameterList * getTemplateParameterList(unsigned i) const
Common * getCommonPtr() const
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
SourceLocation getRAngleLoc() const
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void setMemberSpecialization()
Note that this member template is a specialization.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
const_iterator begin() const
const FunctionTemplateDecl * getMostRecentDecl() const
SourceLocation getLAngleLoc() const
const Expr * getRequiresClause() const
The constraint-expression of the associated requires-clause.
void setTemplateParameters(TemplateParameterList *TParams)
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
NamedDecl - This represents a decl with a name.
NamedDecl * getAsNamedDecl(TemplateParameter P)
Expr * getAssociatedConstraints() const
Declaration of a friend template.
const TypeAliasTemplateDecl * getPreviousDecl() const
Retrieve the previous declaration of this function template, or NULL if no such declaration exists...
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
VarTemplateDecl * getDefinition()
bool isExplicitSpecialization() const
SourceRange getSourceRange() const LLVM_READONLY
TrailingObjects::FixedSizeStorageOwner FixedSizeStorageOwner
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
Declaration of a template function.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
spec_iterator spec_end() const
SourceLocation getTemplateLoc() const
FunctionTemplateDecl * getMostRecentDecl()
TemplateArgumentList(OnStackType, ArrayRef< TemplateArgument > Args)
Construct a new, temporary template argument list on the stack.