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 *,
85 unsigned NumParams : 29;
89 LLVM_PREFERRED_TYPE(
bool)
90 unsigned ContainsUnexpandedParameterPack : 1;
93 LLVM_PREFERRED_TYPE(
bool)
94 unsigned HasRequiresClause : 1;
98 LLVM_PREFERRED_TYPE(
bool)
99 unsigned HasConstrainedParameters : 1;
111 return HasRequiresClause ? 1 : 0;
115 template <
size_t N,
bool HasRequiresClause>
124 Expr *RequiresClause);
139 unsigned size()
const {
return NumParams; }
140 bool empty()
const {
return NumParams == 0; }
148 assert(Idx <
size() &&
"Template parameter index out-of-range");
152 assert(Idx <
size() &&
"Template parameter index out-of-range");
177 if (
P->isParameterPack())
184 return HasRequiresClause ? getTrailingObjects<Expr *>()[0] :
nullptr;
189 return HasRequiresClause ? getTrailingObjects<Expr *>()[0] :
nullptr;
214 bool OmitTemplateKW =
false)
const;
226template <
size_t N,
bool HasRequiresClause>
228 :
public TemplateParameterList::FixedSizeStorageOwner {
229 typename TemplateParameterList::FixedSizeStorage<
231 N, HasRequiresClause ? 1u : 0u
240 Expr *RequiresClause)
241 : FixedSizeStorageOwner(
242 (assert(N == Params.size()),
243 assert(HasRequiresClause == (RequiresClause != nullptr)),
245 TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
250 :
private llvm::TrailingObjects<TemplateArgumentList, TemplateArgument> {
253 unsigned NumArguments;
272 assert(Idx < NumArguments &&
"Invalid template argument index");
286 unsigned size()
const {
return NumArguments; }
290 return getTrailingObjects<TemplateArgument>();
304template<
typename ParmDecl,
typename ArgType>
310 ParmDecl *PrevDeclWithDefaultArg;
313 static_assert(
sizeof(Chain) ==
sizeof(
void *) * 2,
314 "non-pointer argument type?");
316 llvm::PointerUnion<ArgType, ParmDecl*, Chain*> ValueOrInherited;
318 static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
320 if (
auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
322 assert(!isa<ParmDecl *>(Parm->getDefaultArgStorage().ValueOrInherited) &&
323 "should only be one level of indirection");
331 bool isSet()
const {
return !ValueOrInherited.isNull(); }
335 bool isInherited()
const {
return isa<ParmDecl *>(ValueOrInherited); }
341 if (
const auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl *>())
342 Storage = &Prev->getDefaultArgStorage();
343 if (
const auto *
C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
345 return cast<ArgType>(Storage->ValueOrInherited);
351 if (
const auto *
D = ValueOrInherited.template dyn_cast<ParmDecl *>())
353 if (
const auto *
C = ValueOrInherited.template dyn_cast<Chain *>())
354 return C->PrevDeclWithDefaultArg;
360 assert(!
isSet() &&
"default argument already set");
361 ValueOrInherited = Arg;
366 InheritedFrom = getParmOwningDefaultArg(InheritedFrom);
368 ValueOrInherited = InheritedFrom;
369 else if ([[maybe_unused]]
auto *
D =
370 dyn_cast<ParmDecl *>(ValueOrInherited)) {
371 assert(
C.isSameDefaultTemplateArgument(
D, InheritedFrom));
374 }
else if (
auto *Inherited = dyn_cast<Chain *>(ValueOrInherited)) {
375 assert(
C.isSameDefaultTemplateArgument(Inherited->PrevDeclWithDefaultArg,
377 Inherited->PrevDeclWithDefaultArg = InheritedFrom;
380 Chain{InheritedFrom, cast<ArgType>(ValueOrInherited)};
385 ValueOrInherited = ArgType();
399 void anchor()
override;
439 return K >= firstTemplate && K <= lastTemplate;
459 assert(
TemplatedDecl == NewTemplatedDecl &&
"Inconsistent TemplatedDecl");
469 :
public llvm::FoldingSetNode,
470 private llvm::TrailingObjects<FunctionTemplateSpecializationInfo,
471 MemberSpecializationInfo *> {
474 llvm::PointerIntPair<FunctionDecl *, 1, bool> Function;
480 llvm::PointerIntPair<FunctionTemplateDecl *, 2> Template;
506 getTrailingObjects<MemberSpecializationInfo *>()[0] = MSInfo;
509 size_t numTrailingObjects(OverloadToken<MemberSpecializationInfo*>)
const {
548 "Cannot encode TSK_Undeclared for a function template specialization");
549 Template.setInt(TSK - 1);
598 return numTrailingObjects(OverloadToken<MemberSpecializationInfo *>())
599 ? getTrailingObjects<MemberSpecializationInfo *>()[0]
610 ID.AddInteger(TemplateArgs.size());
622 llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
631 : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
633 "Cannot encode undeclared template specializations for members");
652 "Cannot encode undeclared template specializations for members");
653 MemberAndTSK.setInt(TSK - 1);
660 return PointOfInstantiation;
665 PointOfInstantiation = POI;
692 :
private llvm::TrailingObjects<DependentFunctionTemplateSpecializationInfo,
693 FunctionTemplateDecl *> {
694 friend TrailingObjects;
697 unsigned NumCandidates;
713 return {getTrailingObjects<FunctionTemplateDecl *>(), NumCandidates};
735 void anchor()
override;
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)
765 return SETraits::getDecl(&*this->I)->getMostRecentDecl();
771 template <
typename EntryType>
772 static SpecIterator<EntryType>
782 template <
class EntryType,
typename ...ProfileArguments>
785 void *&InsertPos, ProfileArguments &&...ProfileArgs);
787 template <
class EntryType,
typename... ProfileArguments>
791 ProfileArguments &&...ProfileArgs);
793 template <
class Derived,
class EntryType>
795 EntryType *Entry,
void *InsertPos);
805 llvm::PointerIntPair<RedeclarableTemplateDecl *, 1, bool>
864 assert(
getCommonPtr()->InstantiatedFromMember.getPointer() &&
865 "Only member templates can be member template specializations");
910 assert(!
getCommonPtr()->InstantiatedFromMember.getPointer());
939 return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate;
986 llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
1029 return cast<FunctionTemplateDecl>(
1033 return cast<FunctionTemplateDecl>(
1040 return cast_or_null<FunctionTemplateDecl>(
1044 return cast_or_null<FunctionTemplateDecl>(
1049 return cast<FunctionTemplateDecl>(
1058 return cast_or_null<FunctionTemplateDecl>(
1133 "The depth of template parmeter position is more than 2^20!");
1135 "The position of template parmeter position is more than 2^12!");
1145 "The depth of template parmeter position is more than 2^20!");
1153 "The position of template parmeter position is more than 2^12!");
1168 private llvm::TrailingObjects<TemplateTypeParmDecl, TypeConstraint> {
1171 friend TrailingObjects;
1181 bool HasTypeConstraint : 1;
1186 bool TypeConstraintInitialized : 1;
1191 bool ExpandedParameterPack : 1;
1194 unsigned NumExpanded = 0;
1203 bool HasTypeConstraint,
1204 std::optional<unsigned> NumExpanded)
1206 HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(
false),
1207 ExpandedParameterPack(NumExpanded),
1208 NumExpanded(NumExpanded.value_or(0)) {}
1214 bool Typename,
bool ParameterPack,
bool HasTypeConstraint =
false,
1215 std::optional<unsigned> NumExpanded = std::nullopt);
1220 bool HasTypeConstraint);
1228 return Typename && !HasTypeConstraint;
1240 return DefaultArgument.
isSet() ? *DefaultArgument.
get() : NoneLoc;
1265 DefaultArgument.
clear();
1289 if (TC->hasExplicitTemplateArgs())
1290 for (
const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
1291 if (ArgLoc.getArgument().containsUnexpandedParameterPack())
1321 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1328 return TypeConstraintInitialized ? getTrailingObjects<TypeConstraint>() :
1333 Expr *ImmediatelyDeclaredConstraint);
1337 return HasTypeConstraint;
1346 if (HasTypeConstraint)
1365 private llvm::TrailingObjects<NonTypeTemplateParmDecl,
1366 std::pair<QualType, TypeSourceInfo *>,
1369 friend TrailingObjects;
1386 bool ExpandedParameterPack =
false;
1389 unsigned NumExpandedTypes = 0;
1391 size_t numTrailingObjects(
1392 OverloadToken<std::pair<QualType, TypeSourceInfo *>>)
const {
1393 return NumExpandedTypes;
1403 NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc,
1404 SourceLocation IdLoc,
unsigned D,
unsigned P,
1405 const IdentifierInfo *
Id, QualType
T,
1406 TypeSourceInfo *TInfo,
1407 ArrayRef<QualType> ExpandedTypes,
1408 ArrayRef<TypeSourceInfo *> ExpandedTInfos);
1411 static NonTypeTemplateParmDecl *
1412 Create(
const ASTContext &
C, DeclContext *DC, SourceLocation StartLoc,
1413 SourceLocation IdLoc,
unsigned D,
unsigned P,
const IdentifierInfo *
Id,
1414 QualType
T,
bool ParameterPack, TypeSourceInfo *TInfo);
1416 static NonTypeTemplateParmDecl *
1417 Create(
const ASTContext &
C, DeclContext *DC, SourceLocation StartLoc,
1418 SourceLocation IdLoc,
unsigned D,
unsigned P,
const IdentifierInfo *
Id,
1419 QualType
T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
1420 ArrayRef<TypeSourceInfo *> ExpandedTInfos);
1422 static NonTypeTemplateParmDecl *
1426 unsigned NumExpandedTypes,
1427 bool HasTypeConstraint);
1446 return DefaultArgument.
isSet() ? *DefaultArgument.
get() : NoneLoc;
1520 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1521 return NumExpandedTypes;
1527 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1528 auto TypesAndInfos =
1529 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1530 return TypesAndInfos[I].first;
1536 assert(I < NumExpandedTypes &&
"Out-of-range expansion type index");
1537 auto TypesAndInfos =
1538 getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1539 return TypesAndInfos[I].second;
1550 *getTrailingObjects<Expr *>() =
E;
1586 private llvm::TrailingObjects<TemplateTemplateParmDecl,
1587 TemplateParameterList *> {
1597 LLVM_PREFERRED_TYPE(
bool)
1598 unsigned Typename : 1;
1601 LLVM_PREFERRED_TYPE(
bool)
1602 unsigned ParameterPack : 1;
1607 LLVM_PREFERRED_TYPE(
bool)
1608 unsigned ExpandedParameterPack : 1;
1611 unsigned NumExpandedParams = 0;
1618 ParameterPack(ParameterPack), ExpandedParameterPack(
false) {}
1625 void anchor()
override;
1634 unsigned P,
bool ParameterPack,
1675 return ParameterPack &&
1702 assert(ExpandedParameterPack &&
"Not an expansion parameter pack");
1703 return NumExpandedParams;
1709 assert(I < NumExpandedParams &&
"Out-of-range expansion type index");
1710 return getTrailingObjects<TemplateParameterList *>()[I];
1722 return DefaultArgument.
isSet() ? *DefaultArgument.
get() : NoneLoc;
1768 void anchor()
override;
1821 public llvm::FoldingSetNode {
1825 struct SpecializedPartialSpecialization {
1836 llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1837 SpecializedTemplate;
1851 unsigned SpecializationKind : 3;
1885 return cast<ClassTemplateSpecializationDecl>(
1895 return *TemplateArgs;
1899 TemplateArgs = Args;
1935 SpecializedTemplate = Specialized;
1939 SpecializationKind = TSK;
1944 return PointOfInstantiation;
1948 assert(
Loc.isValid() &&
"point of instantiation must be valid!");
1949 PointOfInstantiation =
Loc;
1971 if (
const auto *PartialSpec =
1972 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1973 return PartialSpec->PartialSpecialization;
1975 return cast<ClassTemplateDecl *>(SpecializedTemplate);
1990 if (
const auto *PartialSpec =
1991 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1992 return *PartialSpec->TemplateArgs;
2002 assert(!isa<SpecializedPartialSpecialization *>(SpecializedTemplate) &&
2003 "Already set to a class template partial specialization!");
2004 auto *PS =
new (
getASTContext()) SpecializedPartialSpecialization();
2005 PS->PartialSpecialization = PartialSpec;
2006 PS->TemplateArgs = TemplateArgs;
2007 SpecializedTemplate = PS;
2013 assert(!isa<SpecializedPartialSpecialization *>(SpecializedTemplate) &&
2014 "Previously set to a class template partial specialization!");
2015 SpecializedTemplate = TemplDecl;
2022 dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
2023 return Info->TemplateArgsAsWritten;
2024 return cast<const ASTTemplateArgumentListInfo *>(ExplicitInfo);
2031 dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
2032 Info->TemplateArgsAsWritten = ArgsWritten;
2034 ExplicitInfo = ArgsWritten;
2046 dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
2047 return Info->ExternKeywordLoc;
2057 dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
2058 return Info->TemplateKeywordLoc;
2074 ID.AddInteger(TemplateArgs.size());
2082 return K >= firstClassTemplateSpecialization &&
2083 K <= lastClassTemplateSpecialization;
2097 llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
2098 InstantiatedFromMember;
2108 InstantiatedFromMember(
nullptr,
false) {}
2110 void anchor()
override;
2127 return cast<ClassTemplatePartialSpecializationDecl>(
2134 return TemplateParams;
2179 cast<ClassTemplatePartialSpecializationDecl>(
getFirstDecl());
2180 return First->InstantiatedFromMember.getPointer();
2190 First->InstantiatedFromMember.setPointer(PartialSpec);
2211 cast<ClassTemplatePartialSpecializationDecl>(
getFirstDecl());
2212 return First->InstantiatedFromMember.getInt();
2218 assert(
First->InstantiatedFromMember.getPointer() &&
2219 "Only member templates can be member template specializations");
2220 return First->InstantiatedFromMember.setInt(
true);
2227 assert(
getTypeForDecl() &&
"partial specialization has no type set!");
2229 ->getInjectedSpecializationType();
2246 return K == ClassTemplatePartialSpecialization;
2262 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>
2272 llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
2277 llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
2333 return cast<ClassTemplateDecl>(
2337 return cast<ClassTemplateDecl>(
2344 return cast_or_null<ClassTemplateDecl>(
2348 return cast_or_null<ClassTemplateDecl>(
2354 return cast<ClassTemplateDecl>(
2362 return cast_or_null<ClassTemplateDecl>(
2453 virtual void anchor();
2460 unsigned NumParams = 0;
2474 :
Decl(
Decl::FriendTemplate, DC,
Loc), NumParams(NumParams),
2475 Params(Params),
Friend(
Friend), FriendLoc(FriendLoc) {}
2509 assert(i <= NumParams);
2555 return cast<TypeAliasTemplateDecl>(
2559 return cast<TypeAliasTemplateDecl>(
2566 return cast_or_null<TypeAliasTemplateDecl>(
2570 return cast_or_null<TypeAliasTemplateDecl>(
2576 return cast_or_null<TypeAliasTemplateDecl>(
2610 public llvm::FoldingSetNode {
2615 struct SpecializedPartialSpecialization {
2626 llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2627 SpecializedTemplate;
2641 unsigned SpecializationKind : 3;
2647 LLVM_PREFERRED_TYPE(
bool)
2648 unsigned IsCompleteDefinition : 1;
2678 return cast<VarTemplateSpecializationDecl>(Recent);
2712 SpecializationKind = TSK;
2717 return PointOfInstantiation;
2721 assert(
Loc.isValid() &&
"point of instantiation must be valid!");
2722 PointOfInstantiation =
Loc;
2731 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2742 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2744 if (
const auto *PartialSpec =
2745 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2746 return PartialSpec->PartialSpecialization;
2748 return cast<VarTemplateDecl *>(SpecializedTemplate);
2763 if (
const auto *PartialSpec =
2764 SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2765 return *PartialSpec->TemplateArgs;
2775 assert(!isa<SpecializedPartialSpecialization *>(SpecializedTemplate) &&
2776 "Already set to a variable template partial specialization!");
2777 auto *PS =
new (
getASTContext()) SpecializedPartialSpecialization();
2778 PS->PartialSpecialization = PartialSpec;
2779 PS->TemplateArgs = TemplateArgs;
2780 SpecializedTemplate = PS;
2786 assert(!isa<SpecializedPartialSpecialization *>(SpecializedTemplate) &&
2787 "Previously set to a variable template partial specialization!");
2788 SpecializedTemplate = TemplDecl;
2795 dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
2796 return Info->TemplateArgsAsWritten;
2797 return cast<const ASTTemplateArgumentListInfo *>(ExplicitInfo);
2804 dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
2805 Info->TemplateArgsAsWritten = ArgsWritten;
2807 ExplicitInfo = ArgsWritten;
2819 dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
2820 return Info->ExternKeywordLoc;
2830 dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
2831 return Info->TemplateKeywordLoc;
2847 ID.AddInteger(TemplateArgs.size());
2855 return K >= firstVarTemplateSpecialization &&
2856 K <= lastVarTemplateSpecialization;
2870 llvm::PointerIntPair<VarTemplatePartialSpecializationDecl *, 1, bool>
2871 InstantiatedFromMember;
2882 InstantiatedFromMember(
nullptr,
false) {}
2884 void anchor()
override;
2901 return cast<VarTemplatePartialSpecializationDecl>(
2908 return TemplateParams;
2953 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
2954 return First->InstantiatedFromMember.getPointer();
2960 First->InstantiatedFromMember.setPointer(PartialSpec);
2981 cast<VarTemplatePartialSpecializationDecl>(
getFirstDecl());
2982 return First->InstantiatedFromMember.getInt();
2988 assert(
First->InstantiatedFromMember.getPointer() &&
2989 "Only member templates can be member template specializations");
2990 return First->InstantiatedFromMember.setInt(
true);
3007 return K == VarTemplatePartialSpecialization;
3023 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>
3030 llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
3035 llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
3097 return cast_or_null<VarTemplateDecl>(
3101 return cast_or_null<VarTemplateDecl>(
3107 return cast<VarTemplateDecl>(
3115 return cast_or_null<VarTemplateDecl>(
3222 private llvm::TrailingObjects<ImplicitConceptSpecializationDecl,
3224 unsigned NumTemplateArgs;
3236 unsigned NumTemplateArgs);
3264 public Mergeable<TemplateParamObjectDecl>,
3265 public llvm::FoldingSetNode {
3304 ID.AddPointer(
T.getCanonicalType().getAsOpaquePtr());
3327 return cast<TemplateTemplateParmDecl *>(
P);
3331 auto *TD = dyn_cast<TemplateDecl>(
D);
3332 return TD && (isa<ClassTemplateDecl>(TD) ||
3333 isa<ClassTemplatePartialSpecializationDecl>(TD) ||
3334 isa<TypeAliasTemplateDecl>(TD) ||
3335 isa<TemplateTemplateParmDecl>(TD))
3352 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
3353 if (TTP->isExpandedParameterPack())
3354 return TTP->getNumExpansionParameters();
3357 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3358 if (NTTP->isExpandedParameterPack())
3359 return NTTP->getNumExpansionTypes();
3362 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3363 if (TTP->isExpandedParameterPack())
3364 return TTP->getNumExpansionTemplateParameters();
3367 return std::nullopt;
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
enum clang::sema::@1727::IndirectLocalPathEntry::EntryKind Kind
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 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 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 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
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.
ClassTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this class template, or nullptr if no such declaration exists.
void LoadLazySpecializations(bool OnlyPartial=false) const
Load any lazily-loaded specializations from the external source.
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...
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Create an empty class template node.
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)
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
bool isMemberSpecialization() const
Determines whether this class template partial specialization template was a specialization of a memb...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ArrayRef< TemplateArgument > getInjectedTemplateArgs(const ASTContext &Context) const
Get the template argument list of the template parameter list.
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.
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
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.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
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, GlobalDeclID ID)
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 setPointOfInstantiation(SourceLocation Loc)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
static bool classof(const Decl *D)
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
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.
void setTemplateArgsAsWritten(const TemplateArgumentListInfo &ArgsInfo)
Set the template argument list as written in the sources.
bool isExplicitSpecialization() const
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
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...
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 setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
void Profile(llvm::FoldingSetNodeID &ID) const
void setSpecializedTemplate(ClassTemplateDecl *Specialized)
static bool classofKind(Kind K)
Declaration of a C++20 concept.
void setDefinition(Expr *E)
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, GlobalDeclID ID)
bool isTypeConcept() const
ConceptDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool hasDefinition() const
static bool classof(const Decl *D)
const ConceptDecl * getCanonicalDecl() const
static bool classofKind(Kind K)
A reference to a concept and its template args, as it appears in the code.
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.
ArrayRef< FunctionTemplateDecl * > getCandidates() const
Returns the candidates for the primary function template.
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
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),...
TemplateParameterList * getTemplateParameterList(unsigned i) const
static bool classofKind(Kind K)
unsigned getNumTemplateParameters() const
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
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 ...
void setInstantiatedFromMemberTemplate(bool Val=true)
bool isInstantiatedFromMemberTemplate() const
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
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.
void setInstantiatedFromMemberTemplate(FunctionTemplateDecl *D)
FunctionTemplateDecl * getMostRecentDecl()
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
const FunctionTemplateDecl * getCanonicalDecl() const
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Create an empty function template node.
spec_range specializations() const
spec_iterator spec_begin() const
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
bool isCompatibleWithDefinition() const
const FunctionTemplateDecl * getMostRecentDecl() const
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 ...
bool isExplicitSpecialization() const
TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
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.
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, GlobalDeclID ID, unsigned NumTemplateArgs)
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.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, bool HasTypeConstraint)
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)
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.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
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.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the associated-constraints of this template parameter.
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)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Represents a pack expansion of types.
A (possibly-)qualified type.
Declaration of a redeclarable template.
static SpecIterator< EntryType > makeSpecIterator(llvm::FoldingSetVector< EntryType > &Specs, bool isEnd)
SpecEntryTraits< EntryType >::DeclType * findSpecializationLocally(llvm::FoldingSetVector< EntryType > &Specs, void *&InsertPos, ProfileArguments &&...ProfileArgs)
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
redeclarable_base::redecl_iterator redecl_iterator
void loadLazySpecializationsImpl(bool OnlyPartial=false) const
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 setMemberSpecialization()
Note that this member template is a specialization.
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
ArrayRef< TemplateArgument > getInjectedTemplateArgs(const ASTContext &Context) const
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.
A trivial tuple used to represent a source range.
SourceLocation getEnd() 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.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
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
ArrayRef< TemplateArgument > getInjectedTemplateArgs(const ASTContext &Context)
Get the template argument list of the template parameter list.
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.
bool wasDeclaredWithTypename() const
Whether this template template parameter was declared with the 'typename' keyword.
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 bool classof(const Decl *D)
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
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 setDeclaredWithTypename(bool withTypename)
Set whether this template template parameter was declared with the 'typename' or 'class' keyword.
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...
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.
const TemplateArgumentLoc & 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.
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, GlobalDeclID ID)
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
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...
void removeDefaultArgument()
Removes the default argument of 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
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter.
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 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, GlobalDeclID 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)
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Represents a declaration of a type.
const Type * getTypeForDecl() const
A container of type source information.
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...
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
void LoadLazySpecializations(bool OnlyPartial=false) const
Load any lazily-loaded specializations from the external source.
VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
const VarTemplateDecl * getCanonicalDecl() const
static VarTemplateDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Create an empty 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()
spec_range specializations() const
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.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
bool isMemberSpecialization() const
Determines whether this variable template partial specialization was a specialization of a member par...
void Profile(llvm::FoldingSetNodeID &ID) const
static bool classof(const Decl *D)
ArrayRef< TemplateArgument > getInjectedTemplateArgs(const ASTContext &Context) const
Get the template argument list of the template parameter list.
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)
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
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 setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, const ASTContext &Context)
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...
static bool classof(const Decl *D)
bool isClassScopeExplicitSpecialization() const
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...
void Profile(llvm::FoldingSetNodeID &ID) const
void setPointOfInstantiation(SourceLocation Loc)
void setTemplateArgsAsWritten(const TemplateArgumentListInfo &ArgsInfo)
Set the template argument list as written in the sources.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
void setInstantiationOf(VarTemplateDecl *TemplDecl)
Note that this variable template specialization is an instantiation of the given variable template.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this variable template specialization is an instantiation of a template (rather than an explicit s...
bool isExplicitSpecialization() const
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setCompleteDefinition()
VarTemplateSpecializationDecl * getMostRecentDecl()
static bool classofKind(Kind K)
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Decl * getPrimaryMergedDecl(Decl *D)
Get the primary declaration for a declaration from an AST file.
NamedDecl * getAsNamedDecl(TemplateParameter P)
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
StorageClass
Storage classes.
void * allocateDefaultArgStorageChain(const ASTContext &C)
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
llvm::PointerUnion< const ASTTemplateArgumentListInfo *, ExplicitInstantiationInfo * > SpecializationOrInstantiationInfo
TemplateParameterList * getReplacedTemplateParameterList(Decl *D)
Internal helper used by Subst* nodes to retrieve the parameter list for their AssociatedDecl.
TagTypeKind
The kind of a tag type.
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
std::optional< unsigned > getExpandedPackSize(const NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
const FunctionProtoType * T
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
bool isTemplateExplicitInstantiationOrSpecialization(TemplateSpecializationKind Kind)
True if this template specialization kind is an explicit specialization, explicit instantiation decla...
Diagnostic wrappers for TextAPI types for error reporting.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
Data that is common to all of the declarations of a given class template.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
QualType InjectedClassNameType
The injected-class-name type for this class template.
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Provides information about an explicit instantiation of a variable or class template.
ExplicitInstantiationInfo()=default
SourceLocation ExternKeywordLoc
The location of the extern keyword.
const ASTTemplateArgumentListInfo * TemplateArgsAsWritten
The template arguments as written..
SourceLocation TemplateKeywordLoc
The location of the template keyword.
Data that is common to all of the declarations of a given function template.
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
Describes how types, statements, expressions, and declarations should be printed.
llvm::PointerIntPair< RedeclarableTemplateDecl *, 1, bool > InstantiatedFromMember
The template from which this was most directly instantiated (or null).
static ArrayRef< TemplateArgument > getTemplateArgs(FunctionTemplateSpecializationInfo *I)
static DeclType * getDecl(FunctionTemplateSpecializationInfo *I)
static ArrayRef< TemplateArgument > getTemplateArgs(EntryType *D)
static DeclType * getDecl(EntryType *D)
SpecIterator(typename llvm::FoldingSetVector< EntryType >::iterator SetIter)
DeclType * operator->() const
DeclType * operator*() const
Data that is common to all of the declarations of a given variable template.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...