clang 20.0.0git
SemaTemplateVariadic.cpp
Go to the documentation of this file.
1//===------- SemaTemplateVariadic.cpp - C++ Variadic Templates ------------===/
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//===----------------------------------------------------------------------===/
7//
8// This file implements semantic analysis for C++0x variadic templates.
9//===----------------------------------------------------------------------===/
10
11#include "clang/Sema/Sema.h"
12#include "TypeLocBuilder.h"
13#include "clang/AST/Expr.h"
15#include "clang/AST/TypeLoc.h"
16#include "clang/Sema/Lookup.h"
20#include "clang/Sema/Template.h"
21#include <optional>
22
23using namespace clang;
24
25//----------------------------------------------------------------------------
26// Visitor that collects unexpanded parameter packs
27//----------------------------------------------------------------------------
28
29namespace {
30 /// A class that collects unexpanded parameter packs.
31 class CollectUnexpandedParameterPacksVisitor :
32 public RecursiveASTVisitor<CollectUnexpandedParameterPacksVisitor>
33 {
35 inherited;
36
38
39 bool InLambda = false;
40 unsigned DepthLimit = (unsigned)-1;
41
42 void addUnexpanded(NamedDecl *ND, SourceLocation Loc = SourceLocation()) {
43 if (auto *VD = dyn_cast<VarDecl>(ND)) {
44 // For now, the only problematic case is a generic lambda's templated
45 // call operator, so we don't need to look for all the other ways we
46 // could have reached a dependent parameter pack.
47 auto *FD = dyn_cast<FunctionDecl>(VD->getDeclContext());
48 auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr;
49 if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit)
50 return;
51 } else if (getDepthAndIndex(ND).first >= DepthLimit)
52 return;
53
54 Unexpanded.push_back({ND, Loc});
55 }
56 void addUnexpanded(const TemplateTypeParmType *T,
58 if (T->getDepth() < DepthLimit)
59 Unexpanded.push_back({T, Loc});
60 }
61
62 public:
63 explicit CollectUnexpandedParameterPacksVisitor(
65 : Unexpanded(Unexpanded) {}
66
67 bool shouldWalkTypesOfTypeLocs() const { return false; }
68
69 // We need this so we can find e.g. attributes on lambdas.
70 bool shouldVisitImplicitCode() const { return true; }
71
72 //------------------------------------------------------------------------
73 // Recording occurrences of (unexpanded) parameter packs.
74 //------------------------------------------------------------------------
75
76 /// Record occurrences of template type parameter packs.
77 bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
78 if (TL.getTypePtr()->isParameterPack())
79 addUnexpanded(TL.getTypePtr(), TL.getNameLoc());
80 return true;
81 }
82
83 /// Record occurrences of template type parameter packs
84 /// when we don't have proper source-location information for
85 /// them.
86 ///
87 /// Ideally, this routine would never be used.
88 bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
89 if (T->isParameterPack())
90 addUnexpanded(T);
91
92 return true;
93 }
94
95 /// Record occurrences of function and non-type template
96 /// parameter packs in an expression.
97 bool VisitDeclRefExpr(DeclRefExpr *E) {
98 if (E->getDecl()->isParameterPack())
99 addUnexpanded(E->getDecl(), E->getLocation());
100
101 return true;
102 }
103
104 /// Record occurrences of template template parameter packs.
105 bool TraverseTemplateName(TemplateName Template) {
106 if (auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>(
107 Template.getAsTemplateDecl())) {
108 if (TTP->isParameterPack())
109 addUnexpanded(TTP);
110 }
111
112 return inherited::TraverseTemplateName(Template);
113 }
114
115 /// Suppress traversal into Objective-C container literal
116 /// elements that are pack expansions.
117 bool TraverseObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
119 return true;
120
121 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
122 ObjCDictionaryElement Element = E->getKeyValueElement(I);
123 if (Element.isPackExpansion())
124 continue;
125
126 TraverseStmt(Element.Key);
127 TraverseStmt(Element.Value);
128 }
129 return true;
130 }
131 //------------------------------------------------------------------------
132 // Pruning the search for unexpanded parameter packs.
133 //------------------------------------------------------------------------
134
135 /// Suppress traversal into statements and expressions that
136 /// do not contain unexpanded parameter packs.
137 bool TraverseStmt(Stmt *S) {
138 Expr *E = dyn_cast_or_null<Expr>(S);
139 if ((E && E->containsUnexpandedParameterPack()) || InLambda)
140 return inherited::TraverseStmt(S);
141
142 return true;
143 }
144
145 /// Suppress traversal into types that do not contain
146 /// unexpanded parameter packs.
147 bool TraverseType(QualType T) {
148 if ((!T.isNull() && T->containsUnexpandedParameterPack()) || InLambda)
150
151 return true;
152 }
153
154 /// Suppress traversal into types with location information
155 /// that do not contain unexpanded parameter packs.
156 bool TraverseTypeLoc(TypeLoc TL) {
157 if ((!TL.getType().isNull() &&
159 InLambda)
161
162 return true;
163 }
164
165 /// Suppress traversal of parameter packs.
166 bool TraverseDecl(Decl *D) {
167 // A function parameter pack is a pack expansion, so cannot contain
168 // an unexpanded parameter pack. Likewise for a template parameter
169 // pack that contains any references to other packs.
170 if (D && D->isParameterPack())
171 return true;
172
174 }
175
176 /// Suppress traversal of pack-expanded attributes.
177 bool TraverseAttr(Attr *A) {
178 if (A->isPackExpansion())
179 return true;
180
181 return inherited::TraverseAttr(A);
182 }
183
184 /// Suppress traversal of pack expansion expressions and types.
185 ///@{
186 bool TraversePackExpansionType(PackExpansionType *T) { return true; }
187 bool TraversePackExpansionTypeLoc(PackExpansionTypeLoc TL) { return true; }
188 bool TraversePackExpansionExpr(PackExpansionExpr *E) { return true; }
189 bool TraverseCXXFoldExpr(CXXFoldExpr *E) { return true; }
190 bool TraversePackIndexingExpr(PackIndexingExpr *E) {
191 return inherited::TraverseStmt(E->getIndexExpr());
192 }
193 bool TraversePackIndexingType(PackIndexingType *E) {
194 return inherited::TraverseStmt(E->getIndexExpr());
195 }
196 bool TraversePackIndexingTypeLoc(PackIndexingTypeLoc TL) {
198 }
199
200 ///@}
201
202 /// Suppress traversal of using-declaration pack expansion.
203 bool TraverseUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
204 if (D->isPackExpansion())
205 return true;
206
207 return inherited::TraverseUnresolvedUsingValueDecl(D);
208 }
209
210 /// Suppress traversal of using-declaration pack expansion.
211 bool TraverseUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) {
212 if (D->isPackExpansion())
213 return true;
214
215 return inherited::TraverseUnresolvedUsingTypenameDecl(D);
216 }
217
218 /// Suppress traversal of template argument pack expansions.
220 if (Arg.isPackExpansion())
221 return true;
222
224 }
225
226 /// Suppress traversal of template argument pack expansions.
228 if (ArgLoc.getArgument().isPackExpansion())
229 return true;
230
232 }
233
234 /// Suppress traversal of base specifier pack expansions.
236 if (Base.isPackExpansion())
237 return true;
238
240 }
241
242 /// Suppress traversal of mem-initializer pack expansions.
244 if (Init->isPackExpansion())
245 return true;
246
248 }
249
250 /// Note whether we're traversing a lambda containing an unexpanded
251 /// parameter pack. In this case, the unexpanded pack can occur anywhere,
252 /// including all the places where we normally wouldn't look. Within a
253 /// lambda, we don't propagate the 'contains unexpanded parameter pack' bit
254 /// outside an expression.
255 bool TraverseLambdaExpr(LambdaExpr *Lambda) {
256 // The ContainsUnexpandedParameterPack bit on a lambda is always correct,
257 // even if it's contained within another lambda.
258 if (!Lambda->containsUnexpandedParameterPack())
259 return true;
260
261 bool WasInLambda = InLambda;
262 unsigned OldDepthLimit = DepthLimit;
263
264 InLambda = true;
265 if (auto *TPL = Lambda->getTemplateParameterList())
266 DepthLimit = TPL->getDepth();
267
268 inherited::TraverseLambdaExpr(Lambda);
269
270 InLambda = WasInLambda;
271 DepthLimit = OldDepthLimit;
272 return true;
273 }
274
275 /// Suppress traversal within pack expansions in lambda captures.
276 bool TraverseLambdaCapture(LambdaExpr *Lambda, const LambdaCapture *C,
277 Expr *Init) {
278 if (C->isPackExpansion())
279 return true;
280
281 return inherited::TraverseLambdaCapture(Lambda, C, Init);
282 }
283 };
284}
285
286/// Determine whether it's possible for an unexpanded parameter pack to
287/// be valid in this location. This only happens when we're in a declaration
288/// that is nested within an expression that could be expanded, such as a
289/// lambda-expression within a function call.
290///
291/// This is conservatively correct, but may claim that some unexpanded packs are
292/// permitted when they are not.
294 for (auto *SI : FunctionScopes)
295 if (isa<sema::LambdaScopeInfo>(SI))
296 return true;
297 return false;
298}
299
300/// Diagnose all of the unexpanded parameter packs in the given
301/// vector.
302bool
306 if (Unexpanded.empty())
307 return false;
308
309 // If we are within a lambda expression and referencing a pack that is not
310 // declared within the lambda itself, that lambda contains an unexpanded
311 // parameter pack, and we are done.
312 // FIXME: Store 'Unexpanded' on the lambda so we don't need to recompute it
313 // later.
314 SmallVector<UnexpandedParameterPack, 4> LambdaParamPackReferences;
315 if (auto *LSI = getEnclosingLambda()) {
316 for (auto &Pack : Unexpanded) {
317 auto DeclaresThisPack = [&](NamedDecl *LocalPack) {
318 if (auto *TTPT = Pack.first.dyn_cast<const TemplateTypeParmType *>()) {
319 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(LocalPack);
320 return TTPD && TTPD->getTypeForDecl() == TTPT;
321 }
322 return declaresSameEntity(Pack.first.get<NamedDecl *>(), LocalPack);
323 };
324 if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
325 LambdaParamPackReferences.push_back(Pack);
326 }
327
328 if (LambdaParamPackReferences.empty()) {
329 // Construct in lambda only references packs declared outside the lambda.
330 // That's OK for now, but the lambda itself is considered to contain an
331 // unexpanded pack in this case, which will require expansion outside the
332 // lambda.
333
334 // We do not permit pack expansion that would duplicate a statement
335 // expression, not even within a lambda.
336 // FIXME: We could probably support this for statement expressions that
337 // do not contain labels.
338 // FIXME: This is insufficient to detect this problem; consider
339 // f( ({ bad: 0; }) + pack ... );
340 bool EnclosingStmtExpr = false;
341 for (unsigned N = FunctionScopes.size(); N; --N) {
343 if (llvm::any_of(
344 Func->CompoundScopes,
345 [](sema::CompoundScopeInfo &CSI) { return CSI.IsStmtExpr; })) {
346 EnclosingStmtExpr = true;
347 break;
348 }
349 // Coumpound-statements outside the lambda are OK for now; we'll check
350 // for those when we finish handling the lambda.
351 if (Func == LSI)
352 break;
353 }
354
355 if (!EnclosingStmtExpr) {
356 LSI->ContainsUnexpandedParameterPack = true;
357 return false;
358 }
359 } else {
360 Unexpanded = LambdaParamPackReferences;
361 }
362 }
363
367
368 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
369 IdentifierInfo *Name = nullptr;
370 if (const TemplateTypeParmType *TTP
371 = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>())
372 Name = TTP->getIdentifier();
373 else
374 Name = Unexpanded[I].first.get<NamedDecl *>()->getIdentifier();
375
376 if (Name && NamesKnown.insert(Name).second)
377 Names.push_back(Name);
378
379 if (Unexpanded[I].second.isValid())
380 Locations.push_back(Unexpanded[I].second);
381 }
382
383 auto DB = Diag(Loc, diag::err_unexpanded_parameter_pack)
384 << (int)UPPC << (int)Names.size();
385 for (size_t I = 0, E = std::min(Names.size(), (size_t)2); I != E; ++I)
386 DB << Names[I];
387
388 for (unsigned I = 0, N = Locations.size(); I != N; ++I)
389 DB << SourceRange(Locations[I]);
390 return true;
391}
392
396 // C++0x [temp.variadic]p5:
397 // An appearance of a name of a parameter pack that is not expanded is
398 // ill-formed.
399 if (!T->getType()->containsUnexpandedParameterPack())
400 return false;
401
403 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(
404 T->getTypeLoc());
405 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
406 return DiagnoseUnexpandedParameterPacks(Loc, UPPC, Unexpanded);
407}
408
411 // C++0x [temp.variadic]p5:
412 // An appearance of a name of a parameter pack that is not expanded is
413 // ill-formed.
415 return false;
416
417 // CollectUnexpandedParameterPacksVisitor does not expect to see a
418 // FunctionParmPackExpr, but diagnosing unexpected parameter packs may still
419 // see such an expression in a lambda body.
420 // We'll bail out early in this case to avoid triggering an assertion.
421 if (isa<FunctionParmPackExpr>(E) && getEnclosingLambda())
422 return false;
423
425 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(E);
426 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
427 return DiagnoseUnexpandedParameterPacks(E->getBeginLoc(), UPPC, Unexpanded);
428}
429
432 return false;
433
435 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(RE);
436 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
437
438 // We only care about unexpanded references to the RequiresExpr's own
439 // parameter packs.
440 auto Parms = RE->getLocalParameters();
441 llvm::SmallPtrSet<NamedDecl*, 8> ParmSet(Parms.begin(), Parms.end());
443 for (auto Parm : Unexpanded)
444 if (ParmSet.contains(Parm.first.dyn_cast<NamedDecl *>()))
445 UnexpandedParms.push_back(Parm);
446 if (UnexpandedParms.empty())
447 return false;
448
450 UnexpandedParms);
451}
452
455 // C++0x [temp.variadic]p5:
456 // An appearance of a name of a parameter pack that is not expanded is
457 // ill-formed.
458 if (!SS.getScopeRep() ||
460 return false;
461
463 CollectUnexpandedParameterPacksVisitor(Unexpanded)
464 .TraverseNestedNameSpecifier(SS.getScopeRep());
465 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
467 UPPC, Unexpanded);
468}
469
472 // C++0x [temp.variadic]p5:
473 // An appearance of a name of a parameter pack that is not expanded is
474 // ill-formed.
475 switch (NameInfo.getName().getNameKind()) {
484 return false;
485
489 // FIXME: We shouldn't need this null check!
490 if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
491 return DiagnoseUnexpandedParameterPack(NameInfo.getLoc(), TSInfo, UPPC);
492
494 return false;
495
496 break;
497 }
498
500 CollectUnexpandedParameterPacksVisitor(Unexpanded)
501 .TraverseType(NameInfo.getName().getCXXNameType());
502 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
503 return DiagnoseUnexpandedParameterPacks(NameInfo.getLoc(), UPPC, Unexpanded);
504}
505
507 TemplateName Template,
509
510 if (Template.isNull() || !Template.containsUnexpandedParameterPack())
511 return false;
512
514 CollectUnexpandedParameterPacksVisitor(Unexpanded)
515 .TraverseTemplateName(Template);
516 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
517 return DiagnoseUnexpandedParameterPacks(Loc, UPPC, Unexpanded);
518}
519
522 if (Arg.getArgument().isNull() ||
524 return false;
525
527 CollectUnexpandedParameterPacksVisitor(Unexpanded)
528 .TraverseTemplateArgumentLoc(Arg);
529 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
530 return DiagnoseUnexpandedParameterPacks(Arg.getLocation(), UPPC, Unexpanded);
531}
532
535 CollectUnexpandedParameterPacksVisitor(Unexpanded)
536 .TraverseTemplateArgument(Arg);
537}
538
541 CollectUnexpandedParameterPacksVisitor(Unexpanded)
542 .TraverseTemplateArgumentLoc(Arg);
543}
544
547 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
548}
549
552 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
553}
554
558 CollectUnexpandedParameterPacksVisitor(Unexpanded)
559 .TraverseNestedNameSpecifierLoc(NNS);
560}
561
563 const DeclarationNameInfo &NameInfo,
565 CollectUnexpandedParameterPacksVisitor(Unexpanded)
566 .TraverseDeclarationNameInfo(NameInfo);
567}
568
571 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(E);
572}
573
576 SourceLocation EllipsisLoc) {
577 if (Arg.isInvalid())
578 return Arg;
579
580 switch (Arg.getKind()) {
582 TypeResult Result = ActOnPackExpansion(Arg.getAsType(), EllipsisLoc);
583 if (Result.isInvalid())
584 return ParsedTemplateArgument();
585
586 return ParsedTemplateArgument(Arg.getKind(), Result.get().getAsOpaquePtr(),
587 Arg.getLocation());
588 }
589
591 ExprResult Result = ActOnPackExpansion(Arg.getAsExpr(), EllipsisLoc);
592 if (Result.isInvalid())
593 return ParsedTemplateArgument();
594
595 return ParsedTemplateArgument(Arg.getKind(), Result.get(),
596 Arg.getLocation());
597 }
598
601 SourceRange R(Arg.getLocation());
602 if (Arg.getScopeSpec().isValid())
604 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
605 << R;
606 return ParsedTemplateArgument();
607 }
608
609 return Arg.getTemplatePackExpansion(EllipsisLoc);
610 }
611 llvm_unreachable("Unhandled template argument kind?");
612}
613
615 SourceLocation EllipsisLoc) {
616 TypeSourceInfo *TSInfo;
617 GetTypeFromParser(Type, &TSInfo);
618 if (!TSInfo)
619 return true;
620
621 TypeSourceInfo *TSResult =
622 CheckPackExpansion(TSInfo, EllipsisLoc, std::nullopt);
623 if (!TSResult)
624 return true;
625
626 return CreateParsedType(TSResult->getType(), TSResult);
627}
628
631 std::optional<unsigned> NumExpansions) {
632 // Create the pack expansion type and source-location information.
634 Pattern->getTypeLoc().getSourceRange(),
635 EllipsisLoc, NumExpansions);
636 if (Result.isNull())
637 return nullptr;
638
639 TypeLocBuilder TLB;
640 TLB.pushFullCopy(Pattern->getTypeLoc());
642 TL.setEllipsisLoc(EllipsisLoc);
643
644 return TLB.getTypeSourceInfo(Context, Result);
645}
646
648 SourceLocation EllipsisLoc,
649 std::optional<unsigned> NumExpansions) {
650 // C++11 [temp.variadic]p5:
651 // The pattern of a pack expansion shall name one or more
652 // parameter packs that are not expanded by a nested pack
653 // expansion.
654 //
655 // A pattern containing a deduced type can't occur "naturally" but arises in
656 // the desugaring of an init-capture pack.
657 if (!Pattern->containsUnexpandedParameterPack() &&
658 !Pattern->getContainedDeducedType()) {
659 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
660 << PatternRange;
661 return QualType();
662 }
663
664 return Context.getPackExpansionType(Pattern, NumExpansions,
665 /*ExpectPackInType=*/false);
666}
667
669 return CheckPackExpansion(Pattern, EllipsisLoc, std::nullopt);
670}
671
673 std::optional<unsigned> NumExpansions) {
674 if (!Pattern)
675 return ExprError();
676
677 // C++0x [temp.variadic]p5:
678 // The pattern of a pack expansion shall name one or more
679 // parameter packs that are not expanded by a nested pack
680 // expansion.
681 if (!Pattern->containsUnexpandedParameterPack()) {
682 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
683 << Pattern->getSourceRange();
685 return ExprError();
686 }
687
688 // Create the pack expansion expression and source-location information.
689 return new (Context)
690 PackExpansionExpr(Context.DependentTy, Pattern, EllipsisLoc, NumExpansions);
691}
692
694 SourceLocation EllipsisLoc, SourceRange PatternRange,
696 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
697 bool &RetainExpansion, std::optional<unsigned> &NumExpansions) {
698 ShouldExpand = true;
699 RetainExpansion = false;
700 std::pair<IdentifierInfo *, SourceLocation> FirstPack;
701 bool HaveFirstPack = false;
702 std::optional<unsigned> NumPartialExpansions;
703 SourceLocation PartiallySubstitutedPackLoc;
704
705 for (UnexpandedParameterPack ParmPack : Unexpanded) {
706 // Compute the depth and index for this parameter pack.
707 unsigned Depth = 0, Index = 0;
708 IdentifierInfo *Name;
709 bool IsVarDeclPack = false;
710
711 if (const TemplateTypeParmType *TTP =
712 ParmPack.first.dyn_cast<const TemplateTypeParmType *>()) {
713 Depth = TTP->getDepth();
714 Index = TTP->getIndex();
715 Name = TTP->getIdentifier();
716 } else {
717 NamedDecl *ND = ParmPack.first.get<NamedDecl *>();
718 if (isa<VarDecl>(ND))
719 IsVarDeclPack = true;
720 else
721 std::tie(Depth, Index) = getDepthAndIndex(ND);
722
723 Name = ND->getIdentifier();
724 }
725
726 // Determine the size of this argument pack.
727 unsigned NewPackSize;
728 if (IsVarDeclPack) {
729 // Figure out whether we're instantiating to an argument pack or not.
730 typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
731
732 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
734 ParmPack.first.get<NamedDecl *>());
735 if (Instantiation->is<DeclArgumentPack *>()) {
736 // We could expand this function parameter pack.
737 NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
738 } else {
739 // We can't expand this function parameter pack, so we can't expand
740 // the pack expansion.
741 ShouldExpand = false;
742 continue;
743 }
744 } else {
745 // If we don't have a template argument at this depth/index, then we
746 // cannot expand the pack expansion. Make a note of this, but we still
747 // want to check any parameter packs we *do* have arguments for.
748 if (Depth >= TemplateArgs.getNumLevels() ||
749 !TemplateArgs.hasTemplateArgument(Depth, Index)) {
750 ShouldExpand = false;
751 continue;
752 }
753
754 // Determine the size of the argument pack.
755 NewPackSize = TemplateArgs(Depth, Index).pack_size();
756 }
757
758 // C++0x [temp.arg.explicit]p9:
759 // Template argument deduction can extend the sequence of template
760 // arguments corresponding to a template parameter pack, even when the
761 // sequence contains explicitly specified template arguments.
762 if (!IsVarDeclPack && CurrentInstantiationScope) {
763 if (NamedDecl *PartialPack =
765 unsigned PartialDepth, PartialIndex;
766 std::tie(PartialDepth, PartialIndex) = getDepthAndIndex(PartialPack);
767 if (PartialDepth == Depth && PartialIndex == Index) {
768 RetainExpansion = true;
769 // We don't actually know the new pack size yet.
770 NumPartialExpansions = NewPackSize;
771 PartiallySubstitutedPackLoc = ParmPack.second;
772 continue;
773 }
774 }
775 }
776
777 if (!NumExpansions) {
778 // The is the first pack we've seen for which we have an argument.
779 // Record it.
780 NumExpansions = NewPackSize;
781 FirstPack.first = Name;
782 FirstPack.second = ParmPack.second;
783 HaveFirstPack = true;
784 continue;
785 }
786
787 if (NewPackSize != *NumExpansions) {
788 // C++0x [temp.variadic]p5:
789 // All of the parameter packs expanded by a pack expansion shall have
790 // the same number of arguments specified.
791 if (HaveFirstPack)
792 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
793 << FirstPack.first << Name << *NumExpansions << NewPackSize
794 << SourceRange(FirstPack.second) << SourceRange(ParmPack.second);
795 else
796 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
797 << Name << *NumExpansions << NewPackSize
798 << SourceRange(ParmPack.second);
799 return true;
800 }
801 }
802
803 // If we're performing a partial expansion but we also have a full expansion,
804 // expand to the number of common arguments. For example, given:
805 //
806 // template<typename ...T> struct A {
807 // template<typename ...U> void f(pair<T, U>...);
808 // };
809 //
810 // ... a call to 'A<int, int>().f<int>' should expand the pack once and
811 // retain an expansion.
812 if (NumPartialExpansions) {
813 if (NumExpansions && *NumExpansions < *NumPartialExpansions) {
814 NamedDecl *PartialPack =
816 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_partial)
817 << PartialPack << *NumPartialExpansions << *NumExpansions
818 << SourceRange(PartiallySubstitutedPackLoc);
819 return true;
820 }
821
822 NumExpansions = NumPartialExpansions;
823 }
824
825 return false;
826}
827
828std::optional<unsigned> Sema::getNumArgumentsInExpansion(
829 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs) {
830 QualType Pattern = cast<PackExpansionType>(T)->getPattern();
832 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(Pattern);
833
834 std::optional<unsigned> Result;
835 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
836 // Compute the depth and index for this parameter pack.
837 unsigned Depth;
838 unsigned Index;
839
840 if (const TemplateTypeParmType *TTP =
841 Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) {
842 Depth = TTP->getDepth();
843 Index = TTP->getIndex();
844 } else {
845 NamedDecl *ND = Unexpanded[I].first.get<NamedDecl *>();
846 if (isa<VarDecl>(ND)) {
847 // Function parameter pack or init-capture pack.
848 typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
849
850 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
852 Unexpanded[I].first.get<NamedDecl *>());
853 if (Instantiation->is<Decl *>())
854 // The pattern refers to an unexpanded pack. We're not ready to expand
855 // this pack yet.
856 return std::nullopt;
857
858 unsigned Size = Instantiation->get<DeclArgumentPack *>()->size();
859 assert((!Result || *Result == Size) && "inconsistent pack sizes");
860 Result = Size;
861 continue;
862 }
863
864 std::tie(Depth, Index) = getDepthAndIndex(ND);
865 }
866 if (Depth >= TemplateArgs.getNumLevels() ||
867 !TemplateArgs.hasTemplateArgument(Depth, Index))
868 // The pattern refers to an unknown template argument. We're not ready to
869 // expand this pack yet.
870 return std::nullopt;
871
872 // Determine the size of the argument pack.
873 unsigned Size = TemplateArgs(Depth, Index).pack_size();
874 assert((!Result || *Result == Size) && "inconsistent pack sizes");
875 Result = Size;
876 }
877
878 return Result;
879}
880
882 const DeclSpec &DS = D.getDeclSpec();
883 switch (DS.getTypeSpecType()) {
885 case TST_typename:
887 case TST_typeofType:
888#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
889#include "clang/Basic/TransformTypeTraits.def"
890 case TST_atomic: {
891 QualType T = DS.getRepAsType().get();
892 if (!T.isNull() && T->containsUnexpandedParameterPack())
893 return true;
894 break;
895 }
896
898 case TST_typeofExpr:
899 case TST_decltype:
900 case TST_bitint:
901 if (DS.getRepAsExpr() &&
903 return true;
904 break;
905
906 case TST_unspecified:
907 case TST_void:
908 case TST_char:
909 case TST_wchar:
910 case TST_char8:
911 case TST_char16:
912 case TST_char32:
913 case TST_int:
914 case TST_int128:
915 case TST_half:
916 case TST_float:
917 case TST_double:
918 case TST_Accum:
919 case TST_Fract:
920 case TST_Float16:
921 case TST_float128:
922 case TST_ibm128:
923 case TST_bool:
924 case TST_decimal32:
925 case TST_decimal64:
926 case TST_decimal128:
927 case TST_enum:
928 case TST_union:
929 case TST_struct:
930 case TST_interface:
931 case TST_class:
932 case TST_auto:
933 case TST_auto_type:
935 case TST_BFloat16:
936#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
937#include "clang/Basic/OpenCLImageTypes.def"
939 case TST_error:
940 break;
941 }
942
943 for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) {
944 const DeclaratorChunk &Chunk = D.getTypeObject(I);
945 switch (Chunk.Kind) {
951 // These declarator chunks cannot contain any parameter packs.
952 break;
953
955 if (Chunk.Arr.NumElts &&
957 return true;
958 break;
960 for (unsigned i = 0, e = Chunk.Fun.NumParams; i != e; ++i) {
961 ParmVarDecl *Param = cast<ParmVarDecl>(Chunk.Fun.Params[i].Param);
962 QualType ParamTy = Param->getType();
963 assert(!ParamTy.isNull() && "Couldn't parse type?");
964 if (ParamTy->containsUnexpandedParameterPack()) return true;
965 }
966
967 if (Chunk.Fun.getExceptionSpecType() == EST_Dynamic) {
968 for (unsigned i = 0; i != Chunk.Fun.getNumExceptions(); ++i) {
969 if (Chunk.Fun.Exceptions[i]
970 .Ty.get()
972 return true;
973 }
974 } else if (isComputedNoexcept(Chunk.Fun.getExceptionSpecType()) &&
976 return true;
977
978 if (Chunk.Fun.hasTrailingReturnType()) {
980 if (!T.isNull() && T->containsUnexpandedParameterPack())
981 return true;
982 }
983 break;
984
986 if (Chunk.Mem.Scope().getScopeRep() &&
988 return true;
989 break;
990 }
991 }
992
993 if (Expr *TRC = D.getTrailingRequiresClause())
994 if (TRC->containsUnexpandedParameterPack())
995 return true;
996
997 return false;
998}
999
1000namespace {
1001
1002// Callback to only accept typo corrections that refer to parameter packs.
1003class ParameterPackValidatorCCC final : public CorrectionCandidateCallback {
1004 public:
1005 bool ValidateCandidate(const TypoCorrection &candidate) override {
1006 NamedDecl *ND = candidate.getCorrectionDecl();
1007 return ND && ND->isParameterPack();
1008 }
1009
1010 std::unique_ptr<CorrectionCandidateCallback> clone() override {
1011 return std::make_unique<ParameterPackValidatorCCC>(*this);
1012 }
1013};
1014
1015}
1016
1018 SourceLocation OpLoc,
1019 IdentifierInfo &Name,
1020 SourceLocation NameLoc,
1021 SourceLocation RParenLoc) {
1022 // C++0x [expr.sizeof]p5:
1023 // The identifier in a sizeof... expression shall name a parameter pack.
1024 LookupResult R(*this, &Name, NameLoc, LookupOrdinaryName);
1025 LookupName(R, S);
1026
1027 NamedDecl *ParameterPack = nullptr;
1028 switch (R.getResultKind()) {
1030 ParameterPack = R.getFoundDecl();
1031 break;
1032
1035 ParameterPackValidatorCCC CCC{};
1036 if (TypoCorrection Corrected =
1037 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, nullptr,
1038 CCC, CTK_ErrorRecovery)) {
1039 diagnoseTypo(Corrected,
1040 PDiag(diag::err_sizeof_pack_no_pack_name_suggest) << &Name,
1041 PDiag(diag::note_parameter_pack_here));
1042 ParameterPack = Corrected.getCorrectionDecl();
1043 }
1044 break;
1045 }
1048 break;
1049
1052 return ExprError();
1053 }
1054
1055 if (!ParameterPack || !ParameterPack->isParameterPack()) {
1056 Diag(NameLoc, diag::err_expected_name_of_pack) << &Name;
1057 return ExprError();
1058 }
1059
1060 MarkAnyDeclReferenced(OpLoc, ParameterPack, true);
1061
1062 return SizeOfPackExpr::Create(Context, OpLoc, ParameterPack, NameLoc,
1063 RParenLoc);
1064}
1065
1066static bool isParameterPack(Expr *PackExpression) {
1067 if (auto *D = dyn_cast<DeclRefExpr>(PackExpression); D) {
1068 ValueDecl *VD = D->getDecl();
1069 return VD->isParameterPack();
1070 }
1071 return false;
1072}
1073
1075 SourceLocation EllipsisLoc,
1076 SourceLocation LSquareLoc,
1077 Expr *IndexExpr,
1078 SourceLocation RSquareLoc) {
1079 bool isParameterPack = ::isParameterPack(PackExpression);
1080 if (!isParameterPack) {
1081 if (!PackExpression->containsErrors()) {
1082 CorrectDelayedTyposInExpr(IndexExpr);
1083 Diag(PackExpression->getBeginLoc(), diag::err_expected_name_of_pack)
1084 << PackExpression;
1085 }
1086 return ExprError();
1087 }
1088 ExprResult Res =
1089 BuildPackIndexingExpr(PackExpression, EllipsisLoc, IndexExpr, RSquareLoc);
1090 if (!Res.isInvalid())
1092 ? diag::warn_cxx23_pack_indexing
1093 : diag::ext_pack_indexing);
1094 return Res;
1095}
1096
1099 Expr *IndexExpr, SourceLocation RSquareLoc,
1100 ArrayRef<Expr *> ExpandedExprs, bool EmptyPack) {
1101
1102 std::optional<int64_t> Index;
1103 if (!IndexExpr->isInstantiationDependent()) {
1104 llvm::APSInt Value(Context.getIntWidth(Context.getSizeType()));
1105
1107 IndexExpr, Context.getSizeType(), Value, CCEK_ArrayBound);
1108 if (!Res.isUsable())
1109 return ExprError();
1110 Index = Value.getExtValue();
1111 IndexExpr = Res.get();
1112 }
1113
1114 if (Index && (!ExpandedExprs.empty() || EmptyPack)) {
1115 if (*Index < 0 || EmptyPack || *Index >= int64_t(ExpandedExprs.size())) {
1116 Diag(PackExpression->getBeginLoc(), diag::err_pack_index_out_of_bound)
1117 << *Index << PackExpression << ExpandedExprs.size();
1118 return ExprError();
1119 }
1120 }
1121
1122 return PackIndexingExpr::Create(getASTContext(), EllipsisLoc, RSquareLoc,
1123 PackExpression, IndexExpr, Index,
1124 ExpandedExprs, EmptyPack);
1125}
1126
1128 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
1129 std::optional<unsigned> &NumExpansions) const {
1130 const TemplateArgument &Argument = OrigLoc.getArgument();
1131 assert(Argument.isPackExpansion());
1132 switch (Argument.getKind()) {
1134 // FIXME: We shouldn't ever have to worry about missing
1135 // type-source info!
1136 TypeSourceInfo *ExpansionTSInfo = OrigLoc.getTypeSourceInfo();
1137 if (!ExpansionTSInfo)
1138 ExpansionTSInfo = Context.getTrivialTypeSourceInfo(Argument.getAsType(),
1139 Ellipsis);
1140 PackExpansionTypeLoc Expansion =
1141 ExpansionTSInfo->getTypeLoc().castAs<PackExpansionTypeLoc>();
1142 Ellipsis = Expansion.getEllipsisLoc();
1143
1144 TypeLoc Pattern = Expansion.getPatternLoc();
1145 NumExpansions = Expansion.getTypePtr()->getNumExpansions();
1146
1147 // We need to copy the TypeLoc because TemplateArgumentLocs store a
1148 // TypeSourceInfo.
1149 // FIXME: Find some way to avoid the copy?
1150 TypeLocBuilder TLB;
1151 TLB.pushFullCopy(Pattern);
1152 TypeSourceInfo *PatternTSInfo =
1153 TLB.getTypeSourceInfo(Context, Pattern.getType());
1155 PatternTSInfo);
1156 }
1157
1159 PackExpansionExpr *Expansion
1160 = cast<PackExpansionExpr>(Argument.getAsExpr());
1161 Expr *Pattern = Expansion->getPattern();
1162 Ellipsis = Expansion->getEllipsisLoc();
1163 NumExpansions = Expansion->getNumExpansions();
1164 return TemplateArgumentLoc(Pattern, Pattern);
1165 }
1166
1168 Ellipsis = OrigLoc.getTemplateEllipsisLoc();
1169 NumExpansions = Argument.getNumTemplateExpansions();
1171 OrigLoc.getTemplateQualifierLoc(),
1172 OrigLoc.getTemplateNameLoc());
1173
1181 return TemplateArgumentLoc();
1182 }
1183
1184 llvm_unreachable("Invalid TemplateArgument Kind!");
1185}
1186
1188 assert(Arg.containsUnexpandedParameterPack());
1189
1190 // If this is a substituted pack, grab that pack. If not, we don't know
1191 // the size yet.
1192 // FIXME: We could find a size in more cases by looking for a substituted
1193 // pack anywhere within this argument, but that's not necessary in the common
1194 // case for 'sizeof...(A)' handling.
1195 TemplateArgument Pack;
1196 switch (Arg.getKind()) {
1198 if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
1199 Pack = Subst->getArgumentPack();
1200 else
1201 return std::nullopt;
1202 break;
1203
1205 if (auto *Subst =
1206 dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.getAsExpr()))
1207 Pack = Subst->getArgumentPack();
1208 else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr())) {
1209 for (VarDecl *PD : *Subst)
1210 if (PD->isParameterPack())
1211 return std::nullopt;
1212 return Subst->getNumExpansions();
1213 } else
1214 return std::nullopt;
1215 break;
1216
1220 Pack = Subst->getArgumentPack();
1221 else
1222 return std::nullopt;
1223 break;
1224
1232 return std::nullopt;
1233 }
1234
1235 // Check that no argument in the pack is itself a pack expansion.
1236 for (TemplateArgument Elem : Pack.pack_elements()) {
1237 // There's no point recursing in this case; we would have already
1238 // expanded this pack expansion into the enclosing pack if we could.
1239 if (Elem.isPackExpansion())
1240 return std::nullopt;
1241 // Don't guess the size of unexpanded packs. The pack within a template
1242 // argument may have yet to be of a PackExpansion type before we see the
1243 // ellipsis in the annotation stage.
1244 //
1245 // This doesn't mean we would invalidate the optimization: Arg can be an
1246 // unexpanded pack regardless of Elem's dependence. For instance,
1247 // A TemplateArgument that contains either a SubstTemplateTypeParmPackType
1248 // or SubstNonTypeTemplateParmPackExpr is always considered Unexpanded, but
1249 // the underlying TemplateArgument thereof may not.
1250 if (Elem.containsUnexpandedParameterPack())
1251 return std::nullopt;
1252 }
1253 return Pack.pack_size();
1254}
1255
1256static void CheckFoldOperand(Sema &S, Expr *E) {
1257 if (!E)
1258 return;
1259
1260 E = E->IgnoreImpCasts();
1261 auto *OCE = dyn_cast<CXXOperatorCallExpr>(E);
1262 if ((OCE && OCE->isInfixBinaryOp()) || isa<BinaryOperator>(E) ||
1263 isa<AbstractConditionalOperator>(E)) {
1264 S.Diag(E->getExprLoc(), diag::err_fold_expression_bad_operand)
1265 << E->getSourceRange()
1268 }
1269}
1270
1272 tok::TokenKind Operator,
1273 SourceLocation EllipsisLoc, Expr *RHS,
1274 SourceLocation RParenLoc) {
1275 // LHS and RHS must be cast-expressions. We allow an arbitrary expression
1276 // in the parser and reduce down to just cast-expressions here.
1277 CheckFoldOperand(*this, LHS);
1278 CheckFoldOperand(*this, RHS);
1279
1280 auto DiscardOperands = [&] {
1283 };
1284
1285 // [expr.prim.fold]p3:
1286 // In a binary fold, op1 and op2 shall be the same fold-operator, and
1287 // either e1 shall contain an unexpanded parameter pack or e2 shall contain
1288 // an unexpanded parameter pack, but not both.
1289 if (LHS && RHS &&
1292 DiscardOperands();
1293 return Diag(EllipsisLoc,
1295 ? diag::err_fold_expression_packs_both_sides
1296 : diag::err_pack_expansion_without_parameter_packs)
1297 << LHS->getSourceRange() << RHS->getSourceRange();
1298 }
1299
1300 // [expr.prim.fold]p2:
1301 // In a unary fold, the cast-expression shall contain an unexpanded
1302 // parameter pack.
1303 if (!LHS || !RHS) {
1304 Expr *Pack = LHS ? LHS : RHS;
1305 assert(Pack && "fold expression with neither LHS nor RHS");
1306 if (!Pack->containsUnexpandedParameterPack()) {
1307 DiscardOperands();
1308 return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1309 << Pack->getSourceRange();
1310 }
1311 }
1312
1313 BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
1314
1315 // Perform first-phase name lookup now.
1316 UnresolvedLookupExpr *ULE = nullptr;
1317 {
1318 UnresolvedSet<16> Functions;
1319 LookupBinOp(S, EllipsisLoc, Opc, Functions);
1320 if (!Functions.empty()) {
1324 /*NamingClass*/ nullptr, NestedNameSpecifierLoc(),
1325 DeclarationNameInfo(OpName, EllipsisLoc), Functions);
1326 if (Callee.isInvalid())
1327 return ExprError();
1328 ULE = cast<UnresolvedLookupExpr>(Callee.get());
1329 }
1330 }
1331
1332 return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1333 std::nullopt);
1334}
1335
1337 SourceLocation LParenLoc, Expr *LHS,
1338 BinaryOperatorKind Operator,
1339 SourceLocation EllipsisLoc, Expr *RHS,
1340 SourceLocation RParenLoc,
1341 std::optional<unsigned> NumExpansions) {
1342 return new (Context)
1343 CXXFoldExpr(Context.DependentTy, Callee, LParenLoc, LHS, Operator,
1344 EllipsisLoc, RHS, RParenLoc, NumExpansions);
1345}
1346
1348 BinaryOperatorKind Operator) {
1349 // [temp.variadic]p9:
1350 // If N is zero for a unary fold-expression, the value of the expression is
1351 // && -> true
1352 // || -> false
1353 // , -> void()
1354 // if the operator is not listed [above], the instantiation is ill-formed.
1355 //
1356 // Note that we need to use something like int() here, not merely 0, to
1357 // prevent the result from being a null pointer constant.
1358 QualType ScalarType;
1359 switch (Operator) {
1360 case BO_LOr:
1361 return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_false);
1362 case BO_LAnd:
1363 return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_true);
1364 case BO_Comma:
1365 ScalarType = Context.VoidTy;
1366 break;
1367
1368 default:
1369 return Diag(EllipsisLoc, diag::err_fold_expression_empty)
1370 << BinaryOperator::getOpcodeStr(Operator);
1371 }
1372
1373 return new (Context) CXXScalarValueInitExpr(
1374 ScalarType, Context.getTrivialTypeSourceInfo(ScalarType, EllipsisLoc),
1375 EllipsisLoc);
1376}
const Decl * D
Expr * E
static StringRef getIdentifier(const Token &Tok)
SourceLocation Loc
Definition: SemaObjC.cpp:758
static void CheckFoldOperand(Sema &S, Expr *E)
static bool isParameterPack(Expr *PackExpression)
Defines the clang::TypeLoc interface and its subclasses.
__device__ int
unsigned getIntWidth(QualType T) const
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:663
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
CanQualType DependentTy
Definition: ASTContext.h:1146
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CanQualType VoidTy
Definition: ASTContext.h:1118
The result of parsing/analyzing an expression, statement etc.
Definition: Ownership.h:153
PtrTy get() const
Definition: Ownership.h:170
bool isInvalid() const
Definition: Ownership.h:166
bool isUsable() const
Definition: Ownership.h:168
Attr - This represents one attribute.
Definition: Attr.h:42
bool isPackExpansion() const
Definition: Attr.h:105
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition: Expr.cpp:2181
StringRef getOpcodeStr() const
Definition: Expr.h:3925
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2300
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4838
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Definition: ExprCXX.h:2181
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:74
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Definition: DeclSpec.h:215
SourceRange getRange() const
Definition: DeclSpec.h:80
SourceLocation getBeginLoc() const
Definition: DeclSpec.h:84
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:95
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:421
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.
Definition: Expr.h:1265
Captures information about "declaration specifiers".
Definition: DeclSpec.h:247
TST getTypeSpecType() const
Definition: DeclSpec.h:534
ParsedType getRepAsType() const
Definition: DeclSpec.h:544
Expr * getRepAsExpr() const
Definition: DeclSpec.h:552
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:242
DeclarationName getCXXOperatorName(OverloadedOperatorKind Op)
Get the name of the overloadable C++ operator corresponding to Op.
The name of a declaration.
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.
Definition: DeclSpec.h:1900
This represents one expression.
Definition: Expr.h:110
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Definition: Expr.h:239
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
Definition: Expr.h:245
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Definition: Expr.h:221
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:3050
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:277
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.
Definition: Diagnostic.h:97
One of these records is kept for each identifier that is lexed.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:514
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1954
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition: ExprCXX.cpp:1393
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.
Definition: Lookup.h:46
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
Definition: Lookup.h:63
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
Definition: Lookup.h:68
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition: Lookup.h:73
@ NotFound
No entity found met the criteria.
Definition: Lookup.h:50
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition: Lookup.h:55
@ Found
Name lookup found a single declaration that met the criteria.
Definition: Lookup.h:59
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Definition: Lookup.h:568
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Definition: Lookup.h:275
LookupResultKind getResultKind() const
Definition: Lookup.h:344
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Definition: Lookup.h:255
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition: Template.h:76
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
Definition: Template.h:175
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
Definition: Template.h:123
This represents a decl that may have a name.
Definition: Decl.h:249
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:270
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...
Definition: ExprObjC.h:309
PtrTy get() const
Definition: Ownership.h:80
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4178
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4207
std::optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
Definition: ExprCXX.h:4218
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4214
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2582
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2578
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2594
Represents a pack expansion of types.
Definition: Type.h:6953
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:6978
static PackIndexingExpr * Create(ASTContext &Context, SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr, std::optional< int64_t > Index, ArrayRef< Expr * > SubstitutedExprs={}, bool ExpandedToEmptyPack=false)
Definition: ExprCXX.cpp:1715
Expr * getIndexExpr() const
Definition: TypeLoc.h:2108
Represents a parameter to a function.
Definition: Decl.h:1722
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.
Definition: Type.h:941
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:1008
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 shouldVisitImplicitCode() const
Return whether this visitor should recurse into implicit code, e.g., implicit constructors and destru...
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...
Definition: ExprConcepts.h:510
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprConcepts.h:586
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:550
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:41
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: SemaBase.cpp:60
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaBase.cpp:32
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:535
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6321
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:12637
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....
Definition: Sema.h:8999
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:940
ASTContext & Context
Definition: Sema.h:1002
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
Definition: Sema.h:600
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)
Definition: SemaExpr.cpp:15062
TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, std::optional< unsigned > &NumExpansions) const
Returns the pattern of the pack expansion for a template argument.
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:13869
@ UPPC_Requirement
Definition: Sema.h:13937
const LangOptions & getLangOpts() const
Definition: Sema.h:593
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.
Definition: SemaExpr.cpp:19790
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 ActOnPackIndexingExpr(Scope *S, Expr *PackExpression, SourceLocation EllipsisLoc, SourceLocation LSquareLoc, Expr *IndexExpr, SourceLocation RSquareLoc)
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool EmptyPack=false)
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.
@ CTK_ErrorRecovery
Definition: Sema.h:9393
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:10011
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
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.
Definition: Sema.cpp:2372
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)
Definition: SemaType.cpp:2723
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)
Definition: ExprCXX.cpp:1691
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.
Definition: Stmt.h:84
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:350
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:326
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:338
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:141
Represents the result of substituting a set of types for a template type parameter pack.
Definition: Type.h:6276
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
SourceLocation getLocation() const
Definition: TemplateBase.h:563
SourceLocation getTemplateEllipsisLoc() const
Definition: TemplateBase.h:623
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:574
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:616
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:578
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:609
Represents a template argument.
Definition: TemplateBase.h:61
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:408
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.
Definition: TemplateBase.h:319
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:343
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.
Definition: TemplateBase.h:298
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:438
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:432
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:74
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:93
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
Definition: TemplateBase.h:89
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:107
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:97
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:78
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:67
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:82
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:103
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:295
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
Represents a C++ template name within the type system.
Definition: TemplateName.h:203
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.
Definition: TypeLoc.h:758
bool isParameterPack() const
Definition: Type.h:6167
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.
Definition: TypeLoc.h:59
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:133
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition: TypeLoc.h:78
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:153
A container of type source information.
Definition: Type.h:7714
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:256
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:7725
SourceLocation getNameLoc() const
Definition: TypeLoc.h:535
The base class of the type hierarchy.
Definition: Type.h:1829
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.cpp:2011
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:2336
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8516
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...
Definition: ExprCXX.h:3202
A set of unresolved declarations.
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3959
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3862
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:667
QualType getType() const
Definition: Decl.h:678
Represents a variable declaration or definition.
Definition: Decl.h:879
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:67
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:104
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:25
The JSON file list parser is used to communicate input to InstallAPI.
@ TST_typeof_unqualType
Definition: Specifiers.h:87
@ TST_ibm128
Definition: Specifiers.h:74
@ TST_decimal64
Definition: Specifiers.h:77
@ TST_float
Definition: Specifiers.h:71
@ TST_auto_type
Definition: Specifiers.h:94
@ TST_auto
Definition: Specifiers.h:92
@ TST_typeof_unqualExpr
Definition: Specifiers.h:88
@ TST_decimal32
Definition: Specifiers.h:76
@ TST_int128
Definition: Specifiers.h:64
@ TST_atomic
Definition: Specifiers.h:96
@ TST_half
Definition: Specifiers.h:66
@ TST_decltype
Definition: Specifiers.h:89
@ TST_typename_pack_indexing
Definition: Specifiers.h:97
@ TST_char32
Definition: Specifiers.h:62
@ TST_struct
Definition: Specifiers.h:81
@ TST_typeofType
Definition: Specifiers.h:85
@ TST_bitint
Definition: Specifiers.h:65
@ TST_wchar
Definition: Specifiers.h:59
@ TST_BFloat16
Definition: Specifiers.h:70
@ TST_char16
Definition: Specifiers.h:61
@ TST_char
Definition: Specifiers.h:58
@ TST_unspecified
Definition: Specifiers.h:56
@ TST_class
Definition: Specifiers.h:82
@ TST_union
Definition: Specifiers.h:80
@ TST_Fract
Definition: Specifiers.h:69
@ TST_float128
Definition: Specifiers.h:73
@ TST_double
Definition: Specifiers.h:72
@ TST_Accum
Definition: Specifiers.h:68
@ TST_int
Definition: Specifiers.h:63
@ TST_bool
Definition: Specifiers.h:75
@ TST_typeofExpr
Definition: Specifiers.h:86
@ TST_typename
Definition: Specifiers.h:84
@ TST_void
Definition: Specifiers.h:57
@ TST_unknown_anytype
Definition: Specifiers.h:95
@ TST_enum
Definition: Specifiers.h:79
@ TST_error
Definition: Specifiers.h:101
@ TST_decltype_auto
Definition: Specifiers.h:93
@ TST_interface
Definition: Specifiers.h:83
@ TST_Float16
Definition: Specifiers.h:67
@ TST_char8
Definition: Specifiers.h:60
@ TST_decimal128
Definition: Specifiers.h:78
@ CPlusPlus26
Definition: LangStandard.h:62
BinaryOperatorKind
@ Result
The result type of a method or function.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
ExprResult ExprError()
Definition: Ownership.h:264
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
Definition: SemaInternal.h:61
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1264
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:258
@ 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.
Definition: DeclSpec.h:1318
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
Definition: DeclSpec.h:1583
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Definition: DeclSpec.h:1437
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1425
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1586
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1400
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
Definition: DeclSpec.h:1569
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Definition: DeclSpec.h:1564
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1441
One instance of this struct is used for each type in a declarator that is parsed.
Definition: DeclSpec.h:1248
enum clang::DeclaratorChunk::@225 Kind
MemberPointerTypeInfo Mem
Definition: DeclSpec.h:1641
ArrayTypeInfo Arr
Definition: DeclSpec.h:1638
FunctionTypeInfo Fun
Definition: DeclSpec.h:1639
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:262