clang  16.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"
18 #include "clang/Sema/ScopeInfo.h"
20 #include "clang/Sema/Template.h"
21 
22 using namespace clang;
23 
24 //----------------------------------------------------------------------------
25 // Visitor that collects unexpanded parameter packs
26 //----------------------------------------------------------------------------
27 
28 namespace {
29  /// A class that collects unexpanded parameter packs.
30  class CollectUnexpandedParameterPacksVisitor :
31  public RecursiveASTVisitor<CollectUnexpandedParameterPacksVisitor>
32  {
34  inherited;
35 
37 
38  bool InLambda = false;
39  unsigned DepthLimit = (unsigned)-1;
40 
41  void addUnexpanded(NamedDecl *ND, SourceLocation Loc = SourceLocation()) {
42  if (auto *VD = dyn_cast<VarDecl>(ND)) {
43  // For now, the only problematic case is a generic lambda's templated
44  // call operator, so we don't need to look for all the other ways we
45  // could have reached a dependent parameter pack.
46  auto *FD = dyn_cast<FunctionDecl>(VD->getDeclContext());
47  auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr;
48  if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit)
49  return;
50  } else if (getDepthAndIndex(ND).first >= DepthLimit)
51  return;
52 
53  Unexpanded.push_back({ND, Loc});
54  }
55  void addUnexpanded(const TemplateTypeParmType *T,
57  if (T->getDepth() < DepthLimit)
58  Unexpanded.push_back({T, Loc});
59  }
60 
61  public:
62  explicit CollectUnexpandedParameterPacksVisitor(
64  : Unexpanded(Unexpanded) {}
65 
66  bool shouldWalkTypesOfTypeLocs() const { return false; }
67 
68  //------------------------------------------------------------------------
69  // Recording occurrences of (unexpanded) parameter packs.
70  //------------------------------------------------------------------------
71 
72  /// Record occurrences of template type parameter packs.
73  bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
74  if (TL.getTypePtr()->isParameterPack())
75  addUnexpanded(TL.getTypePtr(), TL.getNameLoc());
76  return true;
77  }
78 
79  /// Record occurrences of template type parameter packs
80  /// when we don't have proper source-location information for
81  /// them.
82  ///
83  /// Ideally, this routine would never be used.
84  bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
85  if (T->isParameterPack())
86  addUnexpanded(T);
87 
88  return true;
89  }
90 
91  bool
92  VisitSubstTemplateTypeParmPackTypeLoc(SubstTemplateTypeParmPackTypeLoc TL) {
93  Unexpanded.push_back({TL.getTypePtr(), TL.getNameLoc()});
94  return true;
95  }
96 
97  bool VisitSubstTemplateTypeParmPackType(SubstTemplateTypeParmPackType *T) {
98  Unexpanded.push_back({T, SourceLocation()});
99  return true;
100  }
101 
102  bool
103  VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E) {
104  Unexpanded.push_back({E, E->getParameterPackLocation()});
105  return true;
106  }
107 
108  /// Record occurrences of function and non-type template
109  /// parameter packs in an expression.
110  bool VisitDeclRefExpr(DeclRefExpr *E) {
111  if (E->getDecl()->isParameterPack())
112  addUnexpanded(E->getDecl(), E->getLocation());
113 
114  return true;
115  }
116 
117  /// Record occurrences of template template parameter packs.
118  bool TraverseTemplateName(TemplateName Template) {
119  if (auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>(
120  Template.getAsTemplateDecl())) {
121  if (TTP->isParameterPack())
122  addUnexpanded(TTP);
123  }
124 
125  return inherited::TraverseTemplateName(Template);
126  }
127 
128  /// Suppress traversal into Objective-C container literal
129  /// elements that are pack expansions.
130  bool TraverseObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
132  return true;
133 
134  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
136  if (Element.isPackExpansion())
137  continue;
138 
139  TraverseStmt(Element.Key);
140  TraverseStmt(Element.Value);
141  }
142  return true;
143  }
144  //------------------------------------------------------------------------
145  // Pruning the search for unexpanded parameter packs.
146  //------------------------------------------------------------------------
147 
148  /// Suppress traversal into statements and expressions that
149  /// do not contain unexpanded parameter packs.
150  bool TraverseStmt(Stmt *S) {
151  Expr *E = dyn_cast_or_null<Expr>(S);
152  if ((E && E->containsUnexpandedParameterPack()) || InLambda)
153  return inherited::TraverseStmt(S);
154 
155  return true;
156  }
157 
158  /// Suppress traversal into types that do not contain
159  /// unexpanded parameter packs.
160  bool TraverseType(QualType T) {
161  if ((!T.isNull() && T->containsUnexpandedParameterPack()) || InLambda)
162  return inherited::TraverseType(T);
163 
164  return true;
165  }
166 
167  /// Suppress traversal into types with location information
168  /// that do not contain unexpanded parameter packs.
169  bool TraverseTypeLoc(TypeLoc TL) {
170  if ((!TL.getType().isNull() &&
172  InLambda)
173  return inherited::TraverseTypeLoc(TL);
174 
175  return true;
176  }
177 
178  /// Suppress traversal of parameter packs.
179  bool TraverseDecl(Decl *D) {
180  // A function parameter pack is a pack expansion, so cannot contain
181  // an unexpanded parameter pack. Likewise for a template parameter
182  // pack that contains any references to other packs.
183  if (D && D->isParameterPack())
184  return true;
185 
186  return inherited::TraverseDecl(D);
187  }
188 
189  /// Suppress traversal of pack-expanded attributes.
190  bool TraverseAttr(Attr *A) {
191  if (A->isPackExpansion())
192  return true;
193 
194  return inherited::TraverseAttr(A);
195  }
196 
197  /// Suppress traversal of pack expansion expressions and types.
198  ///@{
199  bool TraversePackExpansionType(PackExpansionType *T) { return true; }
200  bool TraversePackExpansionTypeLoc(PackExpansionTypeLoc TL) { return true; }
201  bool TraversePackExpansionExpr(PackExpansionExpr *E) { return true; }
202  bool TraverseCXXFoldExpr(CXXFoldExpr *E) { return true; }
203 
204  ///@}
205 
206  /// Suppress traversal of using-declaration pack expansion.
207  bool TraverseUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
208  if (D->isPackExpansion())
209  return true;
210 
211  return inherited::TraverseUnresolvedUsingValueDecl(D);
212  }
213 
214  /// Suppress traversal of using-declaration pack expansion.
215  bool TraverseUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) {
216  if (D->isPackExpansion())
217  return true;
218 
219  return inherited::TraverseUnresolvedUsingTypenameDecl(D);
220  }
221 
222  /// Suppress traversal of template argument pack expansions.
223  bool TraverseTemplateArgument(const TemplateArgument &Arg) {
224  if (Arg.isPackExpansion())
225  return true;
226 
227  return inherited::TraverseTemplateArgument(Arg);
228  }
229 
230  /// Suppress traversal of template argument pack expansions.
231  bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) {
232  if (ArgLoc.getArgument().isPackExpansion())
233  return true;
234 
235  return inherited::TraverseTemplateArgumentLoc(ArgLoc);
236  }
237 
238  /// Suppress traversal of base specifier pack expansions.
239  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base) {
240  if (Base.isPackExpansion())
241  return true;
242 
243  return inherited::TraverseCXXBaseSpecifier(Base);
244  }
245 
246  /// Suppress traversal of mem-initializer pack expansions.
247  bool TraverseConstructorInitializer(CXXCtorInitializer *Init) {
248  if (Init->isPackExpansion())
249  return true;
250 
251  return inherited::TraverseConstructorInitializer(Init);
252  }
253 
254  /// Note whether we're traversing a lambda containing an unexpanded
255  /// parameter pack. In this case, the unexpanded pack can occur anywhere,
256  /// including all the places where we normally wouldn't look. Within a
257  /// lambda, we don't propagate the 'contains unexpanded parameter pack' bit
258  /// outside an expression.
259  bool TraverseLambdaExpr(LambdaExpr *Lambda) {
260  // The ContainsUnexpandedParameterPack bit on a lambda is always correct,
261  // even if it's contained within another lambda.
262  if (!Lambda->containsUnexpandedParameterPack())
263  return true;
264 
265  bool WasInLambda = InLambda;
266  unsigned OldDepthLimit = DepthLimit;
267 
268  InLambda = true;
269  if (auto *TPL = Lambda->getTemplateParameterList())
270  DepthLimit = TPL->getDepth();
271 
272  inherited::TraverseLambdaExpr(Lambda);
273 
274  InLambda = WasInLambda;
275  DepthLimit = OldDepthLimit;
276  return true;
277  }
278 
279  /// Suppress traversal within pack expansions in lambda captures.
280  bool TraverseLambdaCapture(LambdaExpr *Lambda, const LambdaCapture *C,
281  Expr *Init) {
282  if (C->isPackExpansion())
283  return true;
284 
285  return inherited::TraverseLambdaCapture(Lambda, C, Init);
286  }
287  };
288 }
289 
290 /// Determine whether it's possible for an unexpanded parameter pack to
291 /// be valid in this location. This only happens when we're in a declaration
292 /// that is nested within an expression that could be expanded, such as a
293 /// lambda-expression within a function call.
294 ///
295 /// This is conservatively correct, but may claim that some unexpanded packs are
296 /// permitted when they are not.
298  for (auto *SI : FunctionScopes)
299  if (isa<sema::LambdaScopeInfo>(SI))
300  return true;
301  return false;
302 }
303 
304 /// Diagnose all of the unexpanded parameter packs in the given
305 /// vector.
306 bool
310  if (Unexpanded.empty())
311  return false;
312 
313  // If we are within a lambda expression and referencing a pack that is not
314  // declared within the lambda itself, that lambda contains an unexpanded
315  // parameter pack, and we are done.
316  // FIXME: Store 'Unexpanded' on the lambda so we don't need to recompute it
317  // later.
318  SmallVector<UnexpandedParameterPack, 4> LambdaParamPackReferences;
319  if (auto *LSI = getEnclosingLambda()) {
320  for (auto &Pack : Unexpanded) {
321  auto DeclaresThisPack = [&](NamedDecl *LocalPack) {
322  if (auto *TTPT = Pack.first.dyn_cast<const TemplateTypeParmType *>()) {
323  auto *TTPD = dyn_cast<TemplateTypeParmDecl>(LocalPack);
324  return TTPD && TTPD->getTypeForDecl() == TTPT;
325  }
326  return declaresSameEntity(Pack.first.get<const NamedDecl *>(),
327  LocalPack);
328  };
329  if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
330  LambdaParamPackReferences.push_back(Pack);
331  }
332 
333  if (LambdaParamPackReferences.empty()) {
334  // Construct in lambda only references packs declared outside the lambda.
335  // That's OK for now, but the lambda itself is considered to contain an
336  // unexpanded pack in this case, which will require expansion outside the
337  // lambda.
338 
339  // We do not permit pack expansion that would duplicate a statement
340  // expression, not even within a lambda.
341  // FIXME: We could probably support this for statement expressions that
342  // do not contain labels.
343  // FIXME: This is insufficient to detect this problem; consider
344  // f( ({ bad: 0; }) + pack ... );
345  bool EnclosingStmtExpr = false;
346  for (unsigned N = FunctionScopes.size(); N; --N) {
348  if (llvm::any_of(
349  Func->CompoundScopes,
350  [](sema::CompoundScopeInfo &CSI) { return CSI.IsStmtExpr; })) {
351  EnclosingStmtExpr = true;
352  break;
353  }
354  // Coumpound-statements outside the lambda are OK for now; we'll check
355  // for those when we finish handling the lambda.
356  if (Func == LSI)
357  break;
358  }
359 
360  if (!EnclosingStmtExpr) {
361  LSI->ContainsUnexpandedParameterPack = true;
362  return false;
363  }
364  } else {
365  Unexpanded = LambdaParamPackReferences;
366  }
367  }
368 
372 
373  for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
374  IdentifierInfo *Name = nullptr;
375  if (const TemplateTypeParmType *TTP
376  = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>())
377  Name = TTP->getIdentifier();
378  else
379  Name = Unexpanded[I].first.get<const NamedDecl *>()->getIdentifier();
380 
381  if (Name && NamesKnown.insert(Name).second)
382  Names.push_back(Name);
383 
384  if (Unexpanded[I].second.isValid())
385  Locations.push_back(Unexpanded[I].second);
386  }
387 
388  auto DB = Diag(Loc, diag::err_unexpanded_parameter_pack)
389  << (int)UPPC << (int)Names.size();
390  for (size_t I = 0, E = std::min(Names.size(), (size_t)2); I != E; ++I)
391  DB << Names[I];
392 
393  for (unsigned I = 0, N = Locations.size(); I != N; ++I)
394  DB << SourceRange(Locations[I]);
395  return true;
396 }
397 
399  TypeSourceInfo *T,
401  // C++0x [temp.variadic]p5:
402  // An appearance of a name of a parameter pack that is not expanded is
403  // ill-formed.
405  return false;
406 
408  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(
409  T->getTypeLoc());
410  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
411  return DiagnoseUnexpandedParameterPacks(Loc, UPPC, Unexpanded);
412 }
413 
416  // C++0x [temp.variadic]p5:
417  // An appearance of a name of a parameter pack that is not expanded is
418  // ill-formed.
420  return false;
421 
423  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(E);
424  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
425  return DiagnoseUnexpandedParameterPacks(E->getBeginLoc(), UPPC, Unexpanded);
426 }
427 
430  return false;
431 
433  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(RE);
434  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
435 
436  // We only care about unexpanded references to the RequiresExpr's own
437  // parameter packs.
438  auto Parms = RE->getLocalParameters();
439  llvm::SmallPtrSet<NamedDecl*, 8> ParmSet(Parms.begin(), Parms.end());
441  for (auto Parm : Unexpanded)
442  if (ParmSet.contains(Parm.first.dyn_cast<const NamedDecl *>()))
443  UnexpandedParms.push_back(Parm);
444  if (UnexpandedParms.empty())
445  return false;
446 
448  UnexpandedParms);
449 }
450 
453  // C++0x [temp.variadic]p5:
454  // An appearance of a name of a parameter pack that is not expanded is
455  // ill-formed.
456  if (!SS.getScopeRep() ||
458  return false;
459 
461  CollectUnexpandedParameterPacksVisitor(Unexpanded)
462  .TraverseNestedNameSpecifier(SS.getScopeRep());
463  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
465  UPPC, Unexpanded);
466 }
467 
470  // C++0x [temp.variadic]p5:
471  // An appearance of a name of a parameter pack that is not expanded is
472  // ill-formed.
473  switch (NameInfo.getName().getNameKind()) {
482  return false;
483 
487  // FIXME: We shouldn't need this null check!
488  if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
489  return DiagnoseUnexpandedParameterPack(NameInfo.getLoc(), TSInfo, UPPC);
490 
492  return false;
493 
494  break;
495  }
496 
498  CollectUnexpandedParameterPacksVisitor(Unexpanded)
499  .TraverseType(NameInfo.getName().getCXXNameType());
500  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
501  return DiagnoseUnexpandedParameterPacks(NameInfo.getLoc(), UPPC, Unexpanded);
502 }
503 
505  TemplateName Template,
507 
508  if (Template.isNull() || !Template.containsUnexpandedParameterPack())
509  return false;
510 
512  CollectUnexpandedParameterPacksVisitor(Unexpanded)
513  .TraverseTemplateName(Template);
514  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
515  return DiagnoseUnexpandedParameterPacks(Loc, UPPC, Unexpanded);
516 }
517 
520  if (Arg.getArgument().isNull() ||
522  return false;
523 
525  CollectUnexpandedParameterPacksVisitor(Unexpanded)
526  .TraverseTemplateArgumentLoc(Arg);
527  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
528  return DiagnoseUnexpandedParameterPacks(Arg.getLocation(), UPPC, Unexpanded);
529 }
530 
533  CollectUnexpandedParameterPacksVisitor(Unexpanded)
534  .TraverseTemplateArgument(Arg);
535 }
536 
539  CollectUnexpandedParameterPacksVisitor(Unexpanded)
540  .TraverseTemplateArgumentLoc(Arg);
541 }
542 
545  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
546 }
547 
550  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
551 }
552 
556  CollectUnexpandedParameterPacksVisitor(Unexpanded)
557  .TraverseNestedNameSpecifierLoc(NNS);
558 }
559 
561  const DeclarationNameInfo &NameInfo,
563  CollectUnexpandedParameterPacksVisitor(Unexpanded)
564  .TraverseDeclarationNameInfo(NameInfo);
565 }
566 
567 
570  SourceLocation EllipsisLoc) {
571  if (Arg.isInvalid())
572  return Arg;
573 
574  switch (Arg.getKind()) {
576  TypeResult Result = ActOnPackExpansion(Arg.getAsType(), EllipsisLoc);
577  if (Result.isInvalid())
578  return ParsedTemplateArgument();
579 
580  return ParsedTemplateArgument(Arg.getKind(), Result.get().getAsOpaquePtr(),
581  Arg.getLocation());
582  }
583 
585  ExprResult Result = ActOnPackExpansion(Arg.getAsExpr(), EllipsisLoc);
586  if (Result.isInvalid())
587  return ParsedTemplateArgument();
588 
589  return ParsedTemplateArgument(Arg.getKind(), Result.get(),
590  Arg.getLocation());
591  }
592 
595  SourceRange R(Arg.getLocation());
596  if (Arg.getScopeSpec().isValid())
597  R.setBegin(Arg.getScopeSpec().getBeginLoc());
598  Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
599  << R;
600  return ParsedTemplateArgument();
601  }
602 
603  return Arg.getTemplatePackExpansion(EllipsisLoc);
604  }
605  llvm_unreachable("Unhandled template argument kind?");
606 }
607 
609  SourceLocation EllipsisLoc) {
610  TypeSourceInfo *TSInfo;
611  GetTypeFromParser(Type, &TSInfo);
612  if (!TSInfo)
613  return true;
614 
615  TypeSourceInfo *TSResult = CheckPackExpansion(TSInfo, EllipsisLoc, None);
616  if (!TSResult)
617  return true;
618 
619  return CreateParsedType(TSResult->getType(), TSResult);
620 }
621 
624  Optional<unsigned> NumExpansions) {
625  // Create the pack expansion type and source-location information.
626  QualType Result = CheckPackExpansion(Pattern->getType(),
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  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, None);
663 }
664 
666  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();
677  CorrectDelayedTyposInExpr(Pattern);
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, Optional<unsigned> &NumExpansions) {
691  ShouldExpand = true;
692  RetainExpansion = false;
693  std::pair<const IdentifierInfo *, SourceLocation> FirstPack;
695  Optional<unsigned> CurNumExpansions;
696 
697  for (auto [P, Loc] : Unexpanded) {
698  // Compute the depth and index for this parameter pack.
700  unsigned NewPackSize;
701  const auto *ND = P.dyn_cast<const NamedDecl *>();
702  if (ND && isa<VarDecl>(ND)) {
703  const auto *DAP =
706  if (!DAP) {
707  // We can't expand this function parameter pack, so we can't expand
708  // the pack expansion.
709  ShouldExpand = false;
710  continue;
711  }
712  NewPackSize = DAP->size();
713  } else if (ND) {
714  Pos = getDepthAndIndex(ND);
715  } else if (const auto *TTP = P.dyn_cast<const TemplateTypeParmType *>()) {
716  Pos = {TTP->getDepth(), TTP->getIndex()};
717  ND = TTP->getDecl();
718  // FIXME: We either should have some fallback for canonical TTP, or
719  // never have canonical TTP here.
720  } else if (const auto *STP =
721  P.dyn_cast<const SubstTemplateTypeParmPackType *>()) {
722  NewPackSize = STP->getNumArgs();
723  ND = STP->getReplacedParameter();
724  } else {
725  const auto *SEP = P.get<const SubstNonTypeTemplateParmPackExpr *>();
726  NewPackSize = SEP->getArgumentPack().pack_size();
727  ND = SEP->getParameterPack();
728  }
729 
730  if (Pos) {
731  // If we don't have a template argument at this depth/index, then we
732  // cannot expand the pack expansion. Make a note of this, but we still
733  // want to check any parameter packs we *do* have arguments for.
734  if (Pos->first >= TemplateArgs.getNumLevels() ||
735  !TemplateArgs.hasTemplateArgument(Pos->first, Pos->second)) {
736  ShouldExpand = false;
737  continue;
738  }
739  // Determine the size of the argument pack.
740  NewPackSize = TemplateArgs(Pos->first, Pos->second).pack_size();
741  // C++0x [temp.arg.explicit]p9:
742  // Template argument deduction can extend the sequence of template
743  // arguments corresponding to a template parameter pack, even when the
744  // sequence contains explicitly specified template arguments.
746  if (const NamedDecl *PartialPack =
748  PartialPack && getDepthAndIndex(PartialPack) == *Pos) {
749  RetainExpansion = true;
750  // We don't actually know the new pack size yet.
751  PartialExpansion = {NewPackSize, Loc};
752  continue;
753  }
754  }
755 
756  // FIXME: Workaround for Canonical TTP.
757  const IdentifierInfo *Name = ND ? ND->getIdentifier() : nullptr;
758  if (!CurNumExpansions) {
759  // The is the first pack we've seen for which we have an argument.
760  // Record it.
761  CurNumExpansions = NewPackSize;
762  FirstPack = {Name, Loc};
763  } else if (NewPackSize != *CurNumExpansions) {
764  // C++0x [temp.variadic]p5:
765  // All of the parameter packs expanded by a pack expansion shall have
766  // the same number of arguments specified.
767  Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
768  << FirstPack.first << Name << *CurNumExpansions << NewPackSize
769  << SourceRange(FirstPack.second) << SourceRange(Loc);
770  return true;
771  }
772  }
773 
774  if (NumExpansions && CurNumExpansions &&
775  *NumExpansions != *CurNumExpansions) {
776  Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
777  << FirstPack.first << *CurNumExpansions << *NumExpansions
778  << SourceRange(FirstPack.second);
779  return true;
780  }
781 
782  // If we're performing a partial expansion but we also have a full expansion,
783  // expand to the number of common arguments. For example, given:
784  //
785  // template<typename ...T> struct A {
786  // template<typename ...U> void f(pair<T, U>...);
787  // };
788  //
789  // ... a call to 'A<int, int>().f<int>' should expand the pack once and
790  // retain an expansion.
791  if (PartialExpansion) {
792  if (CurNumExpansions && *CurNumExpansions < PartialExpansion->first) {
793  NamedDecl *PartialPack =
795  Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_partial)
796  << PartialPack << PartialExpansion->first << *CurNumExpansions
797  << SourceRange(PartialExpansion->second);
798  return true;
799  }
800  NumExpansions = PartialExpansion->first;
801  } else {
802  NumExpansions = CurNumExpansions;
803  }
804 
805  return false;
806 }
807 
809  const MultiLevelTemplateArgumentList &TemplateArgs) {
810  QualType Pattern = cast<PackExpansionType>(T)->getPattern();
812  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(Pattern);
813 
814  Optional<unsigned> Result;
815  auto setResultSz = [&Result](unsigned Size) {
816  assert((!Result || *Result == Size) && "inconsistent pack sizes");
817  Result = Size;
818  };
819  auto setResultPos = [&](const std::pair<unsigned, unsigned> &Pos) -> bool {
820  unsigned Depth = Pos.first, Index = Pos.second;
821  if (Depth >= TemplateArgs.getNumLevels() ||
822  !TemplateArgs.hasTemplateArgument(Depth, Index))
823  // The pattern refers to an unknown template argument. We're not ready to
824  // expand this pack yet.
825  return true;
826  // Determine the size of the argument pack.
827  setResultSz(TemplateArgs(Depth, Index).pack_size());
828  return false;
829  };
830 
831  for (auto [I, _] : Unexpanded) {
832  if (const auto *TTP = I.dyn_cast<const TemplateTypeParmType *>()) {
833  if (setResultPos({TTP->getDepth(), TTP->getIndex()}))
834  return None;
835  } else if (const auto *STP =
836  I.dyn_cast<const SubstTemplateTypeParmPackType *>()) {
837  setResultSz(STP->getNumArgs());
838  } else if (const auto *SEP =
839  I.dyn_cast<const SubstNonTypeTemplateParmPackExpr *>()) {
840  setResultSz(SEP->getArgumentPack().pack_size());
841  } else {
842  const auto *ND = I.get<const NamedDecl *>();
843  // Function parameter pack or init-capture pack.
844  if (isa<VarDecl>(ND)) {
845  const auto *DAP =
848  if (!DAP)
849  // The pattern refers to an unexpanded pack. We're not ready to expand
850  // this pack yet.
851  return None;
852  setResultSz(DAP->size());
853  } else if (setResultPos(getDepthAndIndex(ND))) {
854  return None;
855  }
856  }
857  }
858 
859  return Result;
860 }
861 
863  const DeclSpec &DS = D.getDeclSpec();
864  switch (DS.getTypeSpecType()) {
865  case TST_typename:
867  case TST_typeofType:
868 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
869 #include "clang/Basic/TransformTypeTraits.def"
870  case TST_atomic: {
871  QualType T = DS.getRepAsType().get();
872  if (!T.isNull() && T->containsUnexpandedParameterPack())
873  return true;
874  break;
875  }
876 
878  case TST_typeofExpr:
879  case TST_decltype:
880  case TST_bitint:
881  if (DS.getRepAsExpr() &&
883  return true;
884  break;
885 
886  case TST_unspecified:
887  case TST_void:
888  case TST_char:
889  case TST_wchar:
890  case TST_char8:
891  case TST_char16:
892  case TST_char32:
893  case TST_int:
894  case TST_int128:
895  case TST_half:
896  case TST_float:
897  case TST_double:
898  case TST_Accum:
899  case TST_Fract:
900  case TST_Float16:
901  case TST_float128:
902  case TST_ibm128:
903  case TST_bool:
904  case TST_decimal32:
905  case TST_decimal64:
906  case TST_decimal128:
907  case TST_enum:
908  case TST_union:
909  case TST_struct:
910  case TST_interface:
911  case TST_class:
912  case TST_auto:
913  case TST_auto_type:
914  case TST_decltype_auto:
915  case TST_BFloat16:
916 #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
917 #include "clang/Basic/OpenCLImageTypes.def"
918  case TST_unknown_anytype:
919  case TST_error:
920  break;
921  }
922 
923  for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) {
924  const DeclaratorChunk &Chunk = D.getTypeObject(I);
925  switch (Chunk.Kind) {
931  // These declarator chunks cannot contain any parameter packs.
932  break;
933 
935  if (Chunk.Arr.NumElts &&
937  return true;
938  break;
940  for (unsigned i = 0, e = Chunk.Fun.NumParams; i != e; ++i) {
941  ParmVarDecl *Param = cast<ParmVarDecl>(Chunk.Fun.Params[i].Param);
942  QualType ParamTy = Param->getType();
943  assert(!ParamTy.isNull() && "Couldn't parse type?");
944  if (ParamTy->containsUnexpandedParameterPack()) return true;
945  }
946 
947  if (Chunk.Fun.getExceptionSpecType() == EST_Dynamic) {
948  for (unsigned i = 0; i != Chunk.Fun.getNumExceptions(); ++i) {
949  if (Chunk.Fun.Exceptions[i]
950  .Ty.get()
952  return true;
953  }
954  } else if (isComputedNoexcept(Chunk.Fun.getExceptionSpecType()) &&
956  return true;
957 
958  if (Chunk.Fun.hasTrailingReturnType()) {
959  QualType T = Chunk.Fun.getTrailingReturnType().get();
960  if (!T.isNull() && T->containsUnexpandedParameterPack())
961  return true;
962  }
963  break;
964 
966  if (Chunk.Mem.Scope().getScopeRep() &&
968  return true;
969  break;
970  }
971  }
972 
973  if (Expr *TRC = D.getTrailingRequiresClause())
974  if (TRC->containsUnexpandedParameterPack())
975  return true;
976 
977  return false;
978 }
979 
980 namespace {
981 
982 // Callback to only accept typo corrections that refer to parameter packs.
983 class ParameterPackValidatorCCC final : public CorrectionCandidateCallback {
984  public:
985  bool ValidateCandidate(const TypoCorrection &candidate) override {
986  NamedDecl *ND = candidate.getCorrectionDecl();
987  return ND && ND->isParameterPack();
988  }
989 
990  std::unique_ptr<CorrectionCandidateCallback> clone() override {
991  return std::make_unique<ParameterPackValidatorCCC>(*this);
992  }
993 };
994 
995 }
996 
997 /// Called when an expression computing the size of a parameter pack
998 /// is parsed.
999 ///
1000 /// \code
1001 /// template<typename ...Types> struct count {
1002 /// static const unsigned value = sizeof...(Types);
1003 /// };
1004 /// \endcode
1005 ///
1006 //
1007 /// \param OpLoc The location of the "sizeof" keyword.
1008 /// \param Name The name of the parameter pack whose size will be determined.
1009 /// \param NameLoc The source location of the name of the parameter pack.
1010 /// \param RParenLoc The location of the closing parentheses.
1012  SourceLocation OpLoc,
1013  IdentifierInfo &Name,
1014  SourceLocation NameLoc,
1015  SourceLocation RParenLoc) {
1016  // C++0x [expr.sizeof]p5:
1017  // The identifier in a sizeof... expression shall name a parameter pack.
1018  LookupResult R(*this, &Name, NameLoc, LookupOrdinaryName);
1019  LookupName(R, S);
1020 
1021  NamedDecl *ParameterPack = nullptr;
1022  switch (R.getResultKind()) {
1023  case LookupResult::Found:
1024  ParameterPack = R.getFoundDecl();
1025  break;
1026 
1029  ParameterPackValidatorCCC CCC{};
1030  if (TypoCorrection Corrected =
1031  CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, nullptr,
1032  CCC, CTK_ErrorRecovery)) {
1033  diagnoseTypo(Corrected,
1034  PDiag(diag::err_sizeof_pack_no_pack_name_suggest) << &Name,
1035  PDiag(diag::note_parameter_pack_here));
1036  ParameterPack = Corrected.getCorrectionDecl();
1037  }
1038  break;
1039  }
1042  break;
1043 
1046  return ExprError();
1047  }
1048 
1049  if (!ParameterPack || !ParameterPack->isParameterPack()) {
1050  Diag(NameLoc, diag::err_sizeof_pack_no_pack_name)
1051  << &Name;
1052  return ExprError();
1053  }
1054 
1055  MarkAnyDeclReferenced(OpLoc, ParameterPack, true);
1056 
1057  return SizeOfPackExpr::Create(Context, OpLoc, ParameterPack, NameLoc,
1058  RParenLoc);
1059 }
1060 
1063  TemplateArgumentLoc OrigLoc,
1064  SourceLocation &Ellipsis, Optional<unsigned> &NumExpansions) const {
1065  const TemplateArgument &Argument = OrigLoc.getArgument();
1066  assert(Argument.isPackExpansion());
1067  switch (Argument.getKind()) {
1068  case TemplateArgument::Type: {
1069  // FIXME: We shouldn't ever have to worry about missing
1070  // type-source info!
1071  TypeSourceInfo *ExpansionTSInfo = OrigLoc.getTypeSourceInfo();
1072  if (!ExpansionTSInfo)
1073  ExpansionTSInfo = Context.getTrivialTypeSourceInfo(Argument.getAsType(),
1074  Ellipsis);
1075  PackExpansionTypeLoc Expansion =
1076  ExpansionTSInfo->getTypeLoc().castAs<PackExpansionTypeLoc>();
1077  Ellipsis = Expansion.getEllipsisLoc();
1078 
1079  TypeLoc Pattern = Expansion.getPatternLoc();
1080  NumExpansions = Expansion.getTypePtr()->getNumExpansions();
1081 
1082  // We need to copy the TypeLoc because TemplateArgumentLocs store a
1083  // TypeSourceInfo.
1084  // FIXME: Find some way to avoid the copy?
1085  TypeLocBuilder TLB;
1086  TLB.pushFullCopy(Pattern);
1087  TypeSourceInfo *PatternTSInfo =
1088  TLB.getTypeSourceInfo(Context, Pattern.getType());
1089  return TemplateArgumentLoc(TemplateArgument(Pattern.getType()),
1090  PatternTSInfo);
1091  }
1092 
1094  PackExpansionExpr *Expansion
1095  = cast<PackExpansionExpr>(Argument.getAsExpr());
1096  Expr *Pattern = Expansion->getPattern();
1097  Ellipsis = Expansion->getEllipsisLoc();
1098  NumExpansions = Expansion->getNumExpansions();
1099  return TemplateArgumentLoc(Pattern, Pattern);
1100  }
1101 
1103  Ellipsis = OrigLoc.getTemplateEllipsisLoc();
1104  NumExpansions = Argument.getNumTemplateExpansions();
1106  OrigLoc.getTemplateQualifierLoc(),
1107  OrigLoc.getTemplateNameLoc());
1108 
1115  return TemplateArgumentLoc();
1116  }
1117 
1118  llvm_unreachable("Invalid TemplateArgument Kind!");
1119 }
1120 
1122  assert(Arg.containsUnexpandedParameterPack());
1123 
1124  // If this is a substituted pack, grab that pack. If not, we don't know
1125  // the size yet.
1126  // FIXME: We could find a size in more cases by looking for a substituted
1127  // pack anywhere within this argument, but that's not necessary in the common
1128  // case for 'sizeof...(A)' handling.
1129  TemplateArgument Pack;
1130  switch (Arg.getKind()) {
1132  if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
1133  Pack = Subst->getArgumentPack();
1134  else
1135  return None;
1136  break;
1137 
1139  if (auto *Subst =
1140  dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.getAsExpr()))
1141  Pack = Subst->getArgumentPack();
1142  else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr())) {
1143  for (VarDecl *PD : *Subst)
1144  if (PD->isParameterPack())
1145  return None;
1146  return Subst->getNumExpansions();
1147  } else
1148  return None;
1149  break;
1150 
1154  Pack = Subst->getArgumentPack();
1155  else
1156  return None;
1157  break;
1158 
1165  return None;
1166  }
1167 
1168  // Check that no argument in the pack is itself a pack expansion.
1169  for (TemplateArgument Elem : Pack.pack_elements()) {
1170  // There's no point recursing in this case; we would have already
1171  // expanded this pack expansion into the enclosing pack if we could.
1172  if (Elem.isPackExpansion())
1173  return None;
1174  }
1175  return Pack.pack_size();
1176 }
1177 
1178 static void CheckFoldOperand(Sema &S, Expr *E) {
1179  if (!E)
1180  return;
1181 
1182  E = E->IgnoreImpCasts();
1183  auto *OCE = dyn_cast<CXXOperatorCallExpr>(E);
1184  if ((OCE && OCE->isInfixBinaryOp()) || isa<BinaryOperator>(E) ||
1185  isa<AbstractConditionalOperator>(E)) {
1186  S.Diag(E->getExprLoc(), diag::err_fold_expression_bad_operand)
1187  << E->getSourceRange()
1189  << FixItHint::CreateInsertion(E->getEndLoc(), ")");
1190  }
1191 }
1192 
1194  tok::TokenKind Operator,
1195  SourceLocation EllipsisLoc, Expr *RHS,
1196  SourceLocation RParenLoc) {
1197  // LHS and RHS must be cast-expressions. We allow an arbitrary expression
1198  // in the parser and reduce down to just cast-expressions here.
1199  CheckFoldOperand(*this, LHS);
1200  CheckFoldOperand(*this, RHS);
1201 
1202  auto DiscardOperands = [&] {
1205  };
1206 
1207  // [expr.prim.fold]p3:
1208  // In a binary fold, op1 and op2 shall be the same fold-operator, and
1209  // either e1 shall contain an unexpanded parameter pack or e2 shall contain
1210  // an unexpanded parameter pack, but not both.
1211  if (LHS && RHS &&
1214  DiscardOperands();
1215  return Diag(EllipsisLoc,
1217  ? diag::err_fold_expression_packs_both_sides
1218  : diag::err_pack_expansion_without_parameter_packs)
1219  << LHS->getSourceRange() << RHS->getSourceRange();
1220  }
1221 
1222  // [expr.prim.fold]p2:
1223  // In a unary fold, the cast-expression shall contain an unexpanded
1224  // parameter pack.
1225  if (!LHS || !RHS) {
1226  Expr *Pack = LHS ? LHS : RHS;
1227  assert(Pack && "fold expression with neither LHS nor RHS");
1228  DiscardOperands();
1229  if (!Pack->containsUnexpandedParameterPack())
1230  return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1231  << Pack->getSourceRange();
1232  }
1233 
1234  BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
1235 
1236  // Perform first-phase name lookup now.
1237  UnresolvedLookupExpr *ULE = nullptr;
1238  {
1239  UnresolvedSet<16> Functions;
1240  LookupBinOp(S, EllipsisLoc, Opc, Functions);
1241  if (!Functions.empty()) {
1245  /*NamingClass*/ nullptr, NestedNameSpecifierLoc(),
1246  DeclarationNameInfo(OpName, EllipsisLoc), Functions);
1247  if (Callee.isInvalid())
1248  return ExprError();
1249  ULE = cast<UnresolvedLookupExpr>(Callee.get());
1250  }
1251  }
1252 
1253  return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1254  None);
1255 }
1256 
1258  SourceLocation LParenLoc, Expr *LHS,
1259  BinaryOperatorKind Operator,
1260  SourceLocation EllipsisLoc, Expr *RHS,
1261  SourceLocation RParenLoc,
1262  Optional<unsigned> NumExpansions) {
1263  return new (Context)
1264  CXXFoldExpr(Context.DependentTy, Callee, LParenLoc, LHS, Operator,
1265  EllipsisLoc, RHS, RParenLoc, NumExpansions);
1266 }
1267 
1269  BinaryOperatorKind Operator) {
1270  // [temp.variadic]p9:
1271  // If N is zero for a unary fold-expression, the value of the expression is
1272  // && -> true
1273  // || -> false
1274  // , -> void()
1275  // if the operator is not listed [above], the instantiation is ill-formed.
1276  //
1277  // Note that we need to use something like int() here, not merely 0, to
1278  // prevent the result from being a null pointer constant.
1279  QualType ScalarType;
1280  switch (Operator) {
1281  case BO_LOr:
1282  return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_false);
1283  case BO_LAnd:
1284  return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_true);
1285  case BO_Comma:
1286  ScalarType = Context.VoidTy;
1287  break;
1288 
1289  default:
1290  return Diag(EllipsisLoc, diag::err_fold_expression_empty)
1291  << BinaryOperator::getOpcodeStr(Operator);
1292  }
1293 
1294  return new (Context) CXXScalarValueInitExpr(
1295  ScalarType, Context.getTrivialTypeSourceInfo(ScalarType, EllipsisLoc),
1296  EllipsisLoc);
1297 }
clang::SourceRange::setBegin
void setBegin(SourceLocation b)
Definition: SourceLocation.h:222
clang::TST_half
@ TST_half
Definition: Specifiers.h:63
clang::PackExpansionExpr::getPattern
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4104
clang::DeclaratorChunk::FunctionTypeInfo::NumParams
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1338
clang::DeclaratorChunk::Pointer
@ Pointer
Definition: DeclSpec.h:1200
clang::OpaquePtr::get
PtrTy get() const
Definition: Ownership.h:80
CheckFoldOperand
static void CheckFoldOperand(Sema &S, Expr *E)
Definition: SemaTemplateVariadic.cpp:1178
clang::LookupResult::NotFound
@ NotFound
No entity found met the criteria.
Definition: Lookup.h:50
clang::TST_Float16
@ TST_Float16
Definition: Specifiers.h:64
clang::TST_char8
@ TST_char8
Definition: Specifiers.h:57
clang::TST_bool
@ TST_bool
Definition: Specifiers.h:72
TypeLocBuilder.h
clang::DeclaratorChunk::FunctionTypeInfo::hasTrailingReturnType
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
Definition: DeclSpec.h:1521
clang::PackExpansionExpr::getEllipsisLoc
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4111
clang::DeclRefExpr::getLocation
SourceLocation getLocation() const
Definition: Expr.h:1312
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6604
clang::ObjCDictionaryElement
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:263
clang::DeclarationName::Identifier
@ Identifier
Definition: DeclarationName.h:209
clang::DeclarationName::CXXLiteralOperatorName
@ CXXLiteralOperatorName
Definition: DeclarationName.h:219
clang::ObjCDictionaryLiteral::getNumElements
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:360
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::Sema::ActOnCXXBoolLiteral
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
Definition: SemaExprCXX.cpp:810
clang::LambdaCapture
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
clang::TST_interface
@ TST_interface
Definition: Specifiers.h:80
clang::TemplateName::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templ...
Definition: TemplateName.cpp:281
clang::TypoCorrection
Simple class containing the result of Sema::CorrectTypo.
Definition: TypoCorrection.h:42
clang::FixItHint::CreateInsertion
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
clang::DeclaratorChunk::Mem
MemberPointerTypeInfo Mem
Definition: DeclSpec.h:1577
clang::TemplateArgument::pack_elements
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:365
clang::getDepthAndIndex
std::pair< unsigned, unsigned > getDepthAndIndex(const NamedDecl *ND)
Retrieve the depth and index of a template parameter.
Definition: SemaInternal.h:65
clang::Declarator::getNumTypeObjects
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Definition: DeclSpec.h:2299
clang::TST_unspecified
@ TST_unspecified
Definition: Specifiers.h:53
clang::TemplateArgument::Null
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:67
clang::LookupResult::FoundOverloaded
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
Definition: Lookup.h:63
clang::TypeLocBuilder::pushFullCopy
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
Definition: TypeLocBuilder.cpp:18
clang::TST_typename
@ TST_typename
Definition: Specifiers.h:81
SemaInternal.h
clang::SubstNonTypeTemplateParmPackExpr
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4354
clang::ASTContext::VoidTy
CanQualType VoidTy
Definition: ASTContext.h:1107
clang::DeclarationName::CXXConstructorName
@ CXXConstructorName
Definition: DeclarationName.h:212
llvm::SmallVector
Definition: LLVM.h:38
Lookup.h
clang::TemplateArgumentLoc::getTemplateEllipsisLoc
SourceLocation getTemplateEllipsisLoc() const
Definition: TemplateBase.h:554
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::Sema::FunctionScopes
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:799
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::TST_void
@ TST_void
Definition: Specifiers.h:54
clang::Sema::UPPC_Requirement
@ UPPC_Requirement
Definition: Sema.h:8597
clang::DeclSpec::getRepAsExpr
Expr * getRepAsExpr() const
Definition: DeclSpec.h:513
clang::ASTContext::DeclarationNames
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:664
clang::TypeLocBuilder::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Definition: TypeLocBuilder.h:107
clang::Stmt::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:324
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::TemplateName::getAsTemplateDecl
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Definition: TemplateName.cpp:146
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:56
clang::UnresolvedUsingValueDecl::isPackExpansion
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:3816
clang::TST_struct
@ TST_struct
Definition: Specifiers.h:78
clang::RequiresExpr
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:471
clang::DeclaratorChunk::Fun
FunctionTypeInfo Fun
Definition: DeclSpec.h:1575
clang::EST_Dynamic
@ EST_Dynamic
throw(T1, T2)
Definition: ExceptionSpecificationType.h:23
clang::LookupResult
Represents the results of name lookup.
Definition: Lookup.h:46
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1712
clang::Sema::Diag
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: Sema.cpp:1887
clang::Sema::getFullyPackExpandedSize
Optional< unsigned > getFullyPackExpandedSize(TemplateArgument Arg)
Given a template argument that contains an unexpanded parameter pack, but which has already been subs...
Definition: SemaTemplateVariadic.cpp:1121
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::Type::getContainedDeducedType
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.cpp:1889
clang::LookupResult::NotFoundInCurrentInstantiation
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition: Lookup.h:55
clang::TemplateArgument::Declaration
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:74
clang::BinaryOperator::getOpcodeStr
StringRef getOpcodeStr() const
Definition: Expr.h:3877
clang::Sema::BuildEmptyCXXFoldExpr
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Definition: SemaTemplateVariadic.cpp:1268
clang::DeclarationName::CXXDeductionGuideName
@ CXXDeductionGuideName
Definition: DeclarationName.h:216
clang::Type::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:2004
clang::TST_enum
@ TST_enum
Definition: Specifiers.h:76
clang::TST_error
@ TST_error
Definition: Specifiers.h:96
llvm::Optional< unsigned >
llvm::SmallPtrSet
Definition: ASTContext.h:82
clang::TST_auto
@ TST_auto
Definition: Specifiers.h:89
clang::TypeSpecTypeLoc::getNameLoc
SourceLocation getNameLoc() const
Definition: TypeLoc.h:523
clang::TemplateArgument::isNull
bool isNull() const
Determine whether this template argument has no value.
Definition: TemplateBase.h:247
clang::CXXScopeSpec
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:65
clang::isComputedNoexcept
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
Definition: ExceptionSpecificationType.h:39
clang::Expr::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Definition: Expr.h:232
clang::ConcreteTypeLoc::getTypePtr
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:409
clang::DeclaratorChunk::FunctionTypeInfo::getExceptionSpecType
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Definition: DeclSpec.h:1502
clang::ASTContext::getPackExpansionType
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
Definition: ASTContext.cpp:5264
clang::DeclaratorChunk::FunctionTypeInfo::getTrailingReturnType
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1524
clang::DeclaratorChunk::Arr
ArrayTypeInfo Arr
Definition: DeclSpec.h:1574
clang::DeclaratorChunk::Function
@ Function
Definition: DeclSpec.h:1200
clang::ParsedTemplateArgument::Type
@ Type
A template type parameter, stored as a type.
Definition: ParsedTemplate.h:34
clang::TST_auto_type
@ TST_auto_type
Definition: Specifiers.h:91
clang::Expr::IgnoreImpCasts
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:3015
clang::TST_unknown_anytype
@ TST_unknown_anytype
Definition: Specifiers.h:92
clang::TemplateArgument::getAsExpr
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:341
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
clang::Sema::BuildCXXFoldExpr
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, Optional< unsigned > NumExpansions)
Definition: SemaTemplateVariadic.cpp:1257
clang::TemplateArgumentLoc::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:514
clang::TemplateArgument::Expression
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:96
clang::ObjCDictionaryElement::isPackExpansion
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:278
clang::Declarator::getTrailingRequiresClause
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
Definition: DeclSpec.h:2538
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:409
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1565
clang::CXXFoldExpr
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4625
clang::ExprError
ExprResult ExprError()
Definition: Ownership.h:278
clang::TemplateArgument::Integral
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:82
clang::Sema::CheckParameterPacksForExpansion
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, bool &RetainExpansion, Optional< unsigned > &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
Definition: SemaTemplateVariadic.cpp:686
clang::Declarator::getDeclSpec
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:1969
clang::TemplateArgument::NullPtr
@ 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
clang::UnresolvedSetImpl::empty
bool empty() const
Definition: UnresolvedSet.h:126
clang::UnresolvedUsingTypenameDecl
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3858
clang::TemplateArgumentLoc::getLocation
SourceLocation getLocation() const
Definition: TemplateBase.h:495
clang::TypeLocBuilder::push
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
Definition: TypeLocBuilder.h:99
clang::PackExpansionTypeLoc
Definition: TypeLoc.h:2521
clang::TST_typeof_unqualType
@ TST_typeof_unqualType
Definition: Specifiers.h:84
Template.h
clang::Sema::getEnclosingLambda
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
Definition: Sema.cpp:2314
clang::NestedNameSpecifier::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
Definition: NestedNameSpecifier.cpp:242
min
__DEVICE__ int min(int __a, int __b)
Definition: __clang_cuda_math.h:197
clang::DeclaratorChunk::BlockPointer
@ BlockPointer
Definition: DeclSpec.h:1200
clang::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:244
clang::SubstTemplateTypeParmPackTypeLoc
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:849
clang::DeclaratorChunk::FunctionTypeInfo::Exceptions
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Definition: DeclSpec.h:1375
clang::PackExpansionType
Represents a pack expansion of types.
Definition: Type.h:5830
clang::UnresolvedLookupExpr
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3097
clang::Sema::MarkAnyDeclReferenced
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
Definition: SemaExpr.cpp:19774
clang::DeclSpec::getTypeSpecType
TST getTypeSpecType() const
Definition: DeclSpec.h:495
clang::Sema::CreateParsedType
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6552
clang::TST_decltype
@ TST_decltype
Definition: Specifiers.h:86
clang::PackExpansionTypeLoc::getEllipsisLoc
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2525
clang::LambdaExpr
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1872
clang::Sema::UnexpandedParameterPackContext
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:8532
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
clang::CXXScopeSpec::isValid
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Definition: DeclSpec.h:198
clang::DeclarationName::CXXDestructorName
@ CXXDestructorName
Definition: DeclarationName.h:213
clang::LambdaExpr::getTemplateParameterList
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition: ExprCXX.cpp:1270
clang::Sema::LookupName
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
Definition: SemaLookup.cpp:2165
clang::Sema::ActOnCXXFoldExpr
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 ).
Definition: SemaTemplateVariadic.cpp:1193
clang::ObjCDictionaryElement::Key
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:265
clang::ASTContext::DependentTy
CanQualType DependentTy
Definition: ASTContext.h:1135
getIdentifier
static StringRef getIdentifier(const Token &Tok)
Definition: ParsePragma.cpp:1518
clang::DeclarationNameTable::getCXXOperatorName
DeclarationName getCXXOperatorName(OverloadedOperatorKind Op)
Get the name of the overloadable C++ operator corresponding to Op.
Definition: DeclarationName.h:648
clang::ObjCDictionaryLiteral
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:306
clang::DeclaratorChunk::FunctionTypeInfo::getNumExceptions
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
Definition: DeclSpec.h:1507
clang::DeclaratorChunk::TypeAndRange::Ty
ParsedType Ty
Definition: DeclSpec.h:1295
clang::RecursiveASTVisitor
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Definition: RecursiveASTVisitor.h:152
Depth
int Depth
Definition: ASTDiff.cpp:189
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7386
clang::TST_atomic
@ TST_atomic
Definition: Specifiers.h:93
clang::DeclaratorChunk::Array
@ Array
Definition: DeclSpec.h:1200
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:61
clang::Sema::DiagnoseUnexpandedParameterPack
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
Definition: SemaTemplateVariadic.cpp:398
clang::DeclarationName::CXXOperatorName
@ CXXOperatorName
Definition: DeclarationName.h:215
clang::DeclaratorChunk::FunctionTypeInfo::NoexceptExpr
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1379
clang::MultiLevelTemplateArgumentList
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition: Template.h:75
clang::DeclarationNameInfo::getNamedTypeInfo
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
Definition: DeclarationName.h:806
clang::DeclaratorChunk::MemberPointer
@ MemberPointer
Definition: DeclSpec.h:1200
clang::Sema::PDiag
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaInternal.h:24
clang::Stmt::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:348
clang::Sema::GetTypeFromParser
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
Definition: SemaType.cpp:3103
clang::DeclRefExpr::getDecl
ValueDecl * getDecl()
Definition: Expr.h:1304
clang::DeclaratorChunk::ArrayTypeInfo::NumElts
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
Definition: DeclSpec.h:1262
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:457
Expr.h
clang::UnresolvedSet
A set of unresolved declarations.
Definition: UnresolvedSet.h:148
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:906
clang::TemplateArgumentLoc::getArgument
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:506
clang::ParsedTemplateArgument::getTemplatePackExpansion
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
Definition: SemaTemplate.cpp:912
clang::Sema::DiagnoseAmbiguousLookup
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
Definition: SemaLookup.cpp:2778
clang::MultiLevelTemplateArgumentList::getNumLevels
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
Definition: Template.h:122
clang::TST_char
@ TST_char
Definition: Specifiers.h:55
clang::TST_int
@ TST_int
Definition: Specifiers.h:60
clang::TST_int128
@ TST_int128
Definition: Specifiers.h:61
clang::DeclarationName::CXXUsingDirective
@ CXXUsingDirective
Definition: DeclarationName.h:222
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::ParsedTemplateArgument::Template
@ Template
A template template argument, stored as a template name.
Definition: ParsedTemplate.h:38
Base
clang::TemplateArgument::isPackExpansion
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
Definition: TemplateBase.cpp:247
clang::RequiresExpr::getLocalParameters
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:508
clang::SubstTemplateTemplateParmPackStorage
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:139
clang::SubstTemplateTypeParmPackType
Represents the result of substituting a set of types for a template type parameter pack.
Definition: Type.h:5154
clang::UnresolvedUsingValueDecl
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3762
clang::PackExpansionExpr
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4075
clang::DeclaratorChunk::FunctionTypeInfo::Params
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1363
clang::LookupResult::Ambiguous
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition: Lookup.h:73
clang::Sema::DiagnoseUnexpandedParameterPacks
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
Definition: SemaTemplateVariadic.cpp:307
Sema.h
clang::TypeLocBuilder
Definition: TypeLocBuilder.h:22
clang::ParsedTemplateArgument::getScopeSpec
const CXXScopeSpec & getScopeSpec() const
Retrieve the nested-name-specifier that precedes the template name in a template template argument.
Definition: ParsedTemplate.h:97
clang::TemplateName::isNull
bool isNull() const
Determine whether this template name is NULL.
Definition: TemplateName.cpp:120
clang::DeclaratorChunk::ParamInfo::Param
Decl * Param
Definition: DeclSpec.h:1277
clang::Sema::DiagnoseUnexpandedParameterPackInRequiresExpr
bool DiagnoseUnexpandedParameterPackInRequiresExpr(RequiresExpr *RE)
If the given requirees-expression contains an unexpanded reference to one of its own parameter packs,...
Definition: SemaTemplateVariadic.cpp:428
clang::DeclarationNameInfo::getName
DeclarationName getName() const
getName - Returns the embedded declaration name.
Definition: DeclarationName.h:790
clang::ParsedTemplateArgument
Represents the parsed form of a C++ template argument.
Definition: ParsedTemplate.h:29
clang::UnresolvedUsingTypenameDecl::isPackExpansion
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:3906
clang::Sema::CorrectTypo
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...
Definition: SemaLookup.cpp:5325
clang::TST_decimal32
@ TST_decimal32
Definition: Specifiers.h:73
clang::OpaquePtr< QualType >
clang::TemplateTypeParmType
Definition: Type.h:5002
clang::DeclarationName::CXXConversionFunctionName
@ CXXConversionFunctionName
Definition: DeclarationName.h:214
clang::PackExpansionExpr::getNumExpansions
Optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
Definition: ExprCXX.h:4115
clang::Sema::containsUnexpandedParameterPacks
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
Definition: SemaTemplateVariadic.cpp:862
clang::sema::FunctionScopeInfo
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:102
clang::TemplateArgument::TemplateExpansion
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:90
clang::Sema::diagnoseTypo
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Definition: SemaLookup.cpp:5622
clang::Sema::LookupBinOp
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:15364
clang::ObjCDictionaryLiteral::getKeyValueElement
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:362
clang::RequiresExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprConcepts.h:536
clang::ParsedTemplateArgument::getKind
KindType getKind() const
Determine what kind of template argument we have.
Definition: ParsedTemplate.h:72
clang::TST_float
@ TST_float
Definition: Specifiers.h:68
clang::TST_typeofExpr
@ TST_typeofExpr
Definition: Specifiers.h:83
clang::tok::TokenKind
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:25
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::Sema::CTK_ErrorRecovery
@ CTK_ErrorRecovery
Definition: Sema.h:4485
clang::DeclaratorChunk::Paren
@ Paren
Definition: DeclSpec.h:1200
clang::TemplateArgument::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
Definition: TemplateBase.cpp:270
clang::Sema::getTemplateArgumentPackExpansionPattern
TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, Optional< unsigned > &NumExpansions) const
Returns the pattern of the pack expansion for a template argument.
Definition: SemaTemplateVariadic.cpp:1062
clang::TST_Accum
@ TST_Accum
Definition: Specifiers.h:65
clang::LocalInstantiationScope::getPartiallySubstitutedPack
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
Definition: SemaTemplateInstantiate.cpp:4116
clang::ParsedTemplateArgument::isInvalid
bool isInvalid() const
Determine whether the given template argument is invalid.
Definition: ParsedTemplate.h:69
clang::MultiLevelTemplateArgumentList::hasTemplateArgument
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:174
clang::Attr::isPackExpansion
bool isPackExpansion() const
Definition: Attr.h:97
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:268
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:201
clang::Expr::getExprLoc
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:329
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:802
clang::TST_decimal64
@ TST_decimal64
Definition: Specifiers.h:74
clang::Sema::CreateUnresolvedLookupExpr
ExprResult CreateUnresolvedLookupExpr(CXXRecordDecl *NamingClass, NestedNameSpecifierLoc NNSLoc, DeclarationNameInfo DNI, const UnresolvedSetImpl &Fns, bool PerformADL=true)
Definition: SemaOverload.cpp:13511
llvm::ArrayRef
Definition: LLVM.h:34
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::PackExpansionTypeLoc::setEllipsisLoc
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2529
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::DeclarationName::ObjCZeroArgSelector
@ ObjCZeroArgSelector
Definition: DeclarationName.h:210
clang::TemplateArgument::getNumTemplateExpansions
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
Definition: TemplateBase.cpp:274
clang::ParsedTemplateArgument::getAsExpr
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
Definition: ParsedTemplate.h:81
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
clang::TypeLoc::getType
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:132
clang::DeclarationName::ObjCOneArgSelector
@ ObjCOneArgSelector
Definition: DeclarationName.h:211
clang::PackExpansionTypeLoc::getPatternLoc
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2541
clang::TST_wchar
@ TST_wchar
Definition: Specifiers.h:56
clang::TemplateTypeParmTypeLoc
Wrapper for template type parameters.
Definition: TypeLoc.h:743
clang::LookupResult::getResultKind
LookupResultKind getResultKind() const
Definition: Lookup.h:321
clang::BinaryOperatorKind
BinaryOperatorKind
Definition: OperationKinds.h:25
clang::Sema::CurrentInstantiationScope
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:9690
clang::TST_typeof_unqualExpr
@ TST_typeof_unqualExpr
Definition: Specifiers.h:85
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::TST_decimal128
@ TST_decimal128
Definition: Specifiers.h:75
clang::DeclaratorChunk::MemberPointerTypeInfo::Scope
CXXScopeSpec & Scope()
Definition: DeclSpec.h:1553
clang::SubstNonTypeTemplateParmPackExpr::getParameterPackLocation
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
Definition: ExprCXX.h:4394
clang::Sema::ActOnPackExpansion
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
Definition: SemaTemplateVariadic.cpp:569
clang::ActionResult
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
Definition: Ownership.h:152
clang::TST_ibm128
@ TST_ibm128
Definition: Specifiers.h:71
clang::Sema::collectUnexpandedParameterPacks
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
Definition: SemaTemplateVariadic.cpp:531
clang::TST_class
@ TST_class
Definition: Specifiers.h:79
ScopeInfo.h
clang::SizeOfPackExpr::Create
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, Optional< unsigned > Length=None, ArrayRef< TemplateArgument > PartialArgs=None)
Definition: ExprCXX.cpp:1559
clang::TST_char32
@ TST_char32
Definition: Specifiers.h:59
clang::DeclarationName::getNameKind
NameKind getNameKind() const
Determine what kind of name this is.
Definition: DeclarationName.h:393
clang::Decl::isParameterPack
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:220
clang::TemplateArgument::Type
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
clang::TemplateTypeParmType::getDepth
unsigned getDepth() const
Definition: Type.h:5043
clang
Definition: CalledOnceCheck.h:17
clang::sema::FunctionScopeInfo::CompoundScopes
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound stamement scopes in the function.
Definition: ScopeInfo.h:219
clang::TemplateArgument::getPackExpansionPattern
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
Definition: TemplateBase.cpp:384
clang::sema::CompoundScopeInfo
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:67
RecursiveASTVisitor.h
clang::TemplateArgument::Template
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:86
clang::ParsedTemplateArgument::NonType
@ NonType
A non-type template parameter, stored as an expression.
Definition: ParsedTemplate.h:36
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:71
clang::TemplateArgument::getAsTemplate
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:292
clang::TST_bitint
@ TST_bitint
Definition: Specifiers.h:62
clang::Declarator
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1834
clang::CXXScalarValueInitExpr
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Definition: ExprCXX.h:2100
clang::TST_char16
@ TST_char16
Definition: Specifiers.h:58
clang::TypoCorrection::getCorrectionDecl
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
Definition: TypoCorrection.h:151
clang::DeclaratorChunk::Reference
@ Reference
Definition: DeclSpec.h:1200
clang::CXXScopeSpec::getScopeRep
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:78
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
clang::CorrectionCandidateCallback
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
Definition: TypoCorrection.h:281
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:40
clang::LookupResult::Found
@ Found
Name lookup found a single declaration that met the criteria.
Definition: Lookup.h:59
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6593
clang::BinaryOperator::getOverloadedOperator
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition: Expr.cpp:2169
clang::Declarator::getTypeObject
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Definition: DeclSpec.h:2303
clang::LookupResult::getLookupKind
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Definition: Lookup.h:253
unsigned
clang::Stmt::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:336
clang::DeclaratorChunk
One instance of this struct is used for each type in a declarator that is parsed.
Definition: DeclSpec.h:1196
clang::LookupResult::getFoundDecl
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Definition: Lookup.h:543
clang::TST_BFloat16
@ TST_BFloat16
Definition: Specifiers.h:67
clang::Sema::ActOnSizeofParameterPackExpr
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.
Definition: SemaTemplateVariadic.cpp:1011
clang::TypeLoc::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:152
clang::ASTContext::getTrivialTypeSourceInfo
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
Definition: ASTContext.cpp:3030
clang::Sema::isUnexpandedParameterPackPermitted
bool isUnexpandedParameterPackPermitted()
Determine whether an unexpanded parameter pack might be permitted in this location.
Definition: SemaTemplateVariadic.cpp:297
clang::TST_typeofType
@ TST_typeofType
Definition: Specifiers.h:82
clang::InheritingConcreteTypeLoc::getTypePtr
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:502
clang::TST_float128
@ TST_float128
Definition: Specifiers.h:70
clang::Sema::getNumArgumentsInExpansion
Optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
Definition: SemaTemplateVariadic.cpp:808
clang::TemplateName::getAsSubstTemplateTemplateParmPack
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
Definition: TemplateName.cpp:193
clang::TemplateArgument::pack_size
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:371
clang::Sema::LookupOrdinaryName
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:4247
clang::TypeLoc::castAs
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition: TypeLoc.h:77
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::DeclarationName::ObjCMultiArgSelector
@ ObjCMultiArgSelector
Definition: DeclarationName.h:225
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:712
clang::PackExpansionType::getNumExpansions
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5855
clang::TemplateArgumentLoc::getTemplateQualifierLoc
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:540
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::ParsedTemplateArgument::getLocation
SourceLocation getLocation() const
Retrieve the location of the template argument.
Definition: ParsedTemplate.h:93
clang::DeclarationName::getCXXNameType
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
Definition: DeclarationName.h:448
clang::TemplateArgumentLoc::getTemplateNameLoc
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:547
clang::TemplateTypeParmType::isParameterPack
bool isParameterPack() const
Definition: Type.h:5045
clang::TST_Fract
@ TST_Fract
Definition: Specifiers.h:66
clang::CXXScopeSpec::getRange
SourceRange getRange() const
Definition: DeclSpec.h:70
clang::ObjCDictionaryElement::Value
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:268
clang::CXXCtorInitializer
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2207
clang::CXXScopeSpec::getBeginLoc
SourceLocation getBeginLoc() const
Definition: DeclSpec.h:74
clang::DeclarationNameInfo::getLoc
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Definition: DeclarationName.h:796
clang::Sema::CheckPackExpansion
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
Definition: SemaTemplateVariadic.cpp:623
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:767
clang::TST_decltype_auto
@ TST_decltype_auto
Definition: Specifiers.h:90
clang::ParsedTemplateArgument::getAsType
ParsedType getAsType() const
Retrieve the template type argument's type.
Definition: ParsedTemplate.h:75
clang::TST_union
@ TST_union
Definition: Specifiers.h:77
clang::TST_double
@ TST_double
Definition: Specifiers.h:69
clang::DeclRefExpr
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1232
clang::LookupResult::FoundUnresolvedValue
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
Definition: Lookup.h:68
clang::LookupResult::getLookupNameInfo
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Definition: Lookup.h:233
clang::DeclSpec
Captures information about "declaration specifiers".
Definition: DeclSpec.h:230
clang::ParsedTemplateArgument::getAsTemplate
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
Definition: ParsedTemplate.h:87
clang::DeclSpec::getRepAsType
ParsedType getRepAsType() const
Definition: DeclSpec.h:505
TypeLoc.h
clang::LocalInstantiationScope::findInstantiationOf
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
Definition: SemaTemplateInstantiate.cpp:3998
clang::declaresSameEntity
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1240
clang::TemplateArgument::getAsType
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:268
clang::TypeSourceInfo::getTypeLoc
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:244
ParsedTemplate.h
clang::TemplateArgument::Pack
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:100
clang::DeclaratorChunk::Kind
enum clang::DeclaratorChunk::@212 Kind
clang::DeclaratorChunk::Pipe
@ Pipe
Definition: DeclSpec.h:1200
clang::Sema::CorrectDelayedTyposInExpr
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...
Definition: SemaExprCXX.cpp:8744