45#include "llvm/ADT/ArrayRef.h"
46#include "llvm/ADT/DenseSet.h"
47#include "llvm/ADT/STLExtras.h"
48#include "llvm/ADT/SmallVector.h"
49#include "llvm/Support/Casting.h"
50#include "llvm/Support/ErrorHandling.h"
61class ExtractTypeForDeductionGuide
66 std::optional<TemplateDeclInstantiator> TypedefNameInstantiator;
70 ExtractTypeForDeductionGuide(
75 :
Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs),
76 NestedPattern(NestedPattern),
77 OuterInstantiationArgs(OuterInstantiationArgs) {
78 if (OuterInstantiationArgs)
79 TypedefNameInstantiator.emplace(
81 *OuterInstantiationArgs);
114 if (!OuterInstantiationArgs ||
120 auto *Pattern = TATD;
121 while (Pattern->getInstantiatedFromMemberTemplate())
122 Pattern = Pattern->getInstantiatedFromMemberTemplate();
123 if (!mightReferToOuterTemplateParameters(Pattern->getTemplatedDecl()))
128 TypedefNameInstantiator->InstantiateTypeAliasTemplateDecl(TATD);
132 auto *NewTATD = cast<TypeAliasTemplateDecl>(NewD);
133 MaterializedTypedefs.push_back(NewTATD->getTemplatedDecl());
159 if (OuterInstantiationArgs && InDependentContext &&
161 Decl = cast_if_present<TypedefNameDecl>(
162 TypedefNameInstantiator->InstantiateTypedefNameDecl(
163 OrigDecl, isa<TypeAliasDecl>(OrigDecl)));
166 MaterializedTypedefs.push_back(
Decl);
167 }
else if (InDependentContext) {
172 if (isa<TypeAliasDecl>(OrigDecl))
177 assert(isa<TypedefDecl>(OrigDecl) &&
"Not a Type alias or typedef");
182 MaterializedTypedefs.push_back(
Decl);
205 auto DeductionGuideName =
216 TInfo->
getType(), TInfo, LocEnd, Ctor);
217 Guide->setImplicit(IsImplicit);
218 Guide->setParams(Params);
220 for (
auto *Param : Params)
221 Param->setDeclContext(Guide);
222 for (
auto *TD : MaterializedTypedefs)
223 TD->setDeclContext(Guide);
224 if (isa<CXXRecordDecl>(DC))
227 if (!TemplateParams) {
233 SemaRef.
Context, DC,
Loc, DeductionGuideName, TemplateParams, Guide);
234 GuideTemplate->setImplicit(IsImplicit);
235 Guide->setDescribedFunctionTemplate(GuideTemplate);
237 if (isa<CXXRecordDecl>(DC))
241 return GuideTemplate;
248 bool EvaluateConstraint) {
266 NewTTP->setDefaultArgument(SemaRef.
Context, InstantiatedDefaultArg);
272template <
typename NonTypeTemplateOrTemplateTemplateParmDecl>
273NonTypeTemplateOrTemplateTemplateParmDecl *
275 NonTypeTemplateOrTemplateTemplateParmDecl *OldParam,
280 auto *NewParam = cast<NonTypeTemplateOrTemplateTemplateParmDecl>(
282 NewParam->setPosition(NewIndex);
283 NewParam->setDepth(NewDepth);
290 unsigned NewIndex,
unsigned NewDepth,
291 bool EvaluateConstraint =
true) {
292 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(
TemplateParam))
293 return transformTemplateTypeParam(
294 SemaRef, DC, TTP, Args, NewDepth, NewIndex,
296 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
TemplateParam))
297 return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, NewDepth);
298 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
TemplateParam))
299 return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, NewDepth);
300 llvm_unreachable(
"Unhandled template parameter types");
305struct ConvertConstructorToDeductionGuideTransform {
306 ConvertConstructorToDeductionGuideTransform(
Sema &S,
308 : SemaRef(S), Template(Template) {
316 NestedPattern = Pattern;
362 AllParams.reserve(TemplateParams->
size() + InnerParams->
size());
363 AllParams.insert(AllParams.begin(), TemplateParams->
begin(),
364 TemplateParams->
end());
365 SubstArgs.reserve(InnerParams->
size());
366 Depth1Args.reserve(InnerParams->
size());
372 Args.
setKind(TemplateSubstitutionKind::Rewrite);
378 NamedDecl *NewParam = transformTemplateParameter(
379 SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment, Depth - 1);
388 NewParam = transformTemplateParameter(
389 SemaRef, DC, NewParam, OuterInstantiationArgs, Index,
395 "Unexpected template parameter depth");
397 AllParams.push_back(NewParam);
402 Expr *RequiresClause =
nullptr;
403 if (
Expr *InnerRC = InnerParams->getRequiresClause()) {
405 Args.
setKind(TemplateSubstitutionKind::Rewrite);
413 RequiresClause =
E.getAs<
Expr>();
416 TemplateParams = TemplateParameterList::Create(
417 SemaRef.
Context, InnerParams->getTemplateLoc(),
418 InnerParams->getLAngleLoc(), AllParams, InnerParams->getRAngleLoc(),
426 Args.
setKind(TemplateSubstitutionKind::Rewrite);
435 assert(FPTL &&
"no prototype for constructor declaration");
443 QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args,
444 MaterializedTypedefs);
449 return buildDeductionGuide(
452 true, MaterializedTypedefs);
463 DeductionGuideName, EPI);
466 TSI = SemaRef.
SubstType(TSI, OuterInstantiationArgs,
Loc,
477 for (
auto T : ParamTypes) {
480 TSI = SemaRef.
SubstType(TSI, OuterInstantiationArgs,
Loc,
489 FPTL.
setParam(Params.size(), NewParam);
490 Params.push_back(NewParam);
493 return buildDeductionGuide(
499 QualType transformFunctionProtoType(
520 NewParam = transformFunctionTypeParam(
521 NewParam, OuterInstantiationArgs, MaterializedTypedefs,
530 transformFunctionTypeParam(NewParam, Args, MaterializedTypedefs,
534 ParamTypes.push_back(NewParam->
getType());
535 Params.push_back(NewParam);
557 ReturnType, ParamTypes, TL.
getBeginLoc(), DeductionGuideName, EPI);
576 bool TransformingOuterPatterns) {
583 SemaRef.
SubstType(PackTL.getPatternLoc(), Args,
589 PackTL.getTypePtr()->getNumExpansions());
600 NewDI = ExtractTypeForDeductionGuide(
601 SemaRef, MaterializedTypedefs, NestedPattern,
602 TransformingOuterPatterns ? &Args :
nullptr)
612 NewDefArg =
new (SemaRef.
Context)
620 auto NewType = NewDI->
getType();
640 struct TemplateParamsReferencedFinder
643 llvm::BitVector ReferencedTemplateParams;
645 TemplateParamsReferencedFinder(
647 : TemplateParamList(TemplateParamList),
648 ReferencedTemplateParams(TemplateParamList->size()) {}
675 void Mark(
unsigned Depth,
unsigned Index) {
676 if (Index < TemplateParamList->size() &&
678 ReferencedTemplateParams.set(Index);
681 TemplateParamsReferencedFinder Finder(TemplateParamsList);
682 Finder.TraverseTemplateArguments(DeducedArgs);
685 for (
unsigned Index = 0; Index < TemplateParamsList->
size(); ++Index) {
686 if (Finder.ReferencedTemplateParams[Index])
687 Results.push_back(Index);
695 assert(Name.getNameKind() ==
696 DeclarationName::NameKind::CXXDeductionGuideName &&
697 "name must be a deduction guide name");
698 auto Existing = DC->
lookup(Name);
699 for (
auto *
D : Existing)
717 unsigned FirstUndeducedParamIdx,
Expr *IsDeducible) {
742 unsigned AdjustDepth = 0;
743 if (
auto *PrimaryTemplate =
745 AdjustDepth = PrimaryTemplate->getTemplateDepth();
755 Args.
setKind(TemplateSubstitutionKind::Rewrite);
757 NamedDecl *NewParam = transformTemplateParameter(
759 AdjustedAliasTemplateArgs.size(),
764 AdjustedAliasTemplateArgs.push_back(NewTemplateArgument);
772 Args.
setKind(TemplateSubstitutionKind::Rewrite);
775 for (
unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
776 const auto &
D = DeduceResults[Index];
780 Args.
setKind(TemplateSubstitutionKind::Rewrite);
784 transformTemplateParameter(SemaRef, F->
getDeclContext(), TP, Args,
785 FirstUndeducedParamIdx,
787 FirstUndeducedParamIdx += 1;
788 assert(TemplateArgsForBuildingRC[Index].isNull());
789 TemplateArgsForBuildingRC[Index] =
797 assert(TemplateArgsForBuildingRC[Index].isNull() &&
798 "InstantiatedArgs must be null before setting");
799 TemplateArgsForBuildingRC[Index] = Output.
getArgument();
839 clang::Decl::ClassTemplateSpecialization) {
846 for (
auto It : OuterLevelArgs)
856 BinaryOperatorKind::BO_LAnd,
E.get(), IsDeducible);
857 if (Conjunction.isInvalid())
865Expr *buildIsDeducibleConstraint(
Sema &SemaRef,
871 if (
auto *PrimaryTemplate =
873 PrimaryTemplate && TemplateParams.size() > 0) {
877 unsigned AdjustDepth = PrimaryTemplate->getTemplateDepth();
879 for (
auto *TP : TemplateParams) {
883 Args.
setKind(TemplateSubstitutionKind::Rewrite);
885 NamedDecl *NewParam = transformTemplateParameter(
887 TransformedTemplateArgs.size(),
892 TransformedTemplateArgs.push_back(NewTemplateArgument);
896 Args.
setKind(TemplateSubstitutionKind::Rewrite);
914 TypeTrait::BTT_IsDeducible, IsDeducibleTypeTraitArgs,
918std::pair<TemplateDecl *, llvm::ArrayRef<TemplateArgument>>
922 ->getUnderlyingType()
923 .getSingleStepDesugaredType(SemaRef.
Context);
930 Template = TST->getTemplateName().getAsTemplateDecl();
931 AliasRhsTemplateArgs = TST->template_arguments();
932 }
else if (
const auto *RT = RhsType->getAs<
RecordType>()) {
936 if (
const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(
937 RT->getAsCXXRecordDecl())) {
938 Template = CTSD->getSpecializedTemplate();
939 AliasRhsTemplateArgs = CTSD->getTemplateArgs().asArray();
942 assert(
false &&
"unhandled RHS type of the alias");
944 return {Template, AliasRhsTemplateArgs};
950BuildDeductionGuideForTypeAlias(
Sema &SemaRef,
957 if (BuildingDeductionGuides.isInvalid())
960 auto &Context = SemaRef.
Context;
961 auto [Template, AliasRhsTemplateArgs] =
970 FReturnType = InjectedCNT->getInjectedTST();
974 assert(FReturnType &&
"expected to see a return type");
1007 AliasRhsTemplateArgs, TDeduceInfo, DeduceResults,
1014 for (
unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
1015 if (
const auto &
D = DeduceResults[Index]; !
D.isNull())
1016 DeducedArgs.push_back(
D);
1018 NonDeducedTemplateParamsInFIndex.push_back(Index);
1020 auto DeducedAliasTemplateParams =
1021 TemplateParamsReferencedInTemplateArgumentList(
1040 for (
unsigned AliasTemplateParamIdx : DeducedAliasTemplateParams) {
1042 AliasTemplate->getTemplateParameters()->getParam(AliasTemplateParamIdx);
1046 Args.
setKind(TemplateSubstitutionKind::Rewrite);
1048 NamedDecl *NewParam = transformTemplateParameter(
1051 FPrimeTemplateParams.push_back(NewParam);
1055 TransformedDeducedAliasArgs[AliasTemplateParamIdx] = NewTemplateArgument;
1057 unsigned FirstUndeducedParamIdx = FPrimeTemplateParams.size();
1060 for (
unsigned FTemplateParamIdx : NonDeducedTemplateParamsInFIndex) {
1063 Args.
setKind(TemplateSubstitutionKind::Rewrite);
1067 NamedDecl *NewParam = transformTemplateParameter(
1068 SemaRef, F->
getDeclContext(), TP, Args, FPrimeTemplateParams.size(),
1070 FPrimeTemplateParams.push_back(NewParam);
1072 assert(TemplateArgsForBuildingFPrime[FTemplateParamIdx].isNull() &&
1073 "The argument must be null before setting");
1074 TemplateArgsForBuildingFPrime[FTemplateParamIdx] =
1094 Args.
setKind(TemplateSubstitutionKind::Rewrite);
1096 for (
unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
1097 const auto &
D = DeduceResults[Index];
1100 assert(!TemplateArgsForBuildingFPrime[Index].isNull() &&
1101 "template arguments for non-deduced template parameters should "
1109 assert(TemplateArgsForBuildingFPrime[Index].isNull() &&
1110 "InstantiatedArgs must be null before setting");
1111 TemplateArgsForBuildingFPrime[Index] = Output.
getArgument();
1115 auto *TemplateArgListForBuildingFPrime =
1119 F, TemplateArgListForBuildingFPrime,
AliasTemplate->getLocation(),
1121 auto *GG = cast<CXXDeductionGuideDecl>(FPrime);
1123 Expr *IsDeducible = buildIsDeducibleConstraint(
1124 SemaRef,
AliasTemplate, FPrime->getReturnType(), FPrimeTemplateParams);
1125 Expr *RequiresClause =
1126 buildAssociatedConstraints(SemaRef, F,
AliasTemplate, DeduceResults,
1127 FirstUndeducedParamIdx, IsDeducible);
1129 auto *FPrimeTemplateParamList = TemplateParameterList::Create(
1130 Context,
AliasTemplate->getTemplateParameters()->getTemplateLoc(),
1132 FPrimeTemplateParams,
1135 auto *Result = cast<FunctionTemplateDecl>(buildDeductionGuide(
1137 GG->getCorrespondingConstructor(), GG->getExplicitSpecifier(),
1141 cast<CXXDeductionGuideDecl>(Result->getTemplatedDecl())
1142 ->setDeductionCandidateKind(GG->getDeductionCandidateKind());
1148void DeclareImplicitDeductionGuidesForTypeAlias(
1152 auto &Context = SemaRef.
Context;
1156 if (hasDeclaredDeductionGuides(
1160 auto [Template, AliasRhsTemplateArgs] =
1168 Guides.suppressDiagnostics();
1170 for (
auto *G : Guides) {
1171 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(G)) {
1179 for (
unsigned I = 0, N = DG->getNumParams(); I != N; ++I) {
1180 const auto *
P = DG->getParamDecl(I);
1183 SemaRef.
Context, G->getDeclContext(),
1184 DG->getParamDecl(I)->getBeginLoc(),
P->getLocation(),
nullptr,
1189 auto *Transformed = cast<FunctionDecl>(buildDeductionGuide(
1198 auto *Constraint = buildIsDeducibleConstraint(
1200 if (
auto *RC = DG->getTrailingRequiresClause()) {
1203 BinaryOperatorKind::BO_LAnd, RC, Constraint);
1204 if (!Conjunction.isInvalid())
1207 Transformed->setTrailingRequiresClause(Constraint);
1216 ->getDeductionCandidateKind() == DeductionCandidate::Aggregate)
1232 RHSTemplate, ParamTypes,
Loc);
1233 if (!RHSDeductionGuide)
1235 return BuildDeductionGuideForTypeAlias(SemaRef,
AliasTemplate,
1236 RHSDeductionGuide,
Loc);
1244 llvm::FoldingSetNodeID ID;
1245 ID.AddPointer(Template);
1246 for (
auto &
T : ParamTypes)
1248 unsigned Hash = ID.ComputeHash();
1256 if (
auto *
AliasTemplate = llvm::dyn_cast<TypeAliasTemplateDecl>(Template)) {
1257 if (
auto *FTD = DeclareAggregateDeductionGuideForTypeAlias(
1269 DefRecord->getDescribedClassTemplate())
1270 Template = DescribedTemplate;
1277 ConvertConstructorToDeductionGuideTransform Transform(
1278 *
this, cast<ClassTemplateDecl>(Template));
1289 *
this,
Loc, Template,
1291 if (BuildingDeductionGuides.isInvalid())
1295 Transform.NestedPattern ? Transform.NestedPattern : Transform.Template;
1298 auto *FTD = cast<FunctionTemplateDecl>(
1299 Transform.buildSimpleDeductionGuide(ParamTypes));
1309 if (
auto *
AliasTemplate = llvm::dyn_cast<TypeAliasTemplateDecl>(Template)) {
1316 DefRecord->getDescribedClassTemplate())
1317 Template = DescribedTemplate;
1324 ConvertConstructorToDeductionGuideTransform Transform(
1325 *
this, cast<ClassTemplateDecl>(Template));
1329 if (hasDeclaredDeductionGuides(Transform.DeductionGuideName, DC))
1338 *
this,
Loc, Template,
1340 if (BuildingDeductionGuides.isInvalid())
1348 Transform.NestedPattern ? Transform.NestedPattern : Transform.Template;
1351 bool AddedAny =
false;
1353 D =
D->getUnderlyingDecl();
1362 if (ProcessedCtors.count(
D))
1365 auto *FTD = dyn_cast<FunctionTemplateDecl>(
D);
1375 return !P || P->hasUnparsedDefaultArg();
1379 ProcessedCtors.insert(
D);
1380 Transform.transformConstructor(FTD, CD);
1389 Transform.buildSimpleDeductionGuide(std::nullopt);
1393 cast<CXXDeductionGuideDecl>(
1394 cast<FunctionTemplateDecl>(
1395 Transform.buildSimpleDeductionGuide(Transform.DeducedType))
1396 ->getTemplatedDecl())
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
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.
Defines the clang::TypeLoc interface and its subclasses.
Defines enumerations for the type traits support.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
DeclarationNameTable DeclarationNames
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl)
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Underlying=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
Represents a C++ constructor within a class.
ExplicitSpecifier getExplicitSpecifier()
Represents a C++ deduction guide declaration.
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor=nullptr, DeductionCandidate Kind=DeductionCandidate::Normal)
Represents a C++ struct/union/class.
CXXRecordDecl * getDefinition() const
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addDecl(Decl *D)
Add the declaration D into this context.
Decl::Kind getDeclKind() const
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
bool isInvalidDecl() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getBeginLoc() const LLVM_READONLY
TypeSourceInfo * getTypeSourceInfo() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Store information needed for an explicit specifier.
This represents one expression.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
Represents a prototype with parameter type info, e.g.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
bool isVariadic() const
Whether this function prototype is variadic.
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
unsigned getNumParams() const
SourceLocation getLocalRangeEnd() const
void setLocalRangeBegin(SourceLocation L)
void setLParenLoc(SourceLocation Loc)
void setParam(unsigned i, ParmVarDecl *VD)
ArrayRef< ParmVarDecl * > getParams() const
void setRParenLoc(SourceLocation Loc)
void setLocalRangeEnd(SourceLocation L)
void setExceptionSpecRange(SourceRange R)
SourceLocation getLocalRangeBegin() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
FunctionType - C99 6.7.5.3 - Function Declarators.
const TypeClass * getTypePtr() const
The injected class name of a C++ class template or class template partial specialization.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
void InstantiatedLocal(const Decl *D, Decl *Inst)
Represents the results of name lookup.
Data structure that captures multiple levels of template argument lists for use in template instantia...
void addOuterRetainedLevel()
Add an outermost level that we are not substituting.
void addOuterTemplateArguments(Decl *AssociatedDecl, ArgList Args, bool Final)
Add a new outmost level to the multi-level template argument list.
void setKind(TemplateSubstitutionKind K)
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
void addOuterRetainedLevels(unsigned Num)
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
unsigned getFunctionScopeDepth() const
A (possibly-)qualified type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Scope - A scope is a transient data structure that is used while parsing the program.
RAII object used to change the argument pack substitution index within a Sema object.
Sema - This implements semantic analysis and AST building for C.
bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraint)
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
Scope * getCurScope() const
Retrieve the parser's current scope.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
FunctionTemplateDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
ASTContext & getASTContext() const
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
TemplateParameterList * GetTemplateParameterList(TemplateDecl *TD)
Returns the template parameter list with all default template argument information.
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output, SourceLocation Loc={}, const DeclarationName &Entity={})
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
A convenient class for passing around template argument information.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
Represents a template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Represents a type template specialization; the template must be a class template, a type alias templa...
ArrayRef< TemplateArgument > template_arguments() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
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.
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).
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 isExpandedParameterPack() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getNumExpansionParameters() const
Retrieves the number of parameters in an expanded parameter pack.
unsigned getIndex() const
unsigned getDepth() const
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Declaration of an alias template.
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
void setNameLoc(SourceLocation Loc)
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
bool isRValueReferenceType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isFunctionType() const
const T * getAs() const
Member-template getAs<specific type>'.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
Wrapper for source info for typedefs.
TypedefNameDecl * getTypedefNameDecl() const
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Provides information about an attempted template argument deduction, whose success or failure was des...
The JSON file list parser is used to communicate input to InstallAPI.
@ Rewrite
We are substituting template parameters for (typically) other template parameters in order to rewrite...
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Extra information about a function prototype.
unsigned HasTrailingReturn
@ BuildingDeductionGuides
We are building deduction guides for a class.
A stack object to be created when performing template instantiation.