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
830 const MultiLevelTemplateArgumentList &TemplateArgs) {
831 std::optional<unsigned> Result;
832 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
833 // Compute the depth and index for this parameter pack.
834 unsigned Depth;
835 unsigned Index;
836
837 if (const TemplateTypeParmType *TTP =
838 Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) {
839 Depth = TTP->getDepth();
840 Index = TTP->getIndex();
841 } else {
842 NamedDecl *ND = Unexpanded[I].first.get<NamedDecl *>();
843 if (isa<VarDecl>(ND)) {
844 // Function parameter pack or init-capture pack.
845 typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
846
847 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
849 Unexpanded[I].first.get<NamedDecl *>());
850 if (Instantiation->is<Decl *>())
851 // The pattern refers to an unexpanded pack. We're not ready to expand
852 // this pack yet.
853 return std::nullopt;
854
855 unsigned Size = Instantiation->get<DeclArgumentPack *>()->size();
856 assert((!Result || *Result == Size) && "inconsistent pack sizes");
857 Result = Size;
858 continue;
859 }
860
861 std::tie(Depth, Index) = getDepthAndIndex(ND);
862 }
863 if (Depth >= TemplateArgs.getNumLevels() ||
864 !TemplateArgs.hasTemplateArgument(Depth, Index))
865 // The pattern refers to an unknown template argument. We're not ready to
866 // expand this pack yet.
867 return std::nullopt;
868
869 // Determine the size of the argument pack.
870 unsigned Size = TemplateArgs(Depth, Index).pack_size();
871 assert((!Result || *Result == Size) && "inconsistent pack sizes");
872 Result = Size;
873 }
874
875 return Result;
876}
877
878std::optional<unsigned> Sema::getNumArgumentsInExpansion(
879 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs) {
880 QualType Pattern = cast<PackExpansionType>(T)->getPattern();
882 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(Pattern);
883 return getNumArgumentsInExpansionFromUnexpanded(Unexpanded, TemplateArgs);
884}
885
887 const DeclSpec &DS = D.getDeclSpec();
888 switch (DS.getTypeSpecType()) {
890 case TST_typename:
892 case TST_typeofType:
893#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
894#include "clang/Basic/TransformTypeTraits.def"
895 case TST_atomic: {
896 QualType T = DS.getRepAsType().get();
897 if (!T.isNull() && T->containsUnexpandedParameterPack())
898 return true;
899 break;
900 }
901
903 case TST_typeofExpr:
904 case TST_decltype:
905 case TST_bitint:
906 if (DS.getRepAsExpr() &&
908 return true;
909 break;
910
911 case TST_unspecified:
912 case TST_void:
913 case TST_char:
914 case TST_wchar:
915 case TST_char8:
916 case TST_char16:
917 case TST_char32:
918 case TST_int:
919 case TST_int128:
920 case TST_half:
921 case TST_float:
922 case TST_double:
923 case TST_Accum:
924 case TST_Fract:
925 case TST_Float16:
926 case TST_float128:
927 case TST_ibm128:
928 case TST_bool:
929 case TST_decimal32:
930 case TST_decimal64:
931 case TST_decimal128:
932 case TST_enum:
933 case TST_union:
934 case TST_struct:
935 case TST_interface:
936 case TST_class:
937 case TST_auto:
938 case TST_auto_type:
940 case TST_BFloat16:
941#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
942#include "clang/Basic/OpenCLImageTypes.def"
943#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
944#include "clang/Basic/HLSLIntangibleTypes.def"
946 case TST_error:
947 break;
948 }
949
950 for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) {
951 const DeclaratorChunk &Chunk = D.getTypeObject(I);
952 switch (Chunk.Kind) {
958 // These declarator chunks cannot contain any parameter packs.
959 break;
960
962 if (Chunk.Arr.NumElts &&
964 return true;
965 break;
967 for (unsigned i = 0, e = Chunk.Fun.NumParams; i != e; ++i) {
968 ParmVarDecl *Param = cast<ParmVarDecl>(Chunk.Fun.Params[i].Param);
969 QualType ParamTy = Param->getType();
970 assert(!ParamTy.isNull() && "Couldn't parse type?");
971 if (ParamTy->containsUnexpandedParameterPack()) return true;
972 }
973
974 if (Chunk.Fun.getExceptionSpecType() == EST_Dynamic) {
975 for (unsigned i = 0; i != Chunk.Fun.getNumExceptions(); ++i) {
976 if (Chunk.Fun.Exceptions[i]
977 .Ty.get()
979 return true;
980 }
981 } else if (isComputedNoexcept(Chunk.Fun.getExceptionSpecType()) &&
983 return true;
984
985 if (Chunk.Fun.hasTrailingReturnType()) {
987 if (!T.isNull() && T->containsUnexpandedParameterPack())
988 return true;
989 }
990 break;
991
993 if (Chunk.Mem.Scope().getScopeRep() &&
995 return true;
996 break;
997 }
998 }
999
1000 if (Expr *TRC = D.getTrailingRequiresClause())
1001 if (TRC->containsUnexpandedParameterPack())
1002 return true;
1003
1004 return false;
1005}
1006
1007namespace {
1008
1009// Callback to only accept typo corrections that refer to parameter packs.
1010class ParameterPackValidatorCCC final : public CorrectionCandidateCallback {
1011 public:
1012 bool ValidateCandidate(const TypoCorrection &candidate) override {
1013 NamedDecl *ND = candidate.getCorrectionDecl();
1014 return ND && ND->isParameterPack();
1015 }
1016
1017 std::unique_ptr<CorrectionCandidateCallback> clone() override {
1018 return std::make_unique<ParameterPackValidatorCCC>(*this);
1019 }
1020};
1021
1022}
1023
1025 SourceLocation OpLoc,
1026 IdentifierInfo &Name,
1027 SourceLocation NameLoc,
1028 SourceLocation RParenLoc) {
1029 // C++0x [expr.sizeof]p5:
1030 // The identifier in a sizeof... expression shall name a parameter pack.
1031 LookupResult R(*this, &Name, NameLoc, LookupOrdinaryName);
1032 LookupName(R, S);
1033
1034 NamedDecl *ParameterPack = nullptr;
1035 switch (R.getResultKind()) {
1037 ParameterPack = R.getFoundDecl();
1038 break;
1039
1042 ParameterPackValidatorCCC CCC{};
1043 if (TypoCorrection Corrected =
1044 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, nullptr,
1045 CCC, CTK_ErrorRecovery)) {
1046 diagnoseTypo(Corrected,
1047 PDiag(diag::err_sizeof_pack_no_pack_name_suggest) << &Name,
1048 PDiag(diag::note_parameter_pack_here));
1049 ParameterPack = Corrected.getCorrectionDecl();
1050 }
1051 break;
1052 }
1055 break;
1056
1059 return ExprError();
1060 }
1061
1062 if (!ParameterPack || !ParameterPack->isParameterPack()) {
1063 Diag(NameLoc, diag::err_expected_name_of_pack) << &Name;
1064 return ExprError();
1065 }
1066
1067 MarkAnyDeclReferenced(OpLoc, ParameterPack, true);
1068
1069 return SizeOfPackExpr::Create(Context, OpLoc, ParameterPack, NameLoc,
1070 RParenLoc);
1071}
1072
1073static bool isParameterPack(Expr *PackExpression) {
1074 if (auto *D = dyn_cast<DeclRefExpr>(PackExpression); D) {
1075 ValueDecl *VD = D->getDecl();
1076 return VD->isParameterPack();
1077 }
1078 return false;
1079}
1080
1082 SourceLocation EllipsisLoc,
1083 SourceLocation LSquareLoc,
1084 Expr *IndexExpr,
1085 SourceLocation RSquareLoc) {
1086 bool isParameterPack = ::isParameterPack(PackExpression);
1087 if (!isParameterPack) {
1088 if (!PackExpression->containsErrors()) {
1089 CorrectDelayedTyposInExpr(IndexExpr);
1090 Diag(PackExpression->getBeginLoc(), diag::err_expected_name_of_pack)
1091 << PackExpression;
1092 }
1093 return ExprError();
1094 }
1095 ExprResult Res =
1096 BuildPackIndexingExpr(PackExpression, EllipsisLoc, IndexExpr, RSquareLoc);
1097 if (!Res.isInvalid())
1099 ? diag::warn_cxx23_pack_indexing
1100 : diag::ext_pack_indexing);
1101 return Res;
1102}
1103
1106 Expr *IndexExpr, SourceLocation RSquareLoc,
1107 ArrayRef<Expr *> ExpandedExprs, bool EmptyPack) {
1108
1109 std::optional<int64_t> Index;
1110 if (!IndexExpr->isInstantiationDependent()) {
1111 llvm::APSInt Value(Context.getIntWidth(Context.getSizeType()));
1112
1114 IndexExpr, Context.getSizeType(), Value, CCEK_ArrayBound);
1115 if (!Res.isUsable())
1116 return ExprError();
1117 Index = Value.getExtValue();
1118 IndexExpr = Res.get();
1119 }
1120
1121 if (Index && (!ExpandedExprs.empty() || EmptyPack)) {
1122 if (*Index < 0 || EmptyPack || *Index >= int64_t(ExpandedExprs.size())) {
1123 Diag(PackExpression->getBeginLoc(), diag::err_pack_index_out_of_bound)
1124 << *Index << PackExpression << ExpandedExprs.size();
1125 return ExprError();
1126 }
1127 }
1128
1129 return PackIndexingExpr::Create(getASTContext(), EllipsisLoc, RSquareLoc,
1130 PackExpression, IndexExpr, Index,
1131 ExpandedExprs, EmptyPack);
1132}
1133
1135 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
1136 std::optional<unsigned> &NumExpansions) const {
1137 const TemplateArgument &Argument = OrigLoc.getArgument();
1138 assert(Argument.isPackExpansion());
1139 switch (Argument.getKind()) {
1141 // FIXME: We shouldn't ever have to worry about missing
1142 // type-source info!
1143 TypeSourceInfo *ExpansionTSInfo = OrigLoc.getTypeSourceInfo();
1144 if (!ExpansionTSInfo)
1145 ExpansionTSInfo = Context.getTrivialTypeSourceInfo(Argument.getAsType(),
1146 Ellipsis);
1147 PackExpansionTypeLoc Expansion =
1148 ExpansionTSInfo->getTypeLoc().castAs<PackExpansionTypeLoc>();
1149 Ellipsis = Expansion.getEllipsisLoc();
1150
1151 TypeLoc Pattern = Expansion.getPatternLoc();
1152 NumExpansions = Expansion.getTypePtr()->getNumExpansions();
1153
1154 // We need to copy the TypeLoc because TemplateArgumentLocs store a
1155 // TypeSourceInfo.
1156 // FIXME: Find some way to avoid the copy?
1157 TypeLocBuilder TLB;
1158 TLB.pushFullCopy(Pattern);
1159 TypeSourceInfo *PatternTSInfo =
1160 TLB.getTypeSourceInfo(Context, Pattern.getType());
1162 PatternTSInfo);
1163 }
1164
1166 PackExpansionExpr *Expansion
1167 = cast<PackExpansionExpr>(Argument.getAsExpr());
1168 Expr *Pattern = Expansion->getPattern();
1169 Ellipsis = Expansion->getEllipsisLoc();
1170 NumExpansions = Expansion->getNumExpansions();
1171 return TemplateArgumentLoc(Pattern, Pattern);
1172 }
1173
1175 Ellipsis = OrigLoc.getTemplateEllipsisLoc();
1176 NumExpansions = Argument.getNumTemplateExpansions();
1178 OrigLoc.getTemplateQualifierLoc(),
1179 OrigLoc.getTemplateNameLoc());
1180
1188 return TemplateArgumentLoc();
1189 }
1190
1191 llvm_unreachable("Invalid TemplateArgument Kind!");
1192}
1193
1195 assert(Arg.containsUnexpandedParameterPack());
1196
1197 // If this is a substituted pack, grab that pack. If not, we don't know
1198 // the size yet.
1199 // FIXME: We could find a size in more cases by looking for a substituted
1200 // pack anywhere within this argument, but that's not necessary in the common
1201 // case for 'sizeof...(A)' handling.
1202 TemplateArgument Pack;
1203 switch (Arg.getKind()) {
1205 if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
1206 Pack = Subst->getArgumentPack();
1207 else
1208 return std::nullopt;
1209 break;
1210
1212 if (auto *Subst =
1213 dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.getAsExpr()))
1214 Pack = Subst->getArgumentPack();
1215 else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr())) {
1216 for (VarDecl *PD : *Subst)
1217 if (PD->isParameterPack())
1218 return std::nullopt;
1219 return Subst->getNumExpansions();
1220 } else
1221 return std::nullopt;
1222 break;
1223
1227 Pack = Subst->getArgumentPack();
1228 else
1229 return std::nullopt;
1230 break;
1231
1239 return std::nullopt;
1240 }
1241
1242 // Check that no argument in the pack is itself a pack expansion.
1243 for (TemplateArgument Elem : Pack.pack_elements()) {
1244 // There's no point recursing in this case; we would have already
1245 // expanded this pack expansion into the enclosing pack if we could.
1246 if (Elem.isPackExpansion())
1247 return std::nullopt;
1248 // Don't guess the size of unexpanded packs. The pack within a template
1249 // argument may have yet to be of a PackExpansion type before we see the
1250 // ellipsis in the annotation stage.
1251 //
1252 // This doesn't mean we would invalidate the optimization: Arg can be an
1253 // unexpanded pack regardless of Elem's dependence. For instance,
1254 // A TemplateArgument that contains either a SubstTemplateTypeParmPackType
1255 // or SubstNonTypeTemplateParmPackExpr is always considered Unexpanded, but
1256 // the underlying TemplateArgument thereof may not.
1257 if (Elem.containsUnexpandedParameterPack())
1258 return std::nullopt;
1259 }
1260 return Pack.pack_size();
1261}
1262
1263static void CheckFoldOperand(Sema &S, Expr *E) {
1264 if (!E)
1265 return;
1266
1267 E = E->IgnoreImpCasts();
1268 auto *OCE = dyn_cast<CXXOperatorCallExpr>(E);
1269 if ((OCE && OCE->isInfixBinaryOp()) || isa<BinaryOperator>(E) ||
1270 isa<AbstractConditionalOperator>(E)) {
1271 S.Diag(E->getExprLoc(), diag::err_fold_expression_bad_operand)
1272 << E->getSourceRange()
1275 }
1276}
1277
1279 tok::TokenKind Operator,
1280 SourceLocation EllipsisLoc, Expr *RHS,
1281 SourceLocation RParenLoc) {
1282 // LHS and RHS must be cast-expressions. We allow an arbitrary expression
1283 // in the parser and reduce down to just cast-expressions here.
1284 CheckFoldOperand(*this, LHS);
1285 CheckFoldOperand(*this, RHS);
1286
1287 auto DiscardOperands = [&] {
1290 };
1291
1292 // [expr.prim.fold]p3:
1293 // In a binary fold, op1 and op2 shall be the same fold-operator, and
1294 // either e1 shall contain an unexpanded parameter pack or e2 shall contain
1295 // an unexpanded parameter pack, but not both.
1296 if (LHS && RHS &&
1299 DiscardOperands();
1300 return Diag(EllipsisLoc,
1302 ? diag::err_fold_expression_packs_both_sides
1303 : diag::err_pack_expansion_without_parameter_packs)
1304 << LHS->getSourceRange() << RHS->getSourceRange();
1305 }
1306
1307 // [expr.prim.fold]p2:
1308 // In a unary fold, the cast-expression shall contain an unexpanded
1309 // parameter pack.
1310 if (!LHS || !RHS) {
1311 Expr *Pack = LHS ? LHS : RHS;
1312 assert(Pack && "fold expression with neither LHS nor RHS");
1313 if (!Pack->containsUnexpandedParameterPack()) {
1314 DiscardOperands();
1315 return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1316 << Pack->getSourceRange();
1317 }
1318 }
1319
1320 BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
1321
1322 // Perform first-phase name lookup now.
1323 UnresolvedLookupExpr *ULE = nullptr;
1324 {
1325 UnresolvedSet<16> Functions;
1326 LookupBinOp(S, EllipsisLoc, Opc, Functions);
1327 if (!Functions.empty()) {
1331 /*NamingClass*/ nullptr, NestedNameSpecifierLoc(),
1332 DeclarationNameInfo(OpName, EllipsisLoc), Functions);
1333 if (Callee.isInvalid())
1334 return ExprError();
1335 ULE = cast<UnresolvedLookupExpr>(Callee.get());
1336 }
1337 }
1338
1339 return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1340 std::nullopt);
1341}
1342
1344 SourceLocation LParenLoc, Expr *LHS,
1345 BinaryOperatorKind Operator,
1346 SourceLocation EllipsisLoc, Expr *RHS,
1347 SourceLocation RParenLoc,
1348 std::optional<unsigned> NumExpansions) {
1349 return new (Context)
1350 CXXFoldExpr(Context.DependentTy, Callee, LParenLoc, LHS, Operator,
1351 EllipsisLoc, RHS, RParenLoc, NumExpansions);
1352}
1353
1355 BinaryOperatorKind Operator) {
1356 // [temp.variadic]p9:
1357 // If N is zero for a unary fold-expression, the value of the expression is
1358 // && -> true
1359 // || -> false
1360 // , -> void()
1361 // if the operator is not listed [above], the instantiation is ill-formed.
1362 //
1363 // Note that we need to use something like int() here, not merely 0, to
1364 // prevent the result from being a null pointer constant.
1365 QualType ScalarType;
1366 switch (Operator) {
1367 case BO_LOr:
1368 return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_false);
1369 case BO_LAnd:
1370 return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_true);
1371 case BO_Comma:
1372 ScalarType = Context.VoidTy;
1373 break;
1374
1375 default:
1376 return Diag(EllipsisLoc, diag::err_fold_expression_empty)
1377 << BinaryOperator::getOpcodeStr(Operator);
1378 }
1379
1380 return new (Context) CXXScalarValueInitExpr(
1381 ScalarType, Context.getTrivialTypeSourceInfo(ScalarType, EllipsisLoc),
1382 EllipsisLoc);
1383}
const Decl * D
Expr * E
static StringRef getIdentifier(const Token &Tok)
SourceLocation Loc
Definition: SemaObjC.cpp:759
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:664
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:1147
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:1119
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:3926
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2304
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4839
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:537
ParsedType getRepAsType() const
Definition: DeclSpec.h:547
Expr * getRepAsExpr() const
Definition: DeclSpec.h:555
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:1903
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:1396
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:4179
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4208
std::optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
Definition: ExprCXX.h:4219
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4215
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:6960
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:6985
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:1718
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:493
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6329
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:12656
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:9015
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:900
ASTContext & Context
Definition: Sema.h:962
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:560
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:15085
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)
std::optional< unsigned > getNumArgumentsInExpansionFromUnexpanded(llvm::ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs)
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:13888
@ UPPC_Requirement
Definition: Sema.h:13956
const LangOptions & getLangOpts() const
Definition: Sema.h:553
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:19813
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:9409
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:10027
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:2392
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:2731
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:1694
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:6283
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:6174
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:7721
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:7732
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:2354
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8540
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:3963
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3866
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:104
@ 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:1275
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:216
@ 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:1321
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
Definition: DeclSpec.h:1586
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Definition: DeclSpec.h:1440
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1428
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1589
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1403
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
Definition: DeclSpec.h:1572
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Definition: DeclSpec.h:1567
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1444
One instance of this struct is used for each type in a declarator that is parsed.
Definition: DeclSpec.h:1251
enum clang::DeclaratorChunk::@222 Kind
MemberPointerTypeInfo Mem
Definition: DeclSpec.h:1644
ArrayTypeInfo Arr
Definition: DeclSpec.h:1641
FunctionTypeInfo Fun
Definition: DeclSpec.h:1642
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:262