14#ifndef LLVM_CLANG_AST_DECLTEMPLATE_H
15#define LLVM_CLANG_AST_DECLTEMPLATE_H
29#include "llvm/ADT/ArrayRef.h"
30#include "llvm/ADT/FoldingSet.h"
31#include "llvm/ADT/PointerIntPair.h"
32#include "llvm/ADT/PointerUnion.h"
33#include "llvm/ADT/iterator.h"
34#include "llvm/ADT/iterator_range.h"
35#include "llvm/Support/Casting.h"
36#include "llvm/Support/Compiler.h"
37#include "llvm/Support/TrailingObjects.h"
48class ClassTemplateDecl;
49class ClassTemplatePartialSpecializationDecl;
51class FunctionTemplateDecl;
53class NonTypeTemplateParmDecl;
55class TemplateTemplateParmDecl;
56class TemplateTypeParmDecl;
58class UnresolvedSetImpl;
60class VarTemplatePartialSpecializationDecl;
72 :
private llvm::TrailingObjects<TemplateParameterList, NamedDecl *,
82 unsigned NumParams : 29;
86 unsigned ContainsUnexpandedParameterPack : 1;
89 unsigned HasRequiresClause : 1;
93 unsigned HasConstrainedParameters : 1;
105 return HasRequiresClause ? 1 : 0;
109 template <
size_t N,
bool HasRequiresClause>
118 Expr *RequiresClause);
133 unsigned size()
const {
return NumParams; }
141 assert(Idx <
size() &&
"Template parameter index out-of-range");
145 assert(Idx <
size() &&
"Template parameter index out-of-range");
170 if (
P->isParameterPack())
177 return HasRequiresClause ? getTrailingObjects<Expr *>()[0] :
nullptr;
182 return HasRequiresClause ? getTrailingObjects<Expr *>()[0] :
nullptr;
204 bool OmitTemplateKW =
false)
const;
216template <
size_t N,
bool HasRequiresClause>
218 :
public TemplateParameterList::FixedSizeStorageOwner {
219 typename TemplateParameterList::FixedSizeStorage<
221 N, HasRequiresClause ? 1u : 0u
230 Expr *RequiresClause)
231 : FixedSizeStorageOwner(
232 (assert(N == Params.size()),
233 assert(HasRequiresClause == (RequiresClause != nullptr)),
235 TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
240 :
private llvm::TrailingObjects<TemplateArgumentList, TemplateArgument> {
246 unsigned NumArguments;
272 : Arguments(Args.
data()), NumArguments(Args.
size()) {}
280 : Arguments(Other->
data()), NumArguments(Other->
size()) {}
284 assert(Idx < NumArguments &&
"Invalid template argument index");
298 unsigned size()
const {
return NumArguments; }
314template<
typename ParmDecl,
typename ArgType>
320 ParmDecl *PrevDeclWithDefaultArg;
323 static_assert(
sizeof(Chain) ==
sizeof(
void *) * 2,
324 "non-pointer argument type?");
326 llvm::PointerUnion<ArgType, ParmDecl*, Chain*> ValueOrInherited;
328 static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
330 if (
auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
332 assert(!Parm->getDefaultArgStorage()
333 .ValueOrInherited.template is<ParmDecl *>() &&
334 "should only be one level of indirection");
342 bool isSet()
const {
return !ValueOrInherited.isNull(); }
346 bool isInherited()
const {
return ValueOrInherited.template is<ParmDecl*>(); }
352 if (
const auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl *>())
353 Storage = &Prev->getDefaultArgStorage();
354 if (
const auto *
C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
356 return Storage->ValueOrInherited.template get<ArgType>();
362 if (
const auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>())
364 if (
const auto *
C = ValueOrInherited.template dyn_cast<Chain *>())
365 return C->PrevDeclWithDefaultArg;
371 assert(!
isSet() &&
"default argument already set");
372 ValueOrInherited = Arg;
377 InheritedFrom = getParmOwningDefaultArg(InheritedFrom);
379 ValueOrInherited = InheritedFrom;
380 else if (
auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>()) {
381 assert(
C.isSameDefaultTemplateArgument(D, InheritedFrom));
384 }
else if (
auto *Inherited =
385 ValueOrInherited.template dyn_cast<Chain *>()) {
386 assert(
C.isSameDefaultTemplateArgument(Inherited->PrevDeclWithDefaultArg,
388 Inherited->PrevDeclWithDefaultArg = InheritedFrom;
391 Chain{InheritedFrom, ValueOrInherited.template get<ArgType>()};
396 ValueOrInherited = ArgType();
410 void anchor()
override;
450 return K >= firstTemplate && K <= lastTemplate;
470 assert(
TemplatedDecl == NewTemplatedDecl &&
"Inconsistent TemplatedDecl");
480 :
public llvm::FoldingSetNode,
481 private llvm::TrailingObjects<FunctionTemplateSpecializationInfo,
482 MemberSpecializationInfo *> {
485 llvm::PointerIntPair<FunctionDecl *, 1, bool> Function;
491 llvm::PointerIntPair<FunctionTemplateDecl *, 2> Template;
512 : Function(FD, MSInfo ?
true :
false), Template(Template, TSK - 1),
517 getTrailingObjects<MemberSpecializationInfo *>()[0] = MSInfo;
520 size_t numTrailingObjects(OverloadToken<MemberSpecializationInfo*>)
const {
521 return Function.getInt();
560 "Cannot encode TSK_Undeclared for a function template specialization");
561 Template.setInt(TSK - 1);
610 return numTrailingObjects(OverloadToken<MemberSpecializationInfo *>())
611 ? getTrailingObjects<MemberSpecializationInfo *>()[0]
622 ID.AddInteger(TemplateArgs.size());
634 llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
643 : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
645 "Cannot encode undeclared template specializations for members");
664 "Cannot encode undeclared template specializations for members");
665 MemberAndTSK.setInt(TSK - 1);
672 return PointOfInstantiation;
677 PointOfInstantiation = POI;
696 :
private llvm::TrailingObjects<DependentFunctionTemplateSpecializationInfo,
698 FunctionTemplateDecl *> {
700 unsigned NumTemplates;
708 size_t numTrailingObjects(OverloadToken<TemplateArgumentLoc>)
const {
711 size_t numTrailingObjects(OverloadToken<FunctionTemplateDecl *>)
const {
733 return getTrailingObjects<FunctionTemplateDecl *>()[I];
738 return getTrailingObjects<TemplateArgumentLoc>();
759 return AngleLocs.
getEnd();
781 void anchor()
override;
791 return D->getTemplateArgs().asArray();
795 template <
typename EntryType,
typename SETraits = SpecEntryTraits<EntryType>,
796 typename DeclType =
typename SETraits::DeclType>
798 : llvm::iterator_adaptor_base<
799 SpecIterator<EntryType, SETraits, DeclType>,
800 typename llvm::FoldingSetVector<EntryType>::iterator,
801 typename std::iterator_traits<typename llvm::FoldingSetVector<
802 EntryType>::iterator>::iterator_category,
803 DeclType *, ptrdiff_t, DeclType *, DeclType *> {
806 typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
810 return SETraits::getDecl(&*this->I)->getMostRecentDecl();
816 template <
typename EntryType>
817 static SpecIterator<EntryType>
824 template <
class EntryType,
typename ...ProfileArguments>
827 void *&InsertPos, ProfileArguments &&...ProfileArgs);
829 template <
class Derived,
class EntryType>
831 EntryType *Entry,
void *InsertPos);
841 llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
916 assert(
getCommonPtr()->InstantiatedFromMember.getPointer() &&
917 "Only member templates can be member template specializations");
962 assert(!
getCommonPtr()->InstantiatedFromMember.getPointer());
988 return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate;
1035 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
1069 return cast<FunctionTemplateDecl>(
1073 return cast<FunctionTemplateDecl>(
1080 return cast_or_null<FunctionTemplateDecl>(
1084 return cast_or_null<FunctionTemplateDecl>(
1089 return cast<FunctionTemplateDecl>(
1098 return cast_or_null<FunctionTemplateDecl>(
1172 "The depth of template parmeter position is more than 2^20!");
1174 "The position of template parmeter position is more than 2^12!");
1184 "The depth of template parmeter position is more than 2^20!");
1192 "The position of template parmeter position is more than 2^12!");
1207 private llvm::TrailingObjects<TemplateTypeParmDecl, TypeConstraint> {
1210 friend TrailingObjects;
1220 bool HasTypeConstraint : 1;
1225 bool TypeConstraintInitialized : 1;
1230 bool ExpandedParameterPack : 1;
1233 unsigned NumExpanded = 0;
1242 bool HasTypeConstraint,
1243 std::optional<unsigned> NumExpanded)
1244 :
TypeDecl(TemplateTypeParm, DC, IdLoc,
Id, KeyLoc), Typename(Typename),
1245 HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(
false),
1246 ExpandedParameterPack(NumExpanded),
1247 NumExpanded(NumExpanded.value_or(0)) {}
1253 bool Typename,
bool ParameterPack,
bool HasTypeConstraint =
false,
1254 std::optional<unsigned> NumExpanded = std::nullopt);
1259 bool HasTypeConstraint);
1267 return Typename && !HasTypeConstraint;
1283 return DefaultArgument.
get();
1297 DefaultArgument.
set(DefArg);
1309 DefaultArgument.
clear();
1333 if (TC->hasExplicitTemplateArgs())
1334 for (
const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
1335 if (ArgLoc.getArgument().containsUnexpandedParameterPack())
1365 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1372 return TypeConstraintInitialized ? getTrailingObjects<TypeConstraint>() :
1380 Expr *ImmediatelyDeclaredConstraint);
1384 return HasTypeConstraint;
1393 if (HasTypeConstraint)
1412 private llvm::TrailingObjects<NonTypeTemplateParmDecl,
1413 std::pair<QualType, TypeSourceInfo *>,
1416 friend TrailingObjects;
1432 bool ExpandedParameterPack =
false;
1435 unsigned NumExpandedTypes = 0;
1437 size_t numTrailingObjects(
1438 OverloadToken<std::pair<QualType, TypeSourceInfo *>>)
const {
1439 return NumExpandedTypes;
1449 NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc,
1450 SourceLocation IdLoc,
unsigned D,
unsigned P,
1451 IdentifierInfo *
Id, QualType T,
1452 TypeSourceInfo *TInfo,
1453 ArrayRef<QualType> ExpandedTypes,
1454 ArrayRef<TypeSourceInfo *> ExpandedTInfos);
1457 static NonTypeTemplateParmDecl *
1458 Create(
const ASTContext &
C, DeclContext *DC, SourceLocation StartLoc,
1459 SourceLocation IdLoc,
unsigned D,
unsigned P, IdentifierInfo *
Id,
1460 QualType T,
bool ParameterPack, TypeSourceInfo *TInfo);
1462 static NonTypeTemplateParmDecl *
1463 Create(
const ASTContext &
C, DeclContext *DC, SourceLocation StartLoc,
1464 SourceLocation IdLoc,
unsigned D,
unsigned P, IdentifierInfo *
Id,
1465 QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
1466 ArrayRef<TypeSourceInfo *> ExpandedTInfos);
1470 bool HasTypeConstraint);
1473 unsigned NumExpandedTypes,
1474 bool HasTypeConstraint);
1563 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1564 return NumExpandedTypes;
1570 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1571 auto TypesAndInfos =
1572 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1573 return TypesAndInfos[I].first;
1579 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1580 auto TypesAndInfos =
1581 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1582 return TypesAndInfos[I].second;
1593 *getTrailingObjects<Expr *>() = E;
1629 private llvm::TrailingObjects<TemplateTemplateParmDecl,
1630 TemplateParameterList *> {
1642 bool ExpandedParameterPack =
false;
1645 unsigned NumExpandedParams = 0;
1648 unsigned D,
unsigned P,
bool ParameterPack,
1654 unsigned D,
unsigned P,
1658 void anchor()
override;
1667 unsigned P,
bool ParameterPack,
1681 unsigned NumExpansions);
1702 return ParameterPack &&
1729 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1730 return NumExpandedParams;
1736 assert(I < NumExpandedParams &&
"Out-of-range expansion type index");
1737 return getTrailingObjects<TemplateParameterList *>()[I];
1749 return DefaultArgument.
isSet() ? *DefaultArgument.
get() : NoneLoc;
1795 void anchor()
override;
1833 struct SpecializedPartialSpecialization {
1844 llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1845 SpecializedTemplate;
1848 struct ExplicitSpecializationInfo {
1858 ExplicitSpecializationInfo() =
default;
1863 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
1873 unsigned SpecializationKind : 3;
1907 return cast<ClassTemplateSpecializationDecl>(
1917 return *TemplateArgs;
1921 TemplateArgs = Args;
1957 SpecializedTemplate = Specialized;
1961 SpecializationKind = TSK;
1966 return PointOfInstantiation;
1970 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
1971 PointOfInstantiation = Loc;
1993 if (
const auto *PartialSpec =
1994 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1995 return PartialSpec->PartialSpecialization;
2012 if (
const auto *PartialSpec =
2013 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2014 return *PartialSpec->TemplateArgs;
2024 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
2025 "Already set to a class template partial specialization!");
2026 auto *PS =
new (
getASTContext()) SpecializedPartialSpecialization();
2027 PS->PartialSpecialization = PartialSpec;
2028 PS->TemplateArgs = TemplateArgs;
2029 SpecializedTemplate = PS;
2035 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
2036 "Previously set to a class template partial specialization!");
2037 SpecializedTemplate = TemplDecl;
2044 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2045 ExplicitInfo->TypeAsWritten = T;
2051 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2056 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2062 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2063 ExplicitInfo->ExternLoc = Loc;
2069 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2070 ExplicitInfo->TemplateKeywordLoc = Loc;
2075 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2087 ID.AddInteger(TemplateArgs.size());
2095 return K >= firstClassTemplateSpecialization &&
2096 K <= lastClassTemplateSpecialization;
2114 llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
2115 InstantiatedFromMember;
2129 InstantiatedFromMember(
nullptr,
false) {}
2131 void anchor()
override;
2151 return cast<ClassTemplatePartialSpecializationDecl>(
2158 return TemplateParams;
2177 return ArgsAsWritten;
2202 cast<ClassTemplatePartialSpecializationDecl>(
getFirstDecl());
2203 return First->InstantiatedFromMember.getPointer();
2213 First->InstantiatedFromMember.setPointer(PartialSpec);
2234 cast<ClassTemplatePartialSpecializationDecl>(
getFirstDecl());
2235 return First->InstantiatedFromMember.getInt();
2241 assert(
First->InstantiatedFromMember.getPointer() &&
2242 "Only member templates can be member template specializations");
2243 return First->InstantiatedFromMember.setInt(
true);
2250 assert(
getTypeForDecl() &&
"partial specialization has no type set!");
2252 ->getInjectedSpecializationType();
2267 return K == ClassTemplatePartialSpecialization;
2283 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>
2293 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
2298 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
2356 return cast<ClassTemplateDecl>(
2360 return cast<ClassTemplateDecl>(
2367 return cast_or_null<ClassTemplateDecl>(
2371 return cast_or_null<ClassTemplateDecl>(
2377 return cast<ClassTemplateDecl>(
2385 return cast_or_null<ClassTemplateDecl>(
2476 virtual void anchor();
2483 unsigned NumParams = 0;
2497 :
Decl(
Decl::FriendTemplate, DC, Loc), NumParams(NumParams),
2498 Params(Params), Friend(Friend), FriendLoc(FriendLoc) {}
2532 assert(i <= NumParams);
2578 return cast<TypeAliasTemplateDecl>(
2582 return cast<TypeAliasTemplateDecl>(
2589 return cast_or_null<TypeAliasTemplateDecl>(
2593 return cast_or_null<TypeAliasTemplateDecl>(
2599 return cast_or_null<TypeAliasTemplateDecl>(
2642 :
Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc),
2646 :
Decl(Decl::ClassScopeFunctionSpecialization, Empty) {}
2648 virtual void anchor();
2657 return TemplateArgs;
2662 bool HasExplicitTemplateArgs,
2666 HasExplicitTemplateArgs
2678 return K == Decl::ClassScopeFunctionSpecialization;
2696 public llvm::FoldingSetNode {
2701 struct SpecializedPartialSpecialization {
2712 llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2713 SpecializedTemplate;
2716 struct ExplicitSpecializationInfo {
2726 ExplicitSpecializationInfo() =
default;
2731 ExplicitSpecializationInfo *ExplicitInfo =
nullptr;
2742 unsigned SpecializationKind : 3;
2748 unsigned IsCompleteDefinition : 1;
2778 return cast<VarTemplateSpecializationDecl>(Recent);
2793 return TemplateArgsInfo;
2820 SpecializationKind = TSK;
2825 return PointOfInstantiation;
2829 assert(Loc.
isValid() &&
"point of instantiation must be valid!");
2830 PointOfInstantiation = Loc;
2839 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2850 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2852 if (
const auto *PartialSpec =
2853 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2854 return PartialSpec->PartialSpecialization;
2871 if (
const auto *PartialSpec =
2872 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2873 return *PartialSpec->TemplateArgs;
2883 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2884 "Already set to a variable template partial specialization!");
2885 auto *PS =
new (
getASTContext()) SpecializedPartialSpecialization();
2886 PS->PartialSpecialization = PartialSpec;
2887 PS->TemplateArgs = TemplateArgs;
2888 SpecializedTemplate = PS;
2894 assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2895 "Previously set to a variable template partial specialization!");
2896 SpecializedTemplate = TemplDecl;
2903 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2904 ExplicitInfo->TypeAsWritten = T;
2910 return ExplicitInfo ? ExplicitInfo->TypeAsWritten :
nullptr;
2915 return ExplicitInfo ? ExplicitInfo->ExternLoc :
SourceLocation();
2921 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2922 ExplicitInfo->ExternLoc = Loc;
2928 ExplicitInfo =
new (
getASTContext()) ExplicitSpecializationInfo;
2929 ExplicitInfo->TemplateKeywordLoc = Loc;
2934 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc :
SourceLocation();
2946 ID.AddInteger(TemplateArgs.size());
2954 return K >= firstVarTemplateSpecialization &&
2955 K <= lastVarTemplateSpecialization;
2973 llvm::PointerIntPair<VarTemplatePartialSpecializationDecl *, 1, bool>
2974 InstantiatedFromMember;
2986 InstantiatedFromMember(
nullptr,
false) {}
2988 void anchor()
override;
3005 return cast<VarTemplatePartialSpecializationDecl>(
3012 return TemplateParams;
3017 return ArgsAsWritten;
3056 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
3057 return First->InstantiatedFromMember.getPointer();
3063 First->InstantiatedFromMember.setPointer(PartialSpec);
3084 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
3085 return First->InstantiatedFromMember.getInt();
3091 assert(
First->InstantiatedFromMember.getPointer() &&
3092 "Only member templates can be member template specializations");
3093 return First->InstantiatedFromMember.setInt(
true);
3110 return K == VarTemplatePartialSpecialization;
3126 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>
3133 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
3138 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
3200 return cast_or_null<VarTemplateDecl>(
3204 return cast_or_null<VarTemplateDecl>(
3210 return cast<VarTemplateDecl>(
3218 return cast_or_null<VarTemplateDecl>(
3320 private llvm::TrailingObjects<ImplicitConceptSpecializationDecl,
3322 unsigned NumTemplateArgs;
3334 unsigned NumTemplateArgs);
3362 public Mergeable<TemplateParamObjectDecl>,
3363 public llvm::FoldingSetNode {
3429 auto *TD = dyn_cast<TemplateDecl>(D);
3430 return TD && (isa<ClassTemplateDecl>(TD) ||
3431 isa<ClassTemplatePartialSpecializationDecl>(TD) ||
3432 isa<TypeAliasTemplateDecl>(TD) ||
3433 isa<TemplateTemplateParmDecl>(TD))
3450 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
3451 if (TTP->isExpandedParameterPack())
3452 return TTP->getNumExpansionParameters();
3455 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3456 if (NTTP->isExpandedParameterPack())
3457 return NTTP->getNumExpansionTypes();
3460 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3461 if (TTP->isExpandedParameterPack())
3462 return TTP->getNumExpansionTemplateParameters();
3465 return std::nullopt;
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Reads an AST files chain containing the contents of a translation unit.
bool isConstrained() const
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
BuiltinTemplateKind getBuiltinTemplateKind() const
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
static bool classof(const Decl *D)
static bool classofKind(Kind K)
Represents a static or instance method of a struct/union/class.
Represents a C++ struct/union/class.
CXXRecordDecl * getMostRecentNonInjectedDecl()
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Declaration of a function specialization at template class scope.
static bool classof(const Decl *D)
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, const TemplateArgumentListInfo &TemplateArgs)
CXXMethodDecl * getSpecialization() const
static bool classofKind(Kind K)
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
bool hasExplicitTemplateArgs() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this class template.
ClassTemplateDecl * getMostRecentDecl()
spec_iterator spec_begin() const
spec_iterator spec_end() const
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
static bool classofKind(Kind K)
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
CommonBase * newCommon(ASTContext &C) const override
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
llvm::iterator_range< spec_iterator > spec_range
static bool classof(const Decl *D)
const ClassTemplateDecl * getMostRecentDecl() const
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
const ClassTemplateDecl * getCanonicalDecl() const
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
ClassTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this class template, or nullptr if no such declaration exists.
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
const ClassTemplateDecl * getPreviousDecl() const
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
void setCommonPtr(Common *C)
spec_range specializations() const
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template.
Common * getCommonPtr() const
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMemberTemplate() const
ClassTemplatePartialSpecializationDecl * getMostRecentDecl()
void setInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *PartialSpec)
bool isMemberSpecialization()
Determines whether this class template partial specialization template was a specialization of a memb...
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
bool hasAssociatedConstraints() const
void Profile(llvm::FoldingSetNodeID &ID) const
void setMemberSpecialization()
Note that this member template is a specialization.
static bool classofKind(Kind K)
QualType getInjectedSpecializationType() const
Retrieves the injected specialization type for this partial specialization.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static bool classof(const Decl *D)
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isClassScopeExplicitSpecialization() const
Is this an explicit specialization at class scope (within the class that owns the primary template)?...
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
ClassTemplateSpecializationDecl * getMostRecentDecl()
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
void setTemplateArgs(TemplateArgumentList *Args)
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
void setPointOfInstantiation(SourceLocation Loc)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
static bool classof(const Decl *D)
void setSpecializationKind(TemplateSpecializationKind TSK)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, const ASTContext &Context)
void setInstantiationOf(ClassTemplateDecl *TemplDecl)
Note that this class template specialization is an instantiation of the given class template.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
bool isExplicitSpecialization() const
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
void Profile(llvm::FoldingSetNodeID &ID) const
void setSpecializedTemplate(ClassTemplateDecl *Specialized)
static bool classofKind(Kind K)
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ConceptDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
static ConceptDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isTypeConcept() const
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
ConceptDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static bool classof(const Decl *D)
const ConceptDecl * getCanonicalDecl() const
static bool classofKind(Kind K)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Kind
Lists the kind of concrete classes of Decl.
SourceLocation getLocation() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Storage for a default argument.
void setInherited(const ASTContext &C, ParmDecl *InheritedFrom)
Set that the default argument was inherited from another parameter.
bool isSet() const
Determine whether there is a default argument for this parameter.
ArgType get() const
Get the default argument's value.
void set(ArgType Arg)
Set the default argument.
void clear()
Remove the default argument, even if it was inherited.
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
bool isInherited() const
Determine whether the default argument for this parameter was inherited from a previous declaration o...
Provides information about a dependent function-template specialization declaration.
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
const TemplateArgumentLoc * getTemplateArgs() const
Returns the explicit template arguments that were given.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
SourceLocation getRAngleLoc() const
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i'th template candidate.
SourceLocation getLAngleLoc() const
static DependentFunctionTemplateSpecializationInfo * Create(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
This represents one expression.
Stores a list of template parameters and the associated requires-clause (if any) for a TemplateDecl a...
FixedSizeTemplateParameterListStorage(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Declaration of a friend template.
static bool classof(const Decl *D)
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type),...
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
TemplateParameterList * getTemplateParameterList(unsigned i) const
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static bool classofKind(Kind K)
unsigned getNumTemplateParameters() const
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type),...
Represents a function declaration or definition.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Declaration of a template function.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
spec_iterator spec_end() const
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
CommonBase * newCommon(ASTContext &C) const override
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
Common * getCommonPtr() const
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
const FunctionTemplateDecl * getPreviousDecl() const
bool isAbbreviated() const
Return whether this function template is an abbreviated function template, e.g.
FunctionTemplateDecl * getMostRecentDecl()
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
const FunctionTemplateDecl * getCanonicalDecl() const
spec_range specializations() const
spec_iterator spec_begin() const
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
const FunctionTemplateDecl * getMostRecentDecl() const
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
llvm::iterator_range< spec_iterator > spec_range
static bool classofKind(Kind K)
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
static bool classof(const Decl *D)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
bool isExplicitSpecialization() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, const ASTContext &Context)
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
MemberSpecializationInfo * getMemberSpecializationInfo() const
Get the specialization info if this function template specialization is also a member specialization:
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
void Profile(llvm::FoldingSetNodeID &ID)
SourceLocation PointOfInstantiation
The point at which this function template specialization was first instantiated.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
FunctionDecl * getFunction() const
Retrieve the declaration of the function template specialization.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
void setPointOfInstantiation(SourceLocation POI)
Set the (first) point of instantiation of this function template specialization.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
One of these records is kept for each identifier that is lexed.
void setTemplateArguments(ArrayRef< TemplateArgument > Converted)
static bool classofKind(Kind K)
static ImplicitConceptSpecializationDecl * CreateDeserialized(const ASTContext &C, unsigned ID, unsigned NumTemplateArgs)
static ImplicitConceptSpecializationDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation SL, ArrayRef< TemplateArgument > ConvertedArgs)
ArrayRef< TemplateArgument > getTemplateArguments() const
static bool classof(const Decl *D)
Provides information a specialization of a member of a class template, which may be a member function...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
bool isExplicitSpecialization() const
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, SourceLocation POI=SourceLocation())
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
TemplateParamObjectDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
This represents a decl that may have a name.
A C++ nested-name-specifier augmented with source location information.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
const DefArgStorage & getDefaultArgStorage() const
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
static bool classofKind(Kind K)
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
static bool classof(const Decl *D)
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the associated-constraints of this template parameter.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
bool hasPlaceholderTypeConstraint() const
Determine whether this non-type template parameter's type has a placeholder with a type-constraint.
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
void setPlaceholderTypeConstraint(Expr *E)
void removeDefaultArgument()
Removes the default argument of this template parameter.
void setInheritedDefaultArgument(const ASTContext &C, NonTypeTemplateParmDecl *Parm)
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool HasTypeConstraint)
Represents a pack expansion of types.
A (possibly-)qualified type.
QualType getCanonicalType() const
void * getAsOpaquePtr() const
Declaration of a redeclarable template.
static SpecIterator< EntryType > makeSpecIterator(llvm::FoldingSetVector< EntryType > &Specs, bool isEnd)
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
redeclarable_base::redecl_iterator redecl_iterator
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template.
SpecEntryTraits< EntryType >::DeclType * findSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, void *&InsertPos, ProfileArguments &&...ProfileArgs)
const RedeclarableTemplateDecl * getCanonicalDecl() const
redeclarable_base::redecl_range redecl_range
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
static bool classof(const Decl *D)
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or nullptr if this template w...
static bool classofKind(Kind K)
virtual CommonBase * newCommon(ASTContext &C) const =0
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
void addSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, EntryType *Entry, void *InsertPos)
friend class RedeclarableTemplate
void loadLazySpecializationsImpl() const
void setMemberSpecialization()
Note that this member template is a specialization.
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
ArrayRef< TemplateArgument > getInjectedTemplateArgs()
Retrieve the "injected" template arguments that correspond to the template parameters of this templat...
Provides common interface for the Decls that can be redeclared.
RedeclarableTemplateDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
RedeclarableTemplateDecl * getNextRedeclaration() const
RedeclarableTemplateDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
redecl_iterator redecls_end() const
llvm::iterator_range< redecl_iterator > redecl_range
RedeclarableTemplateDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
redecl_iterator redecls_begin() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Sema - This implements semantic analysis and AST building for C.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
SourceLocation getEndLoc() const LLVM_READONLY
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
A convenient class for passing around template argument information.
A template argument list.
TemplateArgumentList(const TemplateArgumentList &)=delete
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
const TemplateArgument & operator[](unsigned Idx) const
Retrieve the template argument at a given index.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
TemplateArgumentList(const TemplateArgumentList *Other)
Produces a shallow copy of the given template argument list.
OnStackType
Type used to indicate that the template argument list itself is a stack object.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
TemplateArgumentList(OnStackType, ArrayRef< TemplateArgument > Args)
Construct a new, temporary template argument list on the stack.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
TemplateArgumentList & operator=(const TemplateArgumentList &)=delete
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
SourceRange getSourceRange() const LLVM_READONLY
Represents a template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
NamedDecl * TemplatedDecl
TemplateParameterList * TemplateParams
bool hasAssociatedConstraints() const
void init(NamedDecl *NewTemplatedDecl)
Initialize the underlying templated declaration.
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params)
void setTemplateParameters(TemplateParameterList *TParams)
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the total constraint-expression associated with this template, including constraint-expressions d...
static bool classof(const Decl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static bool classofKind(Kind K)
A template parameter object.
TemplateParamObjectDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void printAsExpr(llvm::raw_ostream &OS) const
Print this object as an equivalent expression.
const TemplateParamObjectDecl * getCanonicalDecl() const
void Profile(llvm::FoldingSetNodeID &ID)
const APValue & getValue() const
static bool classof(const Decl *D)
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, const APValue &V)
void printName(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const override
Print this template parameter object in a human-readable format.
void printAsInit(llvm::raw_ostream &OS) const
Print this object as an initializer suitable for a variable of the object's type.
static bool classofKind(Kind K)
Stores a list of template parameters for a TemplateDecl and its derived classes.
const_iterator end() const
NamedDecl * getParam(unsigned Idx)
SourceRange getSourceRange() const LLVM_READONLY
const_iterator begin() const
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
const Expr * getRequiresClause() const
The constraint-expression of the associated requires-clause.
bool hasAssociatedConstraints() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
size_t numTrailingObjects(OverloadToken< Expr * >) const
bool hasParameterPack() const
Determine whether this template parameter list contains a parameter pack.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
void print(raw_ostream &Out, const ASTContext &Context, const PrintingPolicy &Policy, bool OmitTemplateKW=false) const
SourceLocation getRAngleLoc() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) const
const NamedDecl * getParam(unsigned Idx) const
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
SourceLocation getLAngleLoc() const
size_t numTrailingObjects(OverloadToken< NamedDecl * >) const
TemplateParameterList(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints derived from this template parameter list, including the requires clause a...
ArrayRef< NamedDecl * > asArray()
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
SourceLocation getTemplateLoc() const
ArrayRef< const NamedDecl * > asArray() const
Defines the position of a template parameter within a template parameter list.
static constexpr unsigned MaxPosition
static constexpr unsigned MaxDepth
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
void setPosition(unsigned P)
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
TemplateParmPosition(unsigned D, unsigned P)
void setDepth(unsigned D)
unsigned getDepth() const
Get the nesting depth of the template parameter.
TemplateParmPosition()=delete
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
const DefArgStorage & getDefaultArgStorage() const
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static bool classof(const Decl *D)
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
static bool classofKind(Kind K)
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
void removeDefaultArgument()
Removes the default argument of this template parameter.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
QualType getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getIndex() const
Retrieve the index of the template parameter.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTypeParmDecl *Prev)
Set that this default argument was inherited from another parameter.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, std::optional< unsigned > NumExpanded=std::nullopt)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
bool isExpandedParameterPack() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void removeDefaultArgument()
Removes the default argument of this template parameter.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getDepth() const
Retrieve the depth of the template parameter.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const DefArgStorage & getDefaultArgStorage() const
unsigned getNumExpansionParameters() const
Retrieves the number of parameters in an expanded parameter pack.
static bool classofKind(Kind K)
static bool classof(const Decl *D)
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the associated-constraints of this template parameter.
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
void setDeclaredWithTypename(bool withTypename)
Set whether this template type parameter was declared with the 'typename' or 'class' keyword.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Declaration of an alias template.
static bool classof(const Decl *D)
CommonBase * newCommon(ASTContext &C) const override
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
TypeAliasTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
const TypeAliasTemplateDecl * getPreviousDecl() const
TypeAliasTemplateDecl * getInstantiatedFromMemberTemplate() const
const TypeAliasTemplateDecl * getCanonicalDecl() const
static bool classofKind(Kind K)
TypeAliasTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Represents a declaration of a type.
const Type * getTypeForDecl() const
A container of type source information.
QualType getType() const
Return the type wrapped by this type source info.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
const T * getAs() const
Member-template getAs<specific type>'.
A set of unresolved declarations.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Declaration of a variable template.
VarTemplateDecl * getDefinition()
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
VarTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
spec_iterator spec_begin() const
Common * getCommonPtr() const
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
static bool classof(const Decl *D)
const VarTemplateDecl * getPreviousDecl() const
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or nullptr if no such declaration exists...
CommonBase * newCommon(ASTContext &C) const override
VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
const VarTemplateDecl * getCanonicalDecl() const
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
llvm::iterator_range< spec_iterator > spec_range
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
static bool classofKind(Kind K)
const VarTemplateDecl * getMostRecentDecl() const
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
spec_iterator spec_end() const
VarTemplateDecl * getMostRecentDecl()
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
spec_range specializations() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
void setMemberSpecialization()
Note that this member template is a specialization.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
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)
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
void Profile(llvm::FoldingSetNodeID &ID) const
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static bool classof(const Decl *D)
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
VarTemplatePartialSpecializationDecl * getMostRecentDecl()
static bool classofKind(Kind K)
bool hasAssociatedConstraints() const
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.
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, const ASTContext &Context)
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
static bool classof(const Decl *D)
bool isClassScopeExplicitSpecialization() const
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this variable template specialization is actually an instantiation of the given variable te...
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void Profile(llvm::FoldingSetNodeID &ID) const
void setPointOfInstantiation(SourceLocation Loc)
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.