31 class CollectUnexpandedParameterPacksVisitor :
39 bool InLambda =
false;
43 if (
auto *VD = dyn_cast<VarDecl>(ND)) {
47 auto *FD = dyn_cast<FunctionDecl>(VD->getDeclContext());
48 auto *FTD = FD ? FD->getDescribedFunctionTemplate() :
nullptr;
49 if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit)
54 Unexpanded.push_back({ND, Loc});
59 Unexpanded.push_back({T, Loc});
63 explicit CollectUnexpandedParameterPacksVisitor(
65 : Unexpanded(Unexpanded) {}
103 if (
auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>(
105 if (TTP->isParameterPack())
120 if (Element.isPackExpansion())
135 Expr *E = dyn_cast_or_null<Expr>(S);
186 bool TraverseCXXFoldExpr(
CXXFoldExpr *E) {
return true; }
195 return inherited::TraverseUnresolvedUsingValueDecl(D);
203 return inherited::TraverseUnresolvedUsingTypenameDecl(D);
224 if (
Base.isPackExpansion())
232 if (Init->isPackExpansion())
249 bool WasInLambda = InLambda;
250 unsigned OldDepthLimit = DepthLimit;
254 DepthLimit = TPL->getDepth();
256 inherited::TraverseLambdaExpr(Lambda);
258 InLambda = WasInLambda;
259 DepthLimit = OldDepthLimit;
266 if (
C->isPackExpansion())
283 if (isa<sema::LambdaScopeInfo>(SI))
294 if (Unexpanded.empty())
304 for (
auto &Pack : Unexpanded) {
305 auto DeclaresThisPack = [&](
NamedDecl *LocalPack) {
307 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(LocalPack);
308 return TTPD && TTPD->getTypeForDecl() == TTPT;
312 if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
313 LambdaParamPackReferences.push_back(Pack);
316 if (LambdaParamPackReferences.empty()) {
328 bool EnclosingStmtExpr =
false;
334 EnclosingStmtExpr =
true;
343 if (!EnclosingStmtExpr) {
344 LSI->ContainsUnexpandedParameterPack =
true;
348 Unexpanded = LambdaParamPackReferences;
356 for (
unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
360 Name = TTP->getIdentifier();
364 if (Name && NamesKnown.insert(Name).second)
365 Names.push_back(Name);
367 if (Unexpanded[I].second.isValid())
368 Locations.push_back(Unexpanded[I].second);
371 auto DB =
Diag(Loc, diag::err_unexpanded_parameter_pack)
372 << (
int)UPPC << (
int)Names.size();
373 for (
size_t I = 0, E = std::min(Names.size(), (
size_t)2); I != E; ++I)
376 for (
unsigned I = 0, N = Locations.size(); I != N; ++I)
391 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(
393 assert(!Unexpanded.empty() &&
"Unable to find unexpanded parameter packs");
406 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(E);
407 assert(!Unexpanded.empty() &&
"Unable to find unexpanded parameter packs");
416 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(RE);
417 assert(!Unexpanded.empty() &&
"Unable to find unexpanded parameter packs");
424 for (
auto Parm : Unexpanded)
425 if (ParmSet.contains(Parm.first.dyn_cast<
NamedDecl *>()))
426 UnexpandedParms.push_back(Parm);
427 if (UnexpandedParms.empty())
444 CollectUnexpandedParameterPacksVisitor(Unexpanded)
446 assert(!Unexpanded.empty() &&
"Unable to find unexpanded parameter packs");
481 CollectUnexpandedParameterPacksVisitor(Unexpanded)
483 assert(!Unexpanded.empty() &&
"Unable to find unexpanded parameter packs");
495 CollectUnexpandedParameterPacksVisitor(Unexpanded)
496 .TraverseTemplateName(Template);
497 assert(!Unexpanded.empty() &&
"Unable to find unexpanded parameter packs");
508 CollectUnexpandedParameterPacksVisitor(Unexpanded)
509 .TraverseTemplateArgumentLoc(Arg);
510 assert(!Unexpanded.empty() &&
"Unable to find unexpanded parameter packs");
516 CollectUnexpandedParameterPacksVisitor(Unexpanded)
517 .TraverseTemplateArgument(Arg);
522 CollectUnexpandedParameterPacksVisitor(Unexpanded)
523 .TraverseTemplateArgumentLoc(Arg);
528 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
533 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
539 CollectUnexpandedParameterPacksVisitor(Unexpanded)
540 .TraverseNestedNameSpecifierLoc(NNS);
546 CollectUnexpandedParameterPacksVisitor(Unexpanded)
547 .TraverseDeclarationNameInfo(NameInfo);
581 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
588 llvm_unreachable(
"Unhandled template argument kind?");
608 std::optional<unsigned> NumExpansions) {
612 EllipsisLoc, NumExpansions);
626 std::optional<unsigned> NumExpansions) {
636 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
650 std::optional<unsigned> NumExpansions) {
659 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
674 bool &RetainExpansion, std::optional<unsigned> &NumExpansions) {
676 RetainExpansion =
false;
677 std::pair<IdentifierInfo *, SourceLocation> FirstPack;
678 bool HaveFirstPack =
false;
679 std::optional<unsigned> NumPartialExpansions;
684 unsigned Depth = 0, Index = 0;
686 bool IsVarDeclPack =
false;
690 Depth = TTP->getDepth();
691 Index = TTP->getIndex();
692 Name = TTP->getIdentifier();
695 if (isa<VarDecl>(ND))
696 IsVarDeclPack =
true;
704 unsigned NewPackSize;
709 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
712 if (Instantiation->is<DeclArgumentPack *>()) {
714 NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
718 ShouldExpand =
false;
727 ShouldExpand =
false;
732 NewPackSize = TemplateArgs(Depth, Index).pack_size();
742 unsigned PartialDepth, PartialIndex;
744 if (PartialDepth == Depth && PartialIndex == Index) {
745 RetainExpansion =
true;
747 NumPartialExpansions = NewPackSize;
748 PartiallySubstitutedPackLoc = ParmPack.second;
754 if (!NumExpansions) {
757 NumExpansions = NewPackSize;
758 FirstPack.first = Name;
759 FirstPack.second = ParmPack.second;
760 HaveFirstPack =
true;
764 if (NewPackSize != *NumExpansions) {
769 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
770 << FirstPack.first << Name << *NumExpansions << NewPackSize
773 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
774 << Name << *NumExpansions << NewPackSize
789 if (NumPartialExpansions) {
790 if (NumExpansions && *NumExpansions < *NumPartialExpansions) {
793 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_partial)
794 << PartialPack << *NumPartialExpansions << *NumExpansions
799 NumExpansions = NumPartialExpansions;
807 QualType Pattern = cast<PackExpansionType>(T)->getPattern();
809 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(Pattern);
811 std::optional<unsigned>
Result;
812 for (
unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
819 Depth = TTP->getDepth();
820 Index = TTP->getIndex();
823 if (isa<VarDecl>(ND)) {
827 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
830 if (Instantiation->is<
Decl *>())
835 unsigned Size = Instantiation->get<DeclArgumentPack *>()->size();
836 assert((!
Result || *
Result == Size) &&
"inconsistent pack sizes");
850 unsigned Size = TemplateArgs(Depth, Index).pack_size();
851 assert((!
Result || *
Result == Size) &&
"inconsistent pack sizes");
864#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
865#include "clang/Basic/TransformTypeTraits.def"
912#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
913#include "clang/Basic/OpenCLImageTypes.def"
921 switch (Chunk.
Kind) {
936 for (
unsigned i = 0, e = Chunk.
Fun.
NumParams; i != e; ++i) {
939 assert(!ParamTy.
isNull() &&
"Couldn't parse type?");
970 if (TRC->containsUnexpandedParameterPack())
981 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
986 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
987 return std::make_unique<ParameterPackValidatorCCC>(*
this);
1025 ParameterPackValidatorCCC CCC{};
1030 PDiag(diag::err_sizeof_pack_no_pack_name_suggest) << &Name,
1031 PDiag(diag::note_parameter_pack_here));
1032 ParameterPack = Corrected.getCorrectionDecl();
1046 Diag(NameLoc, diag::err_sizeof_pack_no_pack_name)
1059 std::optional<unsigned> &NumExpansions)
const {
1067 if (!ExpansionTSInfo)
1090 = cast<PackExpansionExpr>(Argument.
getAsExpr());
1113 llvm_unreachable(
"Invalid TemplateArgument Kind!");
1128 Pack = Subst->getArgumentPack();
1130 return std::nullopt;
1135 dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.
getAsExpr()))
1136 Pack = Subst->getArgumentPack();
1137 else if (
auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.
getAsExpr())) {
1139 if (PD->isParameterPack())
1140 return std::nullopt;
1141 return Subst->getNumExpansions();
1143 return std::nullopt;
1149 Pack = Subst->getArgumentPack();
1151 return std::nullopt;
1160 return std::nullopt;
1167 if (Elem.isPackExpansion())
1168 return std::nullopt;
1178 auto *OCE = dyn_cast<CXXOperatorCallExpr>(E);
1179 if ((OCE && OCE->isInfixBinaryOp()) || isa<BinaryOperator>(E) ||
1180 isa<AbstractConditionalOperator>(E)) {
1197 auto DiscardOperands = [&] {
1210 return Diag(EllipsisLoc,
1212 ? diag::err_fold_expression_packs_both_sides
1213 : diag::err_pack_expansion_without_parameter_packs)
1221 Expr *Pack = LHS ? LHS : RHS;
1222 assert(Pack &&
"fold expression with neither LHS nor RHS");
1225 return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1237 if (!Functions.
empty()) {
1243 if (Callee.isInvalid())
1245 ULE = cast<UnresolvedLookupExpr>(Callee.get());
1249 return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1258 std::optional<unsigned> NumExpansions) {
1261 EllipsisLoc, RHS, RParenLoc, NumExpansions);
1286 return Diag(EllipsisLoc, diag::err_fold_expression_empty)
static StringRef getIdentifier(const Token &Tok)
static void CheckFoldOperand(Sema &S, Expr *E)
Defines the clang::TypeLoc interface and its subclasses.
DeclarationNameTable DeclarationNames
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
The result of parsing/analyzing an expression, statement etc.
Attr - This represents one attribute.
bool isPackExpansion() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
StringRef getOpcodeStr() const
Represents a base class of a C++ class.
Represents a C++ base or member initializer.
Represents a folding of a pack over an operator.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
SourceRange getRange() const
SourceLocation getBeginLoc() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
const TypeClass * getTypePtr() const
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A reference to a declared variable, function, enum, etc.
SourceLocation getLocation() const
Captures information about "declaration specifiers".
TST getTypeSpecType() const
ParsedType getRepAsType() const
Expr * getRepAsExpr() const
Decl - This represents one declaration (or definition), e.g.
bool isParameterPack() const
Whether this declaration is a parameter pack.
The name of a declaration.
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
Information about one declarator, including the parsed type information and the identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
This represents one expression.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
const TypeClass * getTypePtr() const
Describes the capture of a variable or of this, or of a C++1y init-capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
Represents the results of name lookup.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
LookupResultKind getResultKind() const
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Data structure that captures multiple levels of template argument lists for use in template instantia...
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
A C++ nested-name-specifier augmented with source location information.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Represents a C++11 pack expansion that produces a sequence of expressions.
Expr * getPattern()
Retrieve the pattern of the pack expansion.
std::optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
void setEllipsisLoc(SourceLocation Loc)
SourceLocation getEllipsisLoc() const
TypeLoc getPatternLoc() const
Represents a pack expansion of types.
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Represents a parameter to a function.
Represents the parsed form of a C++ template argument.
KindType getKind() const
Determine what kind of template argument we have.
SourceLocation getLocation() const
Retrieve the location of the template argument.
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
ParsedType getAsType() const
Retrieve the template type argument's type.
@ Type
A template type parameter, stored as a type.
@ Template
A template template argument, stored as a template name.
@ NonType
A non-type template parameter, stored as an expression.
bool isInvalid() const
Determine whether the given template argument is invalid.
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool TraverseTemplateArgument(const TemplateArgument &Arg)
Recursively visit a template argument and dispatch to the appropriate method for the argument type.
bool TraverseType(QualType T)
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() pr...
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...
bool TraverseTypeLoc(TypeLoc TL)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)
Recursively visit a lambda capture.
bool TraverseAttr(Attr *At)
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic typ...
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Recursively visit a base specifier.
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
SourceLocation getBeginLoc() const LLVM_READONLY
ArrayRef< ParmVarDecl * > getLocalParameters() const
Scope - A scope is a transient data structure that is used while parsing the program.
Sema - This implements semantic analysis and AST building for C.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, bool &RetainExpansion, std::optional< unsigned > &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
bool DiagnoseUnexpandedParameterPackInRequiresExpr(RequiresExpr *RE)
If the given requirees-expression contains an unexpanded reference to one of its own parameter packs,...
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, std::optional< unsigned > &NumExpansions) const
Returns the pattern of the pack expansion for a template argument.
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
bool isUnexpandedParameterPackPermitted()
Determine whether an unexpanded parameter pack might be permitted in this location.
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
std::optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
std::optional< unsigned > getFullyPackExpandedSize(TemplateArgument Arg)
Given a template argument that contains an unexpanded parameter pack, but which has already been subs...
ExprResult CreateUnresolvedLookupExpr(CXXRecordDecl *NamingClass, NestedNameSpecifierLoc NNSLoc, DeclarationNameInfo DNI, const UnresolvedSetImpl &Fns, bool PerformADL=true)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc)
Called when an expression computing the size of a parameter pack is parsed.
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS, tok::TokenKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)
Handle a C++1z fold-expression: ( expr op ... op expr ).
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, std::optional< unsigned > Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs=std::nullopt)
Encodes a location in the source.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
A structure for storing an already-substituted template template parameter pack.
Represents the result of substituting a set of types for a template type parameter pack.
Location wrapper for a TemplateArgument.
SourceLocation getLocation() const
SourceLocation getTemplateEllipsisLoc() const
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
TypeSourceInfo * getTypeSourceInfo() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
std::optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getAsType() const
Retrieve the type for a type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
bool isNull() const
Determine whether this template argument has no value.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
Represents a C++ template name within the type system.
bool isNull() const
Determine whether this template name is NULL.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
bool containsUnexpandedParameterPack() const
Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templ...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
Wrapper for template type parameters.
bool isParameterPack() const
unsigned getDepth() const
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
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
The base class of the type hierarchy.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
const T * getAs() const
Member-template getAs<specific type>'.
Simple class containing the result of Sema::CorrectTypo.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
A set of unresolved declarations.
Represents a dependent using declaration which was marked with typename.
bool isPackExpansion() const
Determine whether this is a pack expansion.
Represents a dependent using declaration which was not marked with typename.
bool isPackExpansion() const
Determine whether this is a pack expansion.
Represents a variable declaration or definition.
Contains information about the compound statement currently being parsed.
Retains information about a function, method, or block that is currently being parsed.
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound stamement scopes in the function.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
@ C
Languages that the frontend can parse and compile.
@ Result
The result type of a method or function.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
@ EST_Dynamic
throw(T1, T2)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
One instance of this struct is used for each type in a declarator that is parsed.
enum clang::DeclaratorChunk::@214 Kind
MemberPointerTypeInfo Mem
An element in an Objective-C dictionary literal.