clang 19.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 //------------------------------------------------------------------------
70 // Recording occurrences of (unexpanded) parameter packs.
71 //------------------------------------------------------------------------
72
73 /// Record occurrences of template type parameter packs.
74 bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
75 if (TL.getTypePtr()->isParameterPack())
76 addUnexpanded(TL.getTypePtr(), TL.getNameLoc());
77 return true;
78 }
79
80 /// Record occurrences of template type parameter packs
81 /// when we don't have proper source-location information for
82 /// them.
83 ///
84 /// Ideally, this routine would never be used.
85 bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
86 if (T->isParameterPack())
87 addUnexpanded(T);
88
89 return true;
90 }
91
92 /// Record occurrences of function and non-type template
93 /// parameter packs in an expression.
94 bool VisitDeclRefExpr(DeclRefExpr *E) {
95 if (E->getDecl()->isParameterPack())
96 addUnexpanded(E->getDecl(), E->getLocation());
97
98 return true;
99 }
100
101 /// Record occurrences of template template parameter packs.
102 bool TraverseTemplateName(TemplateName Template) {
103 if (auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>(
104 Template.getAsTemplateDecl())) {
105 if (TTP->isParameterPack())
106 addUnexpanded(TTP);
107 }
108
109 return inherited::TraverseTemplateName(Template);
110 }
111
112 /// Suppress traversal into Objective-C container literal
113 /// elements that are pack expansions.
114 bool TraverseObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
116 return true;
117
118 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
120 if (Element.isPackExpansion())
121 continue;
122
123 TraverseStmt(Element.Key);
124 TraverseStmt(Element.Value);
125 }
126 return true;
127 }
128 //------------------------------------------------------------------------
129 // Pruning the search for unexpanded parameter packs.
130 //------------------------------------------------------------------------
131
132 /// Suppress traversal into statements and expressions that
133 /// do not contain unexpanded parameter packs.
134 bool TraverseStmt(Stmt *S) {
135 Expr *E = dyn_cast_or_null<Expr>(S);
136 if ((E && E->containsUnexpandedParameterPack()) || InLambda)
137 return inherited::TraverseStmt(S);
138
139 return true;
140 }
141
142 /// Suppress traversal into types that do not contain
143 /// unexpanded parameter packs.
144 bool TraverseType(QualType T) {
145 if ((!T.isNull() && T->containsUnexpandedParameterPack()) || InLambda)
146 return inherited::TraverseType(T);
147
148 return true;
149 }
150
151 /// Suppress traversal into types with location information
152 /// that do not contain unexpanded parameter packs.
153 bool TraverseTypeLoc(TypeLoc TL) {
154 if ((!TL.getType().isNull() &&
156 InLambda)
158
159 return true;
160 }
161
162 /// Suppress traversal of parameter packs.
163 bool TraverseDecl(Decl *D) {
164 // A function parameter pack is a pack expansion, so cannot contain
165 // an unexpanded parameter pack. Likewise for a template parameter
166 // pack that contains any references to other packs.
167 if (D && D->isParameterPack())
168 return true;
169
170 return inherited::TraverseDecl(D);
171 }
172
173 /// Suppress traversal of pack-expanded attributes.
174 bool TraverseAttr(Attr *A) {
175 if (A->isPackExpansion())
176 return true;
177
178 return inherited::TraverseAttr(A);
179 }
180
181 /// Suppress traversal of pack expansion expressions and types.
182 ///@{
183 bool TraversePackExpansionType(PackExpansionType *T) { return true; }
184 bool TraversePackExpansionTypeLoc(PackExpansionTypeLoc TL) { return true; }
185 bool TraversePackExpansionExpr(PackExpansionExpr *E) { return true; }
186 bool TraverseCXXFoldExpr(CXXFoldExpr *E) { return true; }
187 bool TraversePackIndexingExpr(PackIndexingExpr *E) {
189 }
190 bool TraversePackIndexingType(PackIndexingType *E) {
192 }
193 bool TraversePackIndexingTypeLoc(PackIndexingTypeLoc TL) {
195 }
196
197 ///@}
198
199 /// Suppress traversal of using-declaration pack expansion.
200 bool TraverseUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
201 if (D->isPackExpansion())
202 return true;
203
204 return inherited::TraverseUnresolvedUsingValueDecl(D);
205 }
206
207 /// Suppress traversal of using-declaration pack expansion.
208 bool TraverseUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) {
209 if (D->isPackExpansion())
210 return true;
211
212 return inherited::TraverseUnresolvedUsingTypenameDecl(D);
213 }
214
215 /// Suppress traversal of template argument pack expansions.
217 if (Arg.isPackExpansion())
218 return true;
219
221 }
222
223 /// Suppress traversal of template argument pack expansions.
225 if (ArgLoc.getArgument().isPackExpansion())
226 return true;
227
229 }
230
231 /// Suppress traversal of base specifier pack expansions.
233 if (Base.isPackExpansion())
234 return true;
235
237 }
238
239 /// Suppress traversal of mem-initializer pack expansions.
241 if (Init->isPackExpansion())
242 return true;
243
245 }
246
247 /// Note whether we're traversing a lambda containing an unexpanded
248 /// parameter pack. In this case, the unexpanded pack can occur anywhere,
249 /// including all the places where we normally wouldn't look. Within a
250 /// lambda, we don't propagate the 'contains unexpanded parameter pack' bit
251 /// outside an expression.
252 bool TraverseLambdaExpr(LambdaExpr *Lambda) {
253 // The ContainsUnexpandedParameterPack bit on a lambda is always correct,
254 // even if it's contained within another lambda.
255 if (!Lambda->containsUnexpandedParameterPack())
256 return true;
257
258 bool WasInLambda = InLambda;
259 unsigned OldDepthLimit = DepthLimit;
260
261 InLambda = true;
262 if (auto *TPL = Lambda->getTemplateParameterList())
263 DepthLimit = TPL->getDepth();
264
265 inherited::TraverseLambdaExpr(Lambda);
266
267 InLambda = WasInLambda;
268 DepthLimit = OldDepthLimit;
269 return true;
270 }
271
272 /// Suppress traversal within pack expansions in lambda captures.
273 bool TraverseLambdaCapture(LambdaExpr *Lambda, const LambdaCapture *C,
274 Expr *Init) {
275 if (C->isPackExpansion())
276 return true;
277
278 return inherited::TraverseLambdaCapture(Lambda, C, Init);
279 }
280 };
281}
282
283/// Determine whether it's possible for an unexpanded parameter pack to
284/// be valid in this location. This only happens when we're in a declaration
285/// that is nested within an expression that could be expanded, such as a
286/// lambda-expression within a function call.
287///
288/// This is conservatively correct, but may claim that some unexpanded packs are
289/// permitted when they are not.
291 for (auto *SI : FunctionScopes)
292 if (isa<sema::LambdaScopeInfo>(SI))
293 return true;
294 return false;
295}
296
297/// Diagnose all of the unexpanded parameter packs in the given
298/// vector.
299bool
303 if (Unexpanded.empty())
304 return false;
305
306 // If we are within a lambda expression and referencing a pack that is not
307 // declared within the lambda itself, that lambda contains an unexpanded
308 // parameter pack, and we are done.
309 // FIXME: Store 'Unexpanded' on the lambda so we don't need to recompute it
310 // later.
311 SmallVector<UnexpandedParameterPack, 4> LambdaParamPackReferences;
312 if (auto *LSI = getEnclosingLambda()) {
313 for (auto &Pack : Unexpanded) {
314 auto DeclaresThisPack = [&](NamedDecl *LocalPack) {
315 if (auto *TTPT = Pack.first.dyn_cast<const TemplateTypeParmType *>()) {
316 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(LocalPack);
317 return TTPD && TTPD->getTypeForDecl() == TTPT;
318 }
319 return declaresSameEntity(Pack.first.get<NamedDecl *>(), LocalPack);
320 };
321 if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
322 LambdaParamPackReferences.push_back(Pack);
323 }
324
325 if (LambdaParamPackReferences.empty()) {
326 // Construct in lambda only references packs declared outside the lambda.
327 // That's OK for now, but the lambda itself is considered to contain an
328 // unexpanded pack in this case, which will require expansion outside the
329 // lambda.
330
331 // We do not permit pack expansion that would duplicate a statement
332 // expression, not even within a lambda.
333 // FIXME: We could probably support this for statement expressions that
334 // do not contain labels.
335 // FIXME: This is insufficient to detect this problem; consider
336 // f( ({ bad: 0; }) + pack ... );
337 bool EnclosingStmtExpr = false;
338 for (unsigned N = FunctionScopes.size(); N; --N) {
340 if (llvm::any_of(
341 Func->CompoundScopes,
342 [](sema::CompoundScopeInfo &CSI) { return CSI.IsStmtExpr; })) {
343 EnclosingStmtExpr = true;
344 break;
345 }
346 // Coumpound-statements outside the lambda are OK for now; we'll check
347 // for those when we finish handling the lambda.
348 if (Func == LSI)
349 break;
350 }
351
352 if (!EnclosingStmtExpr) {
353 LSI->ContainsUnexpandedParameterPack = true;
354 return false;
355 }
356 } else {
357 Unexpanded = LambdaParamPackReferences;
358 }
359 }
360
364
365 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
366 IdentifierInfo *Name = nullptr;
367 if (const TemplateTypeParmType *TTP
368 = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>())
369 Name = TTP->getIdentifier();
370 else
371 Name = Unexpanded[I].first.get<NamedDecl *>()->getIdentifier();
372
373 if (Name && NamesKnown.insert(Name).second)
374 Names.push_back(Name);
375
376 if (Unexpanded[I].second.isValid())
377 Locations.push_back(Unexpanded[I].second);
378 }
379
380 auto DB = Diag(Loc, diag::err_unexpanded_parameter_pack)
381 << (int)UPPC << (int)Names.size();
382 for (size_t I = 0, E = std::min(Names.size(), (size_t)2); I != E; ++I)
383 DB << Names[I];
384
385 for (unsigned I = 0, N = Locations.size(); I != N; ++I)
386 DB << SourceRange(Locations[I]);
387 return true;
388}
389
393 // C++0x [temp.variadic]p5:
394 // An appearance of a name of a parameter pack that is not expanded is
395 // ill-formed.
397 return false;
398
400 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(
401 T->getTypeLoc());
402 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
403 return DiagnoseUnexpandedParameterPacks(Loc, UPPC, Unexpanded);
404}
405
408 // C++0x [temp.variadic]p5:
409 // An appearance of a name of a parameter pack that is not expanded is
410 // ill-formed.
412 return false;
413
414 // CollectUnexpandedParameterPacksVisitor does not expect to see a
415 // FunctionParmPackExpr, but diagnosing unexpected parameter packs may still
416 // see such an expression in a lambda body.
417 // We'll bail out early in this case to avoid triggering an assertion.
418 if (isa<FunctionParmPackExpr>(E) && getEnclosingLambda())
419 return false;
420
422 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(E);
423 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
424 return DiagnoseUnexpandedParameterPacks(E->getBeginLoc(), UPPC, Unexpanded);
425}
426
429 return false;
430
432 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(RE);
433 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
434
435 // We only care about unexpanded references to the RequiresExpr's own
436 // parameter packs.
437 auto Parms = RE->getLocalParameters();
438 llvm::SmallPtrSet<NamedDecl*, 8> ParmSet(Parms.begin(), Parms.end());
440 for (auto Parm : Unexpanded)
441 if (ParmSet.contains(Parm.first.dyn_cast<NamedDecl *>()))
442 UnexpandedParms.push_back(Parm);
443 if (UnexpandedParms.empty())
444 return false;
445
447 UnexpandedParms);
448}
449
452 // C++0x [temp.variadic]p5:
453 // An appearance of a name of a parameter pack that is not expanded is
454 // ill-formed.
455 if (!SS.getScopeRep() ||
457 return false;
458
460 CollectUnexpandedParameterPacksVisitor(Unexpanded)
461 .TraverseNestedNameSpecifier(SS.getScopeRep());
462 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
464 UPPC, Unexpanded);
465}
466
469 // C++0x [temp.variadic]p5:
470 // An appearance of a name of a parameter pack that is not expanded is
471 // ill-formed.
472 switch (NameInfo.getName().getNameKind()) {
481 return false;
482
486 // FIXME: We shouldn't need this null check!
487 if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
488 return DiagnoseUnexpandedParameterPack(NameInfo.getLoc(), TSInfo, UPPC);
489
491 return false;
492
493 break;
494 }
495
497 CollectUnexpandedParameterPacksVisitor(Unexpanded)
498 .TraverseType(NameInfo.getName().getCXXNameType());
499 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
500 return DiagnoseUnexpandedParameterPacks(NameInfo.getLoc(), UPPC, Unexpanded);
501}
502
504 TemplateName Template,
506
507 if (Template.isNull() || !Template.containsUnexpandedParameterPack())
508 return false;
509
511 CollectUnexpandedParameterPacksVisitor(Unexpanded)
512 .TraverseTemplateName(Template);
513 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
514 return DiagnoseUnexpandedParameterPacks(Loc, UPPC, Unexpanded);
515}
516
519 if (Arg.getArgument().isNull() ||
521 return false;
522
524 CollectUnexpandedParameterPacksVisitor(Unexpanded)
525 .TraverseTemplateArgumentLoc(Arg);
526 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
527 return DiagnoseUnexpandedParameterPacks(Arg.getLocation(), UPPC, Unexpanded);
528}
529
532 CollectUnexpandedParameterPacksVisitor(Unexpanded)
533 .TraverseTemplateArgument(Arg);
534}
535
538 CollectUnexpandedParameterPacksVisitor(Unexpanded)
539 .TraverseTemplateArgumentLoc(Arg);
540}
541
544 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
545}
546
549 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
550}
551
555 CollectUnexpandedParameterPacksVisitor(Unexpanded)
556 .TraverseNestedNameSpecifierLoc(NNS);
557}
558
560 const DeclarationNameInfo &NameInfo,
562 CollectUnexpandedParameterPacksVisitor(Unexpanded)
563 .TraverseDeclarationNameInfo(NameInfo);
564}
565
566
569 SourceLocation EllipsisLoc) {
570 if (Arg.isInvalid())
571 return Arg;
572
573 switch (Arg.getKind()) {
575 TypeResult Result = ActOnPackExpansion(Arg.getAsType(), EllipsisLoc);
576 if (Result.isInvalid())
577 return ParsedTemplateArgument();
578
579 return ParsedTemplateArgument(Arg.getKind(), Result.get().getAsOpaquePtr(),
580 Arg.getLocation());
581 }
582
584 ExprResult Result = ActOnPackExpansion(Arg.getAsExpr(), EllipsisLoc);
585 if (Result.isInvalid())
586 return ParsedTemplateArgument();
587
588 return ParsedTemplateArgument(Arg.getKind(), Result.get(),
589 Arg.getLocation());
590 }
591
594 SourceRange R(Arg.getLocation());
595 if (Arg.getScopeSpec().isValid())
597 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
598 << R;
599 return ParsedTemplateArgument();
600 }
601
602 return Arg.getTemplatePackExpansion(EllipsisLoc);
603 }
604 llvm_unreachable("Unhandled template argument kind?");
605}
606
608 SourceLocation EllipsisLoc) {
609 TypeSourceInfo *TSInfo;
610 GetTypeFromParser(Type, &TSInfo);
611 if (!TSInfo)
612 return true;
613
614 TypeSourceInfo *TSResult =
615 CheckPackExpansion(TSInfo, EllipsisLoc, std::nullopt);
616 if (!TSResult)
617 return true;
618
619 return CreateParsedType(TSResult->getType(), TSResult);
620}
621
624 std::optional<unsigned> NumExpansions) {
625 // Create the pack expansion type and source-location information.
627 Pattern->getTypeLoc().getSourceRange(),
628 EllipsisLoc, NumExpansions);
629 if (Result.isNull())
630 return nullptr;
631
632 TypeLocBuilder TLB;
633 TLB.pushFullCopy(Pattern->getTypeLoc());
635 TL.setEllipsisLoc(EllipsisLoc);
636
637 return TLB.getTypeSourceInfo(Context, Result);
638}
639
641 SourceLocation EllipsisLoc,
642 std::optional<unsigned> NumExpansions) {
643 // C++11 [temp.variadic]p5:
644 // The pattern of a pack expansion shall name one or more
645 // parameter packs that are not expanded by a nested pack
646 // expansion.
647 //
648 // A pattern containing a deduced type can't occur "naturally" but arises in
649 // the desugaring of an init-capture pack.
650 if (!Pattern->containsUnexpandedParameterPack() &&
651 !Pattern->getContainedDeducedType()) {
652 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
653 << PatternRange;
654 return QualType();
655 }
656
657 return Context.getPackExpansionType(Pattern, NumExpansions,
658 /*ExpectPackInType=*/false);
659}
660
662 return CheckPackExpansion(Pattern, EllipsisLoc, std::nullopt);
663}
664
666 std::optional<unsigned> NumExpansions) {
667 if (!Pattern)
668 return ExprError();
669
670 // C++0x [temp.variadic]p5:
671 // The pattern of a pack expansion shall name one or more
672 // parameter packs that are not expanded by a nested pack
673 // expansion.
674 if (!Pattern->containsUnexpandedParameterPack()) {
675 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
676 << Pattern->getSourceRange();
678 return ExprError();
679 }
680
681 // Create the pack expansion expression and source-location information.
682 return new (Context)
683 PackExpansionExpr(Context.DependentTy, Pattern, EllipsisLoc, NumExpansions);
684}
685
687 SourceLocation EllipsisLoc, SourceRange PatternRange,
689 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
690 bool &RetainExpansion, std::optional<unsigned> &NumExpansions) {
691 ShouldExpand = true;
692 RetainExpansion = false;
693 std::pair<IdentifierInfo *, SourceLocation> FirstPack;
694 bool HaveFirstPack = false;
695 std::optional<unsigned> NumPartialExpansions;
696 SourceLocation PartiallySubstitutedPackLoc;
697
698 for (UnexpandedParameterPack ParmPack : Unexpanded) {
699 // Compute the depth and index for this parameter pack.
700 unsigned Depth = 0, Index = 0;
701 IdentifierInfo *Name;
702 bool IsVarDeclPack = false;
703
704 if (const TemplateTypeParmType *TTP =
705 ParmPack.first.dyn_cast<const TemplateTypeParmType *>()) {
706 Depth = TTP->getDepth();
707 Index = TTP->getIndex();
708 Name = TTP->getIdentifier();
709 } else {
710 NamedDecl *ND = ParmPack.first.get<NamedDecl *>();
711 if (isa<VarDecl>(ND))
712 IsVarDeclPack = true;
713 else
714 std::tie(Depth, Index) = getDepthAndIndex(ND);
715
716 Name = ND->getIdentifier();
717 }
718
719 // Determine the size of this argument pack.
720 unsigned NewPackSize;
721 if (IsVarDeclPack) {
722 // Figure out whether we're instantiating to an argument pack or not.
723 typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
724
725 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
727 ParmPack.first.get<NamedDecl *>());
728 if (Instantiation->is<DeclArgumentPack *>()) {
729 // We could expand this function parameter pack.
730 NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
731 } else {
732 // We can't expand this function parameter pack, so we can't expand
733 // the pack expansion.
734 ShouldExpand = false;
735 continue;
736 }
737 } else {
738 // If we don't have a template argument at this depth/index, then we
739 // cannot expand the pack expansion. Make a note of this, but we still
740 // want to check any parameter packs we *do* have arguments for.
741 if (Depth >= TemplateArgs.getNumLevels() ||
742 !TemplateArgs.hasTemplateArgument(Depth, Index)) {
743 ShouldExpand = false;
744 continue;
745 }
746
747 // Determine the size of the argument pack.
748 NewPackSize = TemplateArgs(Depth, Index).pack_size();
749 }
750
751 // C++0x [temp.arg.explicit]p9:
752 // Template argument deduction can extend the sequence of template
753 // arguments corresponding to a template parameter pack, even when the
754 // sequence contains explicitly specified template arguments.
755 if (!IsVarDeclPack && CurrentInstantiationScope) {
756 if (NamedDecl *PartialPack =
758 unsigned PartialDepth, PartialIndex;
759 std::tie(PartialDepth, PartialIndex) = getDepthAndIndex(PartialPack);
760 if (PartialDepth == Depth && PartialIndex == Index) {
761 RetainExpansion = true;
762 // We don't actually know the new pack size yet.
763 NumPartialExpansions = NewPackSize;
764 PartiallySubstitutedPackLoc = ParmPack.second;
765 continue;
766 }
767 }
768 }
769
770 if (!NumExpansions) {
771 // The is the first pack we've seen for which we have an argument.
772 // Record it.
773 NumExpansions = NewPackSize;
774 FirstPack.first = Name;
775 FirstPack.second = ParmPack.second;
776 HaveFirstPack = true;
777 continue;
778 }
779
780 if (NewPackSize != *NumExpansions) {
781 // C++0x [temp.variadic]p5:
782 // All of the parameter packs expanded by a pack expansion shall have
783 // the same number of arguments specified.
784 if (HaveFirstPack)
785 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
786 << FirstPack.first << Name << *NumExpansions << NewPackSize
787 << SourceRange(FirstPack.second) << SourceRange(ParmPack.second);
788 else
789 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
790 << Name << *NumExpansions << NewPackSize
791 << SourceRange(ParmPack.second);
792 return true;
793 }
794 }
795
796 // If we're performing a partial expansion but we also have a full expansion,
797 // expand to the number of common arguments. For example, given:
798 //
799 // template<typename ...T> struct A {
800 // template<typename ...U> void f(pair<T, U>...);
801 // };
802 //
803 // ... a call to 'A<int, int>().f<int>' should expand the pack once and
804 // retain an expansion.
805 if (NumPartialExpansions) {
806 if (NumExpansions && *NumExpansions < *NumPartialExpansions) {
807 NamedDecl *PartialPack =
809 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_partial)
810 << PartialPack << *NumPartialExpansions << *NumExpansions
811 << SourceRange(PartiallySubstitutedPackLoc);
812 return true;
813 }
814
815 NumExpansions = NumPartialExpansions;
816 }
817
818 return false;
819}
820
821std::optional<unsigned> Sema::getNumArgumentsInExpansion(
822 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs) {
823 QualType Pattern = cast<PackExpansionType>(T)->getPattern();
825 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(Pattern);
826
827 std::optional<unsigned> Result;
828 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
829 // Compute the depth and index for this parameter pack.
830 unsigned Depth;
831 unsigned Index;
832
833 if (const TemplateTypeParmType *TTP =
834 Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) {
835 Depth = TTP->getDepth();
836 Index = TTP->getIndex();
837 } else {
838 NamedDecl *ND = Unexpanded[I].first.get<NamedDecl *>();
839 if (isa<VarDecl>(ND)) {
840 // Function parameter pack or init-capture pack.
841 typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
842
843 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
845 Unexpanded[I].first.get<NamedDecl *>());
846 if (Instantiation->is<Decl *>())
847 // The pattern refers to an unexpanded pack. We're not ready to expand
848 // this pack yet.
849 return std::nullopt;
850
851 unsigned Size = Instantiation->get<DeclArgumentPack *>()->size();
852 assert((!Result || *Result == Size) && "inconsistent pack sizes");
853 Result = Size;
854 continue;
855 }
856
857 std::tie(Depth, Index) = getDepthAndIndex(ND);
858 }
859 if (Depth >= TemplateArgs.getNumLevels() ||
860 !TemplateArgs.hasTemplateArgument(Depth, Index))
861 // The pattern refers to an unknown template argument. We're not ready to
862 // expand this pack yet.
863 return std::nullopt;
864
865 // Determine the size of the argument pack.
866 unsigned Size = TemplateArgs(Depth, Index).pack_size();
867 assert((!Result || *Result == Size) && "inconsistent pack sizes");
868 Result = Size;
869 }
870
871 return Result;
872}
873
875 const DeclSpec &DS = D.getDeclSpec();
876 switch (DS.getTypeSpecType()) {
878 case TST_typename:
880 case TST_typeofType:
881#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
882#include "clang/Basic/TransformTypeTraits.def"
883 case TST_atomic: {
884 QualType T = DS.getRepAsType().get();
886 return true;
887 break;
888 }
889
891 case TST_typeofExpr:
892 case TST_decltype:
893 case TST_bitint:
894 if (DS.getRepAsExpr() &&
896 return true;
897 break;
898
899 case TST_unspecified:
900 case TST_void:
901 case TST_char:
902 case TST_wchar:
903 case TST_char8:
904 case TST_char16:
905 case TST_char32:
906 case TST_int:
907 case TST_int128:
908 case TST_half:
909 case TST_float:
910 case TST_double:
911 case TST_Accum:
912 case TST_Fract:
913 case TST_Float16:
914 case TST_float128:
915 case TST_ibm128:
916 case TST_bool:
917 case TST_decimal32:
918 case TST_decimal64:
919 case TST_decimal128:
920 case TST_enum:
921 case TST_union:
922 case TST_struct:
923 case TST_interface:
924 case TST_class:
925 case TST_auto:
926 case TST_auto_type:
928 case TST_BFloat16:
929#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
930#include "clang/Basic/OpenCLImageTypes.def"
932 case TST_error:
933 break;
934 }
935
936 for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) {
937 const DeclaratorChunk &Chunk = D.getTypeObject(I);
938 switch (Chunk.Kind) {
944 // These declarator chunks cannot contain any parameter packs.
945 break;
946
948 if (Chunk.Arr.NumElts &&
950 return true;
951 break;
953 for (unsigned i = 0, e = Chunk.Fun.NumParams; i != e; ++i) {
954 ParmVarDecl *Param = cast<ParmVarDecl>(Chunk.Fun.Params[i].Param);
955 QualType ParamTy = Param->getType();
956 assert(!ParamTy.isNull() && "Couldn't parse type?");
957 if (ParamTy->containsUnexpandedParameterPack()) return true;
958 }
959
960 if (Chunk.Fun.getExceptionSpecType() == EST_Dynamic) {
961 for (unsigned i = 0; i != Chunk.Fun.getNumExceptions(); ++i) {
962 if (Chunk.Fun.Exceptions[i]
963 .Ty.get()
965 return true;
966 }
967 } else if (isComputedNoexcept(Chunk.Fun.getExceptionSpecType()) &&
969 return true;
970
971 if (Chunk.Fun.hasTrailingReturnType()) {
974 return true;
975 }
976 break;
977
979 if (Chunk.Mem.Scope().getScopeRep() &&
981 return true;
982 break;
983 }
984 }
985
986 if (Expr *TRC = D.getTrailingRequiresClause())
987 if (TRC->containsUnexpandedParameterPack())
988 return true;
989
990 return false;
991}
992
993namespace {
994
995// Callback to only accept typo corrections that refer to parameter packs.
996class ParameterPackValidatorCCC final : public CorrectionCandidateCallback {
997 public:
998 bool ValidateCandidate(const TypoCorrection &candidate) override {
999 NamedDecl *ND = candidate.getCorrectionDecl();
1000 return ND && ND->isParameterPack();
1001 }
1002
1003 std::unique_ptr<CorrectionCandidateCallback> clone() override {
1004 return std::make_unique<ParameterPackValidatorCCC>(*this);
1005 }
1006};
1007
1008}
1009
1010/// Called when an expression computing the size of a parameter pack
1011/// is parsed.
1012///
1013/// \code
1014/// template<typename ...Types> struct count {
1015/// static const unsigned value = sizeof...(Types);
1016/// };
1017/// \endcode
1018///
1019//
1020/// \param OpLoc The location of the "sizeof" keyword.
1021/// \param Name The name of the parameter pack whose size will be determined.
1022/// \param NameLoc The source location of the name of the parameter pack.
1023/// \param RParenLoc The location of the closing parentheses.
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 CorrectDelayedTyposInExpr(IndexExpr);
1089 Diag(PackExpression->getBeginLoc(), diag::err_expected_name_of_pack)
1090 << PackExpression;
1091 return ExprError();
1092 }
1093 ExprResult Res =
1094 BuildPackIndexingExpr(PackExpression, EllipsisLoc, IndexExpr, RSquareLoc);
1095 if (!Res.isInvalid())
1097 ? diag::warn_cxx23_pack_indexing
1098 : diag::ext_pack_indexing);
1099 return Res;
1100}
1101
1104 Expr *IndexExpr, SourceLocation RSquareLoc,
1105 ArrayRef<Expr *> ExpandedExprs, bool EmptyPack) {
1106
1107 std::optional<int64_t> Index;
1108 if (!IndexExpr->isInstantiationDependent()) {
1109 llvm::APSInt Value(Context.getIntWidth(Context.getSizeType()));
1110
1112 IndexExpr, Context.getSizeType(), Value, CCEK_ArrayBound);
1113 if (!Res.isUsable())
1114 return ExprError();
1115 Index = Value.getExtValue();
1116 IndexExpr = Res.get();
1117 }
1118
1119 if (Index && (!ExpandedExprs.empty() || EmptyPack)) {
1120 if (*Index < 0 || EmptyPack || *Index >= int64_t(ExpandedExprs.size())) {
1121 Diag(PackExpression->getBeginLoc(), diag::err_pack_index_out_of_bound)
1122 << *Index << PackExpression << ExpandedExprs.size();
1123 return ExprError();
1124 }
1125 }
1126
1127 return PackIndexingExpr::Create(getASTContext(), EllipsisLoc, RSquareLoc,
1128 PackExpression, IndexExpr, Index,
1129 ExpandedExprs);
1130}
1131
1133 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
1134 std::optional<unsigned> &NumExpansions) const {
1135 const TemplateArgument &Argument = OrigLoc.getArgument();
1136 assert(Argument.isPackExpansion());
1137 switch (Argument.getKind()) {
1139 // FIXME: We shouldn't ever have to worry about missing
1140 // type-source info!
1141 TypeSourceInfo *ExpansionTSInfo = OrigLoc.getTypeSourceInfo();
1142 if (!ExpansionTSInfo)
1143 ExpansionTSInfo = Context.getTrivialTypeSourceInfo(Argument.getAsType(),
1144 Ellipsis);
1145 PackExpansionTypeLoc Expansion =
1146 ExpansionTSInfo->getTypeLoc().castAs<PackExpansionTypeLoc>();
1147 Ellipsis = Expansion.getEllipsisLoc();
1148
1149 TypeLoc Pattern = Expansion.getPatternLoc();
1150 NumExpansions = Expansion.getTypePtr()->getNumExpansions();
1151
1152 // We need to copy the TypeLoc because TemplateArgumentLocs store a
1153 // TypeSourceInfo.
1154 // FIXME: Find some way to avoid the copy?
1155 TypeLocBuilder TLB;
1156 TLB.pushFullCopy(Pattern);
1157 TypeSourceInfo *PatternTSInfo =
1158 TLB.getTypeSourceInfo(Context, Pattern.getType());
1160 PatternTSInfo);
1161 }
1162
1164 PackExpansionExpr *Expansion
1165 = cast<PackExpansionExpr>(Argument.getAsExpr());
1166 Expr *Pattern = Expansion->getPattern();
1167 Ellipsis = Expansion->getEllipsisLoc();
1168 NumExpansions = Expansion->getNumExpansions();
1169 return TemplateArgumentLoc(Pattern, Pattern);
1170 }
1171
1173 Ellipsis = OrigLoc.getTemplateEllipsisLoc();
1174 NumExpansions = Argument.getNumTemplateExpansions();
1176 OrigLoc.getTemplateQualifierLoc(),
1177 OrigLoc.getTemplateNameLoc());
1178
1186 return TemplateArgumentLoc();
1187 }
1188
1189 llvm_unreachable("Invalid TemplateArgument Kind!");
1190}
1191
1193 assert(Arg.containsUnexpandedParameterPack());
1194
1195 // If this is a substituted pack, grab that pack. If not, we don't know
1196 // the size yet.
1197 // FIXME: We could find a size in more cases by looking for a substituted
1198 // pack anywhere within this argument, but that's not necessary in the common
1199 // case for 'sizeof...(A)' handling.
1200 TemplateArgument Pack;
1201 switch (Arg.getKind()) {
1203 if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
1204 Pack = Subst->getArgumentPack();
1205 else
1206 return std::nullopt;
1207 break;
1208
1210 if (auto *Subst =
1211 dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.getAsExpr()))
1212 Pack = Subst->getArgumentPack();
1213 else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr())) {
1214 for (VarDecl *PD : *Subst)
1215 if (PD->isParameterPack())
1216 return std::nullopt;
1217 return Subst->getNumExpansions();
1218 } else
1219 return std::nullopt;
1220 break;
1221
1225 Pack = Subst->getArgumentPack();
1226 else
1227 return std::nullopt;
1228 break;
1229
1237 return std::nullopt;
1238 }
1239
1240 // Check that no argument in the pack is itself a pack expansion.
1241 for (TemplateArgument Elem : Pack.pack_elements()) {
1242 // There's no point recursing in this case; we would have already
1243 // expanded this pack expansion into the enclosing pack if we could.
1244 if (Elem.isPackExpansion())
1245 return std::nullopt;
1246 }
1247 return Pack.pack_size();
1248}
1249
1250static void CheckFoldOperand(Sema &S, Expr *E) {
1251 if (!E)
1252 return;
1253
1254 E = E->IgnoreImpCasts();
1255 auto *OCE = dyn_cast<CXXOperatorCallExpr>(E);
1256 if ((OCE && OCE->isInfixBinaryOp()) || isa<BinaryOperator>(E) ||
1257 isa<AbstractConditionalOperator>(E)) {
1258 S.Diag(E->getExprLoc(), diag::err_fold_expression_bad_operand)
1259 << E->getSourceRange()
1262 }
1263}
1264
1266 tok::TokenKind Operator,
1267 SourceLocation EllipsisLoc, Expr *RHS,
1268 SourceLocation RParenLoc) {
1269 // LHS and RHS must be cast-expressions. We allow an arbitrary expression
1270 // in the parser and reduce down to just cast-expressions here.
1271 CheckFoldOperand(*this, LHS);
1272 CheckFoldOperand(*this, RHS);
1273
1274 auto DiscardOperands = [&] {
1277 };
1278
1279 // [expr.prim.fold]p3:
1280 // In a binary fold, op1 and op2 shall be the same fold-operator, and
1281 // either e1 shall contain an unexpanded parameter pack or e2 shall contain
1282 // an unexpanded parameter pack, but not both.
1283 if (LHS && RHS &&
1286 DiscardOperands();
1287 return Diag(EllipsisLoc,
1289 ? diag::err_fold_expression_packs_both_sides
1290 : diag::err_pack_expansion_without_parameter_packs)
1291 << LHS->getSourceRange() << RHS->getSourceRange();
1292 }
1293
1294 // [expr.prim.fold]p2:
1295 // In a unary fold, the cast-expression shall contain an unexpanded
1296 // parameter pack.
1297 if (!LHS || !RHS) {
1298 Expr *Pack = LHS ? LHS : RHS;
1299 assert(Pack && "fold expression with neither LHS nor RHS");
1300 if (!Pack->containsUnexpandedParameterPack()) {
1301 DiscardOperands();
1302 return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1303 << Pack->getSourceRange();
1304 }
1305 }
1306
1307 BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
1308
1309 // Perform first-phase name lookup now.
1310 UnresolvedLookupExpr *ULE = nullptr;
1311 {
1312 UnresolvedSet<16> Functions;
1313 LookupBinOp(S, EllipsisLoc, Opc, Functions);
1314 if (!Functions.empty()) {
1318 /*NamingClass*/ nullptr, NestedNameSpecifierLoc(),
1319 DeclarationNameInfo(OpName, EllipsisLoc), Functions);
1320 if (Callee.isInvalid())
1321 return ExprError();
1322 ULE = cast<UnresolvedLookupExpr>(Callee.get());
1323 }
1324 }
1325
1326 return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1327 std::nullopt);
1328}
1329
1331 SourceLocation LParenLoc, Expr *LHS,
1332 BinaryOperatorKind Operator,
1333 SourceLocation EllipsisLoc, Expr *RHS,
1334 SourceLocation RParenLoc,
1335 std::optional<unsigned> NumExpansions) {
1336 return new (Context)
1337 CXXFoldExpr(Context.DependentTy, Callee, LParenLoc, LHS, Operator,
1338 EllipsisLoc, RHS, RParenLoc, NumExpansions);
1339}
1340
1342 BinaryOperatorKind Operator) {
1343 // [temp.variadic]p9:
1344 // If N is zero for a unary fold-expression, the value of the expression is
1345 // && -> true
1346 // || -> false
1347 // , -> void()
1348 // if the operator is not listed [above], the instantiation is ill-formed.
1349 //
1350 // Note that we need to use something like int() here, not merely 0, to
1351 // prevent the result from being a null pointer constant.
1352 QualType ScalarType;
1353 switch (Operator) {
1354 case BO_LOr:
1355 return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_false);
1356 case BO_LAnd:
1357 return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_true);
1358 case BO_Comma:
1359 ScalarType = Context.VoidTy;
1360 break;
1361
1362 default:
1363 return Diag(EllipsisLoc, diag::err_fold_expression_empty)
1364 << BinaryOperator::getOpcodeStr(Operator);
1365 }
1366
1367 return new (Context) CXXScalarValueInitExpr(
1368 ScalarType, Context.getTrivialTypeSourceInfo(ScalarType, EllipsisLoc),
1369 EllipsisLoc);
1370}
static StringRef getIdentifier(const Token &Tok)
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:643
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:1114
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:1086
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:2156
StringRef getOpcodeStr() const
Definition: Expr.h:3875
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2293
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4791
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Definition: ExprCXX.h:2165
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:73
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Definition: DeclSpec.h:214
SourceRange getRange() const
Definition: DeclSpec.h:79
SourceLocation getBeginLoc() const
Definition: DeclSpec.h:83
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:94
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:1247
ValueDecl * getDecl()
Definition: Expr.h:1315
SourceLocation getLocation() const
Definition: Expr.h:1323
Captures information about "declaration specifiers".
Definition: DeclSpec.h:246
TST getTypeSpecType() const
Definition: DeclSpec.h:533
ParsedType getRepAsType() const
Definition: DeclSpec.h:543
Expr * getRepAsExpr() const
Definition: DeclSpec.h:551
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:85
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:220
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:1899
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Definition: DeclSpec.h:2381
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:2046
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
Definition: DeclSpec.h:2616
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Definition: DeclSpec.h:2377
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:233
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Definition: Expr.h:215
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:3014
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:266
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:1938
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition: ExprCXX.cpp:1346
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:563
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Definition: Lookup.h:273
LookupResultKind getResultKind() const
Definition: Lookup.h:341
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Definition: Lookup.h:253
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
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:360
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:362
PtrTy get() const
Definition: Ownership.h:80
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4142
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4171
std::optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
Definition: ExprCXX.h:4182
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4178
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2551
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2547
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2563
Represents a pack expansion of types.
Definition: Type.h:6111
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:6136
Expr * getIndexExpr() const
Definition: ExprCXX.h:4400
static PackIndexingExpr * Create(ASTContext &Context, SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr, std::optional< int64_t > Index, ArrayRef< Expr * > SubstitutedExprs={})
Definition: ExprCXX.cpp:1668
Expr * getIndexExpr() const
Definition: TypeLoc.h:2077
Expr * getIndexExpr() const
Definition: Type.h:4959
Represents a parameter to a function.
Definition: Decl.h:1749
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:737
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:804
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool TraverseTemplateArgument(const TemplateArgument &Arg)
Recursively visit a template argument and dispatch to the appropriate method for the argument type.
bool TraverseType(QualType T)
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() pr...
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...
bool TraverseTypeLoc(TypeLoc TL)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)
Recursively visit a lambda capture.
bool TraverseAttr(Attr *At)
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic typ...
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Recursively visit a base specifier.
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
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
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:425
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6759
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:10184
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:4490
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: Sema.cpp:1924
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:891
ASTContext & Context
Definition: Sema.h:476
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:1801
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:16091
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:8973
@ UPPC_Requirement
Definition: Sema.h:9041
const LangOptions & getLangOpts() const
Definition: Sema.h:1794
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:20819
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:4728
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:4043
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaInternal.h:24
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:2371
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:3213
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:1644
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:5431
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:202
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:5322
unsigned getDepth() const
Definition: Type.h:5320
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:6872
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:6883
SourceLocation getNameLoc() const
Definition: TypeLoc.h:535
The base class of the type hierarchy.
Definition: Type.h:1606
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.cpp:1948
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:2094
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7652
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:3163
A set of unresolved declarations.
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3952
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:3998
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3855
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:3908
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:706
QualType getType() const
Definition: Decl.h:717
Represents a variable declaration or definition.
Definition: Decl.h:918
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:60
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:65
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:246
@ 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:1317
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:1247
enum clang::DeclaratorChunk::@215 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