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 // 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) {
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
173 return inherited::TraverseDecl(D);
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) {
192 }
193 bool TraversePackIndexingType(PackIndexingType *E) {
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
569
572 SourceLocation EllipsisLoc) {
573 if (Arg.isInvalid())
574 return Arg;
575
576 switch (Arg.getKind()) {
578 TypeResult Result = ActOnPackExpansion(Arg.getAsType(), EllipsisLoc);
579 if (Result.isInvalid())
580 return ParsedTemplateArgument();
581
582 return ParsedTemplateArgument(Arg.getKind(), Result.get().getAsOpaquePtr(),
583 Arg.getLocation());
584 }
585
587 ExprResult Result = ActOnPackExpansion(Arg.getAsExpr(), EllipsisLoc);
588 if (Result.isInvalid())
589 return ParsedTemplateArgument();
590
591 return ParsedTemplateArgument(Arg.getKind(), Result.get(),
592 Arg.getLocation());
593 }
594
597 SourceRange R(Arg.getLocation());
598 if (Arg.getScopeSpec().isValid())
600 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
601 << R;
602 return ParsedTemplateArgument();
603 }
604
605 return Arg.getTemplatePackExpansion(EllipsisLoc);
606 }
607 llvm_unreachable("Unhandled template argument kind?");
608}
609
611 SourceLocation EllipsisLoc) {
612 TypeSourceInfo *TSInfo;
613 GetTypeFromParser(Type, &TSInfo);
614 if (!TSInfo)
615 return true;
616
617 TypeSourceInfo *TSResult =
618 CheckPackExpansion(TSInfo, EllipsisLoc, std::nullopt);
619 if (!TSResult)
620 return true;
621
622 return CreateParsedType(TSResult->getType(), TSResult);
623}
624
627 std::optional<unsigned> NumExpansions) {
628 // Create the pack expansion type and source-location information.
630 Pattern->getTypeLoc().getSourceRange(),
631 EllipsisLoc, NumExpansions);
632 if (Result.isNull())
633 return nullptr;
634
635 TypeLocBuilder TLB;
636 TLB.pushFullCopy(Pattern->getTypeLoc());
638 TL.setEllipsisLoc(EllipsisLoc);
639
640 return TLB.getTypeSourceInfo(Context, Result);
641}
642
644 SourceLocation EllipsisLoc,
645 std::optional<unsigned> NumExpansions) {
646 // C++11 [temp.variadic]p5:
647 // The pattern of a pack expansion shall name one or more
648 // parameter packs that are not expanded by a nested pack
649 // expansion.
650 //
651 // A pattern containing a deduced type can't occur "naturally" but arises in
652 // the desugaring of an init-capture pack.
653 if (!Pattern->containsUnexpandedParameterPack() &&
654 !Pattern->getContainedDeducedType()) {
655 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
656 << PatternRange;
657 return QualType();
658 }
659
660 return Context.getPackExpansionType(Pattern, NumExpansions,
661 /*ExpectPackInType=*/false);
662}
663
665 return CheckPackExpansion(Pattern, EllipsisLoc, std::nullopt);
666}
667
669 std::optional<unsigned> NumExpansions) {
670 if (!Pattern)
671 return ExprError();
672
673 // C++0x [temp.variadic]p5:
674 // The pattern of a pack expansion shall name one or more
675 // parameter packs that are not expanded by a nested pack
676 // expansion.
677 if (!Pattern->containsUnexpandedParameterPack()) {
678 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
679 << Pattern->getSourceRange();
681 return ExprError();
682 }
683
684 // Create the pack expansion expression and source-location information.
685 return new (Context)
686 PackExpansionExpr(Context.DependentTy, Pattern, EllipsisLoc, NumExpansions);
687}
688
690 SourceLocation EllipsisLoc, SourceRange PatternRange,
692 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
693 bool &RetainExpansion, std::optional<unsigned> &NumExpansions) {
694 ShouldExpand = true;
695 RetainExpansion = false;
696 std::pair<IdentifierInfo *, SourceLocation> FirstPack;
697 bool HaveFirstPack = false;
698 std::optional<unsigned> NumPartialExpansions;
699 SourceLocation PartiallySubstitutedPackLoc;
700
701 for (UnexpandedParameterPack ParmPack : Unexpanded) {
702 // Compute the depth and index for this parameter pack.
703 unsigned Depth = 0, Index = 0;
704 IdentifierInfo *Name;
705 bool IsVarDeclPack = false;
706
707 if (const TemplateTypeParmType *TTP =
708 ParmPack.first.dyn_cast<const TemplateTypeParmType *>()) {
709 Depth = TTP->getDepth();
710 Index = TTP->getIndex();
711 Name = TTP->getIdentifier();
712 } else {
713 NamedDecl *ND = ParmPack.first.get<NamedDecl *>();
714 if (isa<VarDecl>(ND))
715 IsVarDeclPack = true;
716 else
717 std::tie(Depth, Index) = getDepthAndIndex(ND);
718
719 Name = ND->getIdentifier();
720 }
721
722 // Determine the size of this argument pack.
723 unsigned NewPackSize;
724 if (IsVarDeclPack) {
725 // Figure out whether we're instantiating to an argument pack or not.
726 typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
727
728 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
730 ParmPack.first.get<NamedDecl *>());
731 if (Instantiation->is<DeclArgumentPack *>()) {
732 // We could expand this function parameter pack.
733 NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
734 } else {
735 // We can't expand this function parameter pack, so we can't expand
736 // the pack expansion.
737 ShouldExpand = false;
738 continue;
739 }
740 } else {
741 // If we don't have a template argument at this depth/index, then we
742 // cannot expand the pack expansion. Make a note of this, but we still
743 // want to check any parameter packs we *do* have arguments for.
744 if (Depth >= TemplateArgs.getNumLevels() ||
745 !TemplateArgs.hasTemplateArgument(Depth, Index)) {
746 ShouldExpand = false;
747 continue;
748 }
749
750 // Determine the size of the argument pack.
751 NewPackSize = TemplateArgs(Depth, Index).pack_size();
752 }
753
754 // C++0x [temp.arg.explicit]p9:
755 // Template argument deduction can extend the sequence of template
756 // arguments corresponding to a template parameter pack, even when the
757 // sequence contains explicitly specified template arguments.
758 if (!IsVarDeclPack && CurrentInstantiationScope) {
759 if (NamedDecl *PartialPack =
761 unsigned PartialDepth, PartialIndex;
762 std::tie(PartialDepth, PartialIndex) = getDepthAndIndex(PartialPack);
763 if (PartialDepth == Depth && PartialIndex == Index) {
764 RetainExpansion = true;
765 // We don't actually know the new pack size yet.
766 NumPartialExpansions = NewPackSize;
767 PartiallySubstitutedPackLoc = ParmPack.second;
768 continue;
769 }
770 }
771 }
772
773 if (!NumExpansions) {
774 // The is the first pack we've seen for which we have an argument.
775 // Record it.
776 NumExpansions = NewPackSize;
777 FirstPack.first = Name;
778 FirstPack.second = ParmPack.second;
779 HaveFirstPack = true;
780 continue;
781 }
782
783 if (NewPackSize != *NumExpansions) {
784 // C++0x [temp.variadic]p5:
785 // All of the parameter packs expanded by a pack expansion shall have
786 // the same number of arguments specified.
787 if (HaveFirstPack)
788 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
789 << FirstPack.first << Name << *NumExpansions << NewPackSize
790 << SourceRange(FirstPack.second) << SourceRange(ParmPack.second);
791 else
792 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
793 << Name << *NumExpansions << NewPackSize
794 << SourceRange(ParmPack.second);
795 return true;
796 }
797 }
798
799 // If we're performing a partial expansion but we also have a full expansion,
800 // expand to the number of common arguments. For example, given:
801 //
802 // template<typename ...T> struct A {
803 // template<typename ...U> void f(pair<T, U>...);
804 // };
805 //
806 // ... a call to 'A<int, int>().f<int>' should expand the pack once and
807 // retain an expansion.
808 if (NumPartialExpansions) {
809 if (NumExpansions && *NumExpansions < *NumPartialExpansions) {
810 NamedDecl *PartialPack =
812 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_partial)
813 << PartialPack << *NumPartialExpansions << *NumExpansions
814 << SourceRange(PartiallySubstitutedPackLoc);
815 return true;
816 }
817
818 NumExpansions = NumPartialExpansions;
819 }
820
821 return false;
822}
823
824std::optional<unsigned> Sema::getNumArgumentsInExpansion(
825 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs) {
826 QualType Pattern = cast<PackExpansionType>(T)->getPattern();
828 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(Pattern);
829
830 std::optional<unsigned> Result;
831 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
832 // Compute the depth and index for this parameter pack.
833 unsigned Depth;
834 unsigned Index;
835
836 if (const TemplateTypeParmType *TTP =
837 Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) {
838 Depth = TTP->getDepth();
839 Index = TTP->getIndex();
840 } else {
841 NamedDecl *ND = Unexpanded[I].first.get<NamedDecl *>();
842 if (isa<VarDecl>(ND)) {
843 // Function parameter pack or init-capture pack.
844 typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
845
846 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
848 Unexpanded[I].first.get<NamedDecl *>());
849 if (Instantiation->is<Decl *>())
850 // The pattern refers to an unexpanded pack. We're not ready to expand
851 // this pack yet.
852 return std::nullopt;
853
854 unsigned Size = Instantiation->get<DeclArgumentPack *>()->size();
855 assert((!Result || *Result == Size) && "inconsistent pack sizes");
856 Result = Size;
857 continue;
858 }
859
860 std::tie(Depth, Index) = getDepthAndIndex(ND);
861 }
862 if (Depth >= TemplateArgs.getNumLevels() ||
863 !TemplateArgs.hasTemplateArgument(Depth, Index))
864 // The pattern refers to an unknown template argument. We're not ready to
865 // expand this pack yet.
866 return std::nullopt;
867
868 // Determine the size of the argument pack.
869 unsigned Size = TemplateArgs(Depth, Index).pack_size();
870 assert((!Result || *Result == Size) && "inconsistent pack sizes");
871 Result = Size;
872 }
873
874 return Result;
875}
876
878 const DeclSpec &DS = D.getDeclSpec();
879 switch (DS.getTypeSpecType()) {
881 case TST_typename:
883 case TST_typeofType:
884#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
885#include "clang/Basic/TransformTypeTraits.def"
886 case TST_atomic: {
887 QualType T = DS.getRepAsType().get();
888 if (!T.isNull() && T->containsUnexpandedParameterPack())
889 return true;
890 break;
891 }
892
894 case TST_typeofExpr:
895 case TST_decltype:
896 case TST_bitint:
897 if (DS.getRepAsExpr() &&
899 return true;
900 break;
901
902 case TST_unspecified:
903 case TST_void:
904 case TST_char:
905 case TST_wchar:
906 case TST_char8:
907 case TST_char16:
908 case TST_char32:
909 case TST_int:
910 case TST_int128:
911 case TST_half:
912 case TST_float:
913 case TST_double:
914 case TST_Accum:
915 case TST_Fract:
916 case TST_Float16:
917 case TST_float128:
918 case TST_ibm128:
919 case TST_bool:
920 case TST_decimal32:
921 case TST_decimal64:
922 case TST_decimal128:
923 case TST_enum:
924 case TST_union:
925 case TST_struct:
926 case TST_interface:
927 case TST_class:
928 case TST_auto:
929 case TST_auto_type:
931 case TST_BFloat16:
932#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
933#include "clang/Basic/OpenCLImageTypes.def"
935 case TST_error:
936 break;
937 }
938
939 for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) {
940 const DeclaratorChunk &Chunk = D.getTypeObject(I);
941 switch (Chunk.Kind) {
947 // These declarator chunks cannot contain any parameter packs.
948 break;
949
951 if (Chunk.Arr.NumElts &&
953 return true;
954 break;
956 for (unsigned i = 0, e = Chunk.Fun.NumParams; i != e; ++i) {
957 ParmVarDecl *Param = cast<ParmVarDecl>(Chunk.Fun.Params[i].Param);
958 QualType ParamTy = Param->getType();
959 assert(!ParamTy.isNull() && "Couldn't parse type?");
960 if (ParamTy->containsUnexpandedParameterPack()) return true;
961 }
962
963 if (Chunk.Fun.getExceptionSpecType() == EST_Dynamic) {
964 for (unsigned i = 0; i != Chunk.Fun.getNumExceptions(); ++i) {
965 if (Chunk.Fun.Exceptions[i]
966 .Ty.get()
968 return true;
969 }
970 } else if (isComputedNoexcept(Chunk.Fun.getExceptionSpecType()) &&
972 return true;
973
974 if (Chunk.Fun.hasTrailingReturnType()) {
976 if (!T.isNull() && T->containsUnexpandedParameterPack())
977 return true;
978 }
979 break;
980
982 if (Chunk.Mem.Scope().getScopeRep() &&
984 return true;
985 break;
986 }
987 }
988
989 if (Expr *TRC = D.getTrailingRequiresClause())
990 if (TRC->containsUnexpandedParameterPack())
991 return true;
992
993 return false;
994}
995
996namespace {
997
998// Callback to only accept typo corrections that refer to parameter packs.
999class ParameterPackValidatorCCC final : public CorrectionCandidateCallback {
1000 public:
1001 bool ValidateCandidate(const TypoCorrection &candidate) override {
1002 NamedDecl *ND = candidate.getCorrectionDecl();
1003 return ND && ND->isParameterPack();
1004 }
1005
1006 std::unique_ptr<CorrectionCandidateCallback> clone() override {
1007 return std::make_unique<ParameterPackValidatorCCC>(*this);
1008 }
1009};
1010
1011}
1012
1013/// Called when an expression computing the size of a parameter pack
1014/// is parsed.
1015///
1016/// \code
1017/// template<typename ...Types> struct count {
1018/// static const unsigned value = sizeof...(Types);
1019/// };
1020/// \endcode
1021///
1022//
1023/// \param OpLoc The location of the "sizeof" keyword.
1024/// \param Name The name of the parameter pack whose size will be determined.
1025/// \param NameLoc The source location of the name of the parameter pack.
1026/// \param RParenLoc The location of the closing parentheses.
1028 SourceLocation OpLoc,
1029 IdentifierInfo &Name,
1030 SourceLocation NameLoc,
1031 SourceLocation RParenLoc) {
1032 // C++0x [expr.sizeof]p5:
1033 // The identifier in a sizeof... expression shall name a parameter pack.
1034 LookupResult R(*this, &Name, NameLoc, LookupOrdinaryName);
1035 LookupName(R, S);
1036
1037 NamedDecl *ParameterPack = nullptr;
1038 switch (R.getResultKind()) {
1040 ParameterPack = R.getFoundDecl();
1041 break;
1042
1045 ParameterPackValidatorCCC CCC{};
1046 if (TypoCorrection Corrected =
1047 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, nullptr,
1048 CCC, CTK_ErrorRecovery)) {
1049 diagnoseTypo(Corrected,
1050 PDiag(diag::err_sizeof_pack_no_pack_name_suggest) << &Name,
1051 PDiag(diag::note_parameter_pack_here));
1052 ParameterPack = Corrected.getCorrectionDecl();
1053 }
1054 break;
1055 }
1058 break;
1059
1062 return ExprError();
1063 }
1064
1065 if (!ParameterPack || !ParameterPack->isParameterPack()) {
1066 Diag(NameLoc, diag::err_expected_name_of_pack) << &Name;
1067 return ExprError();
1068 }
1069
1070 MarkAnyDeclReferenced(OpLoc, ParameterPack, true);
1071
1072 return SizeOfPackExpr::Create(Context, OpLoc, ParameterPack, NameLoc,
1073 RParenLoc);
1074}
1075
1076static bool isParameterPack(Expr *PackExpression) {
1077 if (auto *D = dyn_cast<DeclRefExpr>(PackExpression); D) {
1078 ValueDecl *VD = D->getDecl();
1079 return VD->isParameterPack();
1080 }
1081 return false;
1082}
1083
1085 SourceLocation EllipsisLoc,
1086 SourceLocation LSquareLoc,
1087 Expr *IndexExpr,
1088 SourceLocation RSquareLoc) {
1089 bool isParameterPack = ::isParameterPack(PackExpression);
1090 if (!isParameterPack) {
1091 if (!PackExpression->containsErrors()) {
1092 CorrectDelayedTyposInExpr(IndexExpr);
1093 Diag(PackExpression->getBeginLoc(), diag::err_expected_name_of_pack)
1094 << PackExpression;
1095 }
1096 return ExprError();
1097 }
1098 ExprResult Res =
1099 BuildPackIndexingExpr(PackExpression, EllipsisLoc, IndexExpr, RSquareLoc);
1100 if (!Res.isInvalid())
1102 ? diag::warn_cxx23_pack_indexing
1103 : diag::ext_pack_indexing);
1104 return Res;
1105}
1106
1109 Expr *IndexExpr, SourceLocation RSquareLoc,
1110 ArrayRef<Expr *> ExpandedExprs, bool EmptyPack) {
1111
1112 std::optional<int64_t> Index;
1113 if (!IndexExpr->isInstantiationDependent()) {
1114 llvm::APSInt Value(Context.getIntWidth(Context.getSizeType()));
1115
1117 IndexExpr, Context.getSizeType(), Value, CCEK_ArrayBound);
1118 if (!Res.isUsable())
1119 return ExprError();
1120 Index = Value.getExtValue();
1121 IndexExpr = Res.get();
1122 }
1123
1124 if (Index && (!ExpandedExprs.empty() || EmptyPack)) {
1125 if (*Index < 0 || EmptyPack || *Index >= int64_t(ExpandedExprs.size())) {
1126 Diag(PackExpression->getBeginLoc(), diag::err_pack_index_out_of_bound)
1127 << *Index << PackExpression << ExpandedExprs.size();
1128 return ExprError();
1129 }
1130 }
1131
1132 return PackIndexingExpr::Create(getASTContext(), EllipsisLoc, RSquareLoc,
1133 PackExpression, IndexExpr, Index,
1134 ExpandedExprs, EmptyPack);
1135}
1136
1138 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
1139 std::optional<unsigned> &NumExpansions) const {
1140 const TemplateArgument &Argument = OrigLoc.getArgument();
1141 assert(Argument.isPackExpansion());
1142 switch (Argument.getKind()) {
1144 // FIXME: We shouldn't ever have to worry about missing
1145 // type-source info!
1146 TypeSourceInfo *ExpansionTSInfo = OrigLoc.getTypeSourceInfo();
1147 if (!ExpansionTSInfo)
1148 ExpansionTSInfo = Context.getTrivialTypeSourceInfo(Argument.getAsType(),
1149 Ellipsis);
1150 PackExpansionTypeLoc Expansion =
1151 ExpansionTSInfo->getTypeLoc().castAs<PackExpansionTypeLoc>();
1152 Ellipsis = Expansion.getEllipsisLoc();
1153
1154 TypeLoc Pattern = Expansion.getPatternLoc();
1155 NumExpansions = Expansion.getTypePtr()->getNumExpansions();
1156
1157 // We need to copy the TypeLoc because TemplateArgumentLocs store a
1158 // TypeSourceInfo.
1159 // FIXME: Find some way to avoid the copy?
1160 TypeLocBuilder TLB;
1161 TLB.pushFullCopy(Pattern);
1162 TypeSourceInfo *PatternTSInfo =
1163 TLB.getTypeSourceInfo(Context, Pattern.getType());
1165 PatternTSInfo);
1166 }
1167
1169 PackExpansionExpr *Expansion
1170 = cast<PackExpansionExpr>(Argument.getAsExpr());
1171 Expr *Pattern = Expansion->getPattern();
1172 Ellipsis = Expansion->getEllipsisLoc();
1173 NumExpansions = Expansion->getNumExpansions();
1174 return TemplateArgumentLoc(Pattern, Pattern);
1175 }
1176
1178 Ellipsis = OrigLoc.getTemplateEllipsisLoc();
1179 NumExpansions = Argument.getNumTemplateExpansions();
1181 OrigLoc.getTemplateQualifierLoc(),
1182 OrigLoc.getTemplateNameLoc());
1183
1191 return TemplateArgumentLoc();
1192 }
1193
1194 llvm_unreachable("Invalid TemplateArgument Kind!");
1195}
1196
1198 assert(Arg.containsUnexpandedParameterPack());
1199
1200 // If this is a substituted pack, grab that pack. If not, we don't know
1201 // the size yet.
1202 // FIXME: We could find a size in more cases by looking for a substituted
1203 // pack anywhere within this argument, but that's not necessary in the common
1204 // case for 'sizeof...(A)' handling.
1205 TemplateArgument Pack;
1206 switch (Arg.getKind()) {
1208 if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
1209 Pack = Subst->getArgumentPack();
1210 else
1211 return std::nullopt;
1212 break;
1213
1215 if (auto *Subst =
1216 dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.getAsExpr()))
1217 Pack = Subst->getArgumentPack();
1218 else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr())) {
1219 for (VarDecl *PD : *Subst)
1220 if (PD->isParameterPack())
1221 return std::nullopt;
1222 return Subst->getNumExpansions();
1223 } else
1224 return std::nullopt;
1225 break;
1226
1230 Pack = Subst->getArgumentPack();
1231 else
1232 return std::nullopt;
1233 break;
1234
1242 return std::nullopt;
1243 }
1244
1245 // Check that no argument in the pack is itself a pack expansion.
1246 for (TemplateArgument Elem : Pack.pack_elements()) {
1247 // There's no point recursing in this case; we would have already
1248 // expanded this pack expansion into the enclosing pack if we could.
1249 if (Elem.isPackExpansion())
1250 return std::nullopt;
1251 // Don't guess the size of unexpanded packs. The pack within a template
1252 // argument may have yet to be of a PackExpansion type before we see the
1253 // ellipsis in the annotation stage.
1254 //
1255 // This doesn't mean we would invalidate the optimization: Arg can be an
1256 // unexpanded pack regardless of Elem's dependence. For instance,
1257 // A TemplateArgument that contains either a SubstTemplateTypeParmPackType
1258 // or SubstNonTypeTemplateParmPackExpr is always considered Unexpanded, but
1259 // the underlying TemplateArgument thereof may not.
1260 if (Elem.containsUnexpandedParameterPack())
1261 return std::nullopt;
1262 }
1263 return Pack.pack_size();
1264}
1265
1266static void CheckFoldOperand(Sema &S, Expr *E) {
1267 if (!E)
1268 return;
1269
1270 E = E->IgnoreImpCasts();
1271 auto *OCE = dyn_cast<CXXOperatorCallExpr>(E);
1272 if ((OCE && OCE->isInfixBinaryOp()) || isa<BinaryOperator>(E) ||
1273 isa<AbstractConditionalOperator>(E)) {
1274 S.Diag(E->getExprLoc(), diag::err_fold_expression_bad_operand)
1275 << E->getSourceRange()
1278 }
1279}
1280
1282 tok::TokenKind Operator,
1283 SourceLocation EllipsisLoc, Expr *RHS,
1284 SourceLocation RParenLoc) {
1285 // LHS and RHS must be cast-expressions. We allow an arbitrary expression
1286 // in the parser and reduce down to just cast-expressions here.
1287 CheckFoldOperand(*this, LHS);
1288 CheckFoldOperand(*this, RHS);
1289
1290 auto DiscardOperands = [&] {
1293 };
1294
1295 // [expr.prim.fold]p3:
1296 // In a binary fold, op1 and op2 shall be the same fold-operator, and
1297 // either e1 shall contain an unexpanded parameter pack or e2 shall contain
1298 // an unexpanded parameter pack, but not both.
1299 if (LHS && RHS &&
1302 DiscardOperands();
1303 return Diag(EllipsisLoc,
1305 ? diag::err_fold_expression_packs_both_sides
1306 : diag::err_pack_expansion_without_parameter_packs)
1307 << LHS->getSourceRange() << RHS->getSourceRange();
1308 }
1309
1310 // [expr.prim.fold]p2:
1311 // In a unary fold, the cast-expression shall contain an unexpanded
1312 // parameter pack.
1313 if (!LHS || !RHS) {
1314 Expr *Pack = LHS ? LHS : RHS;
1315 assert(Pack && "fold expression with neither LHS nor RHS");
1316 if (!Pack->containsUnexpandedParameterPack()) {
1317 DiscardOperands();
1318 return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1319 << Pack->getSourceRange();
1320 }
1321 }
1322
1323 BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
1324
1325 // Perform first-phase name lookup now.
1326 UnresolvedLookupExpr *ULE = nullptr;
1327 {
1328 UnresolvedSet<16> Functions;
1329 LookupBinOp(S, EllipsisLoc, Opc, Functions);
1330 if (!Functions.empty()) {
1334 /*NamingClass*/ nullptr, NestedNameSpecifierLoc(),
1335 DeclarationNameInfo(OpName, EllipsisLoc), Functions);
1336 if (Callee.isInvalid())
1337 return ExprError();
1338 ULE = cast<UnresolvedLookupExpr>(Callee.get());
1339 }
1340 }
1341
1342 return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1343 std::nullopt);
1344}
1345
1347 SourceLocation LParenLoc, Expr *LHS,
1348 BinaryOperatorKind Operator,
1349 SourceLocation EllipsisLoc, Expr *RHS,
1350 SourceLocation RParenLoc,
1351 std::optional<unsigned> NumExpansions) {
1352 return new (Context)
1353 CXXFoldExpr(Context.DependentTy, Callee, LParenLoc, LHS, Operator,
1354 EllipsisLoc, RHS, RParenLoc, NumExpansions);
1355}
1356
1358 BinaryOperatorKind Operator) {
1359 // [temp.variadic]p9:
1360 // If N is zero for a unary fold-expression, the value of the expression is
1361 // && -> true
1362 // || -> false
1363 // , -> void()
1364 // if the operator is not listed [above], the instantiation is ill-formed.
1365 //
1366 // Note that we need to use something like int() here, not merely 0, to
1367 // prevent the result from being a null pointer constant.
1368 QualType ScalarType;
1369 switch (Operator) {
1370 case BO_LOr:
1371 return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_false);
1372 case BO_LAnd:
1373 return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_true);
1374 case BO_Comma:
1375 ScalarType = Context.VoidTy;
1376 break;
1377
1378 default:
1379 return Diag(EllipsisLoc, diag::err_fold_expression_empty)
1380 << BinaryOperator::getOpcodeStr(Operator);
1381 }
1382
1383 return new (Context) CXXScalarValueInitExpr(
1384 ScalarType, Context.getTrivialTypeSourceInfo(ScalarType, EllipsisLoc),
1385 EllipsisLoc);
1386}
static StringRef getIdentifier(const Token &Tok)
SourceLocation Loc
Definition: SemaObjC.cpp:758
static void CheckFoldOperand(Sema &S, Expr *E)
static bool isParameterPack(Expr *PackExpression)
Defines the clang::TypeLoc interface and its subclasses.
__device__ int
unsigned getIntWidth(QualType T) const
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:651
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:1122
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:1094
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:3905
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2300
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4834
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Definition: ExprCXX.h:2177
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:1260
ValueDecl * getDecl()
Definition: Expr.h:1328
SourceLocation getLocation() const
Definition: Expr.h:1336
Captures information about "declaration specifiers".
Definition: DeclSpec.h:247
TST getTypeSpecType() const
Definition: DeclSpec.h:534
ParsedType getRepAsType() const
Definition: DeclSpec.h:544
Expr * getRepAsExpr() const
Definition: DeclSpec.h:552
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:242
DeclarationName getCXXOperatorName(OverloadedOperatorKind Op)
Get the name of the overloadable C++ operator corresponding to Op.
The name of a declaration.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1900
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Definition: DeclSpec.h:2398
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:2047
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
Definition: DeclSpec.h:2633
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Definition: DeclSpec.h:2394
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:3039
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:1950
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: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
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:4174
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4203
std::optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
Definition: ExprCXX.h:4214
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4210
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:6582
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:6607
Expr * getIndexExpr() const
Definition: ExprCXX.h:4442
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:1668
Expr * getIndexExpr() const
Definition: TypeLoc.h:2108
Expr * getIndexExpr() const
Definition: Type.h:5433
Represents a parameter to a function.
Definition: Decl.h:1761
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:940
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:1007
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:478
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6354
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:9799
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:7404
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:822
ASTContext & Context
Definition: Sema.h:873
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:542
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:15198
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:10805
@ UPPC_Requirement
Definition: Sema.h:10873
const LangOptions & getLangOpts() const
Definition: Sema.h:535
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:19914
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:7644
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:8067
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:2389
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:2805
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:5905
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:5796
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:7343
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:7354
SourceLocation getNameLoc() const
Definition: TypeLoc.h:535
The base class of the type hierarchy.
Definition: Type.h:1827
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.cpp:2010
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:2334
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8143
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:3198
A set of unresolved declarations.
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3959
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:4005
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3862
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:3915
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:61
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:1271
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:258
@ EST_Dynamic
throw(T1, T2)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
Definition: DeclSpec.h:1318
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
Definition: DeclSpec.h:1583
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Definition: DeclSpec.h:1437
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1425
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1586
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1400
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
Definition: DeclSpec.h:1569
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Definition: DeclSpec.h:1564
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1441
One instance of this struct is used for each type in a declarator that is parsed.
Definition: DeclSpec.h:1248
enum clang::DeclaratorChunk::@222 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