clang  14.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  /// Record occurrences of function and non-type template
92  /// parameter packs in an expression.
93  bool VisitDeclRefExpr(DeclRefExpr *E) {
94  if (E->getDecl()->isParameterPack())
95  addUnexpanded(E->getDecl(), E->getLocation());
96 
97  return true;
98  }
99 
100  /// Record occurrences of template template parameter packs.
101  bool TraverseTemplateName(TemplateName Template) {
102  if (auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>(
103  Template.getAsTemplateDecl())) {
104  if (TTP->isParameterPack())
105  addUnexpanded(TTP);
106  }
107 
108  return inherited::TraverseTemplateName(Template);
109  }
110 
111  /// Suppress traversal into Objective-C container literal
112  /// elements that are pack expansions.
113  bool TraverseObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
115  return true;
116 
117  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
119  if (Element.isPackExpansion())
120  continue;
121 
122  TraverseStmt(Element.Key);
123  TraverseStmt(Element.Value);
124  }
125  return true;
126  }
127  //------------------------------------------------------------------------
128  // Pruning the search for unexpanded parameter packs.
129  //------------------------------------------------------------------------
130 
131  /// Suppress traversal into statements and expressions that
132  /// do not contain unexpanded parameter packs.
133  bool TraverseStmt(Stmt *S) {
134  Expr *E = dyn_cast_or_null<Expr>(S);
135  if ((E && E->containsUnexpandedParameterPack()) || InLambda)
136  return inherited::TraverseStmt(S);
137 
138  return true;
139  }
140 
141  /// Suppress traversal into types that do not contain
142  /// unexpanded parameter packs.
143  bool TraverseType(QualType T) {
144  if ((!T.isNull() && T->containsUnexpandedParameterPack()) || InLambda)
145  return inherited::TraverseType(T);
146 
147  return true;
148  }
149 
150  /// Suppress traversal into types with location information
151  /// that do not contain unexpanded parameter packs.
152  bool TraverseTypeLoc(TypeLoc TL) {
153  if ((!TL.getType().isNull() &&
155  InLambda)
156  return inherited::TraverseTypeLoc(TL);
157 
158  return true;
159  }
160 
161  /// Suppress traversal of parameter packs.
162  bool TraverseDecl(Decl *D) {
163  // A function parameter pack is a pack expansion, so cannot contain
164  // an unexpanded parameter pack. Likewise for a template parameter
165  // pack that contains any references to other packs.
166  if (D && D->isParameterPack())
167  return true;
168 
169  return inherited::TraverseDecl(D);
170  }
171 
172  /// Suppress traversal of pack-expanded attributes.
173  bool TraverseAttr(Attr *A) {
174  if (A->isPackExpansion())
175  return true;
176 
177  return inherited::TraverseAttr(A);
178  }
179 
180  /// Suppress traversal of pack expansion expressions and types.
181  ///@{
182  bool TraversePackExpansionType(PackExpansionType *T) { return true; }
183  bool TraversePackExpansionTypeLoc(PackExpansionTypeLoc TL) { return true; }
184  bool TraversePackExpansionExpr(PackExpansionExpr *E) { return true; }
185  bool TraverseCXXFoldExpr(CXXFoldExpr *E) { return true; }
186 
187  ///@}
188 
189  /// Suppress traversal of using-declaration pack expansion.
190  bool TraverseUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
191  if (D->isPackExpansion())
192  return true;
193 
194  return inherited::TraverseUnresolvedUsingValueDecl(D);
195  }
196 
197  /// Suppress traversal of using-declaration pack expansion.
198  bool TraverseUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) {
199  if (D->isPackExpansion())
200  return true;
201 
202  return inherited::TraverseUnresolvedUsingTypenameDecl(D);
203  }
204 
205  /// Suppress traversal of template argument pack expansions.
206  bool TraverseTemplateArgument(const TemplateArgument &Arg) {
207  if (Arg.isPackExpansion())
208  return true;
209 
210  return inherited::TraverseTemplateArgument(Arg);
211  }
212 
213  /// Suppress traversal of template argument pack expansions.
214  bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) {
215  if (ArgLoc.getArgument().isPackExpansion())
216  return true;
217 
218  return inherited::TraverseTemplateArgumentLoc(ArgLoc);
219  }
220 
221  /// Suppress traversal of base specifier pack expansions.
222  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base) {
223  if (Base.isPackExpansion())
224  return true;
225 
226  return inherited::TraverseCXXBaseSpecifier(Base);
227  }
228 
229  /// Suppress traversal of mem-initializer pack expansions.
230  bool TraverseConstructorInitializer(CXXCtorInitializer *Init) {
231  if (Init->isPackExpansion())
232  return true;
233 
234  return inherited::TraverseConstructorInitializer(Init);
235  }
236 
237  /// Note whether we're traversing a lambda containing an unexpanded
238  /// parameter pack. In this case, the unexpanded pack can occur anywhere,
239  /// including all the places where we normally wouldn't look. Within a
240  /// lambda, we don't propagate the 'contains unexpanded parameter pack' bit
241  /// outside an expression.
242  bool TraverseLambdaExpr(LambdaExpr *Lambda) {
243  // The ContainsUnexpandedParameterPack bit on a lambda is always correct,
244  // even if it's contained within another lambda.
245  if (!Lambda->containsUnexpandedParameterPack())
246  return true;
247 
248  bool WasInLambda = InLambda;
249  unsigned OldDepthLimit = DepthLimit;
250 
251  InLambda = true;
252  if (auto *TPL = Lambda->getTemplateParameterList())
253  DepthLimit = TPL->getDepth();
254 
255  inherited::TraverseLambdaExpr(Lambda);
256 
257  InLambda = WasInLambda;
258  DepthLimit = OldDepthLimit;
259  return true;
260  }
261 
262  /// Suppress traversal within pack expansions in lambda captures.
263  bool TraverseLambdaCapture(LambdaExpr *Lambda, const LambdaCapture *C,
264  Expr *Init) {
265  if (C->isPackExpansion())
266  return true;
267 
268  return inherited::TraverseLambdaCapture(Lambda, C, Init);
269  }
270  };
271 }
272 
273 /// Determine whether it's possible for an unexpanded parameter pack to
274 /// be valid in this location. This only happens when we're in a declaration
275 /// that is nested within an expression that could be expanded, such as a
276 /// lambda-expression within a function call.
277 ///
278 /// This is conservatively correct, but may claim that some unexpanded packs are
279 /// permitted when they are not.
281  for (auto *SI : FunctionScopes)
282  if (isa<sema::LambdaScopeInfo>(SI))
283  return true;
284  return false;
285 }
286 
287 /// Diagnose all of the unexpanded parameter packs in the given
288 /// vector.
289 bool
293  if (Unexpanded.empty())
294  return false;
295 
296  // If we are within a lambda expression and referencing a pack that is not
297  // declared within the lambda itself, that lambda contains an unexpanded
298  // parameter pack, and we are done.
299  // FIXME: Store 'Unexpanded' on the lambda so we don't need to recompute it
300  // later.
301  SmallVector<UnexpandedParameterPack, 4> LambdaParamPackReferences;
302  if (auto *LSI = getEnclosingLambda()) {
303  for (auto &Pack : Unexpanded) {
304  auto DeclaresThisPack = [&](NamedDecl *LocalPack) {
305  if (auto *TTPT = Pack.first.dyn_cast<const TemplateTypeParmType *>()) {
306  auto *TTPD = dyn_cast<TemplateTypeParmDecl>(LocalPack);
307  return TTPD && TTPD->getTypeForDecl() == TTPT;
308  }
309  return declaresSameEntity(Pack.first.get<NamedDecl *>(), LocalPack);
310  };
311  if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
312  LambdaParamPackReferences.push_back(Pack);
313  }
314 
315  if (LambdaParamPackReferences.empty()) {
316  // Construct in lambda only references packs declared outside the lambda.
317  // That's OK for now, but the lambda itself is considered to contain an
318  // unexpanded pack in this case, which will require expansion outside the
319  // lambda.
320 
321  // We do not permit pack expansion that would duplicate a statement
322  // expression, not even within a lambda.
323  // FIXME: We could probably support this for statement expressions that
324  // do not contain labels.
325  // FIXME: This is insufficient to detect this problem; consider
326  // f( ({ bad: 0; }) + pack ... );
327  bool EnclosingStmtExpr = false;
328  for (unsigned N = FunctionScopes.size(); N; --N) {
330  if (llvm::any_of(
331  Func->CompoundScopes,
332  [](sema::CompoundScopeInfo &CSI) { return CSI.IsStmtExpr; })) {
333  EnclosingStmtExpr = true;
334  break;
335  }
336  // Coumpound-statements outside the lambda are OK for now; we'll check
337  // for those when we finish handling the lambda.
338  if (Func == LSI)
339  break;
340  }
341 
342  if (!EnclosingStmtExpr) {
343  LSI->ContainsUnexpandedParameterPack = true;
344  return false;
345  }
346  } else {
347  Unexpanded = LambdaParamPackReferences;
348  }
349  }
350 
354 
355  for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
356  IdentifierInfo *Name = nullptr;
357  if (const TemplateTypeParmType *TTP
358  = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>())
359  Name = TTP->getIdentifier();
360  else
361  Name = Unexpanded[I].first.get<NamedDecl *>()->getIdentifier();
362 
363  if (Name && NamesKnown.insert(Name).second)
364  Names.push_back(Name);
365 
366  if (Unexpanded[I].second.isValid())
367  Locations.push_back(Unexpanded[I].second);
368  }
369 
370  auto DB = Diag(Loc, diag::err_unexpanded_parameter_pack)
371  << (int)UPPC << (int)Names.size();
372  for (size_t I = 0, E = std::min(Names.size(), (size_t)2); I != E; ++I)
373  DB << Names[I];
374 
375  for (unsigned I = 0, N = Locations.size(); I != N; ++I)
376  DB << SourceRange(Locations[I]);
377  return true;
378 }
379 
381  TypeSourceInfo *T,
383  // C++0x [temp.variadic]p5:
384  // An appearance of a name of a parameter pack that is not expanded is
385  // ill-formed.
387  return false;
388 
390  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(
391  T->getTypeLoc());
392  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
393  return DiagnoseUnexpandedParameterPacks(Loc, UPPC, Unexpanded);
394 }
395 
398  // C++0x [temp.variadic]p5:
399  // An appearance of a name of a parameter pack that is not expanded is
400  // ill-formed.
402  return false;
403 
405  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(E);
406  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
407  return DiagnoseUnexpandedParameterPacks(E->getBeginLoc(), UPPC, Unexpanded);
408 }
409 
412  return false;
413 
415  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(RE);
416  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
417 
418  // We only care about unexpanded references to the RequiresExpr's own
419  // parameter packs.
420  auto Parms = RE->getLocalParameters();
421  llvm::SmallPtrSet<NamedDecl*, 8> ParmSet(Parms.begin(), Parms.end());
423  for (auto Parm : Unexpanded)
424  if (ParmSet.contains(Parm.first.dyn_cast<NamedDecl*>()))
425  UnexpandedParms.push_back(Parm);
426  if (UnexpandedParms.empty())
427  return false;
428 
430  UnexpandedParms);
431 }
432 
435  // C++0x [temp.variadic]p5:
436  // An appearance of a name of a parameter pack that is not expanded is
437  // ill-formed.
438  if (!SS.getScopeRep() ||
440  return false;
441 
443  CollectUnexpandedParameterPacksVisitor(Unexpanded)
444  .TraverseNestedNameSpecifier(SS.getScopeRep());
445  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
447  UPPC, Unexpanded);
448 }
449 
452  // C++0x [temp.variadic]p5:
453  // An appearance of a name of a parameter pack that is not expanded is
454  // ill-formed.
455  switch (NameInfo.getName().getNameKind()) {
464  return false;
465 
469  // FIXME: We shouldn't need this null check!
470  if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
471  return DiagnoseUnexpandedParameterPack(NameInfo.getLoc(), TSInfo, UPPC);
472 
474  return false;
475 
476  break;
477  }
478 
480  CollectUnexpandedParameterPacksVisitor(Unexpanded)
481  .TraverseType(NameInfo.getName().getCXXNameType());
482  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
483  return DiagnoseUnexpandedParameterPacks(NameInfo.getLoc(), UPPC, Unexpanded);
484 }
485 
487  TemplateName Template,
489 
490  if (Template.isNull() || !Template.containsUnexpandedParameterPack())
491  return false;
492 
494  CollectUnexpandedParameterPacksVisitor(Unexpanded)
495  .TraverseTemplateName(Template);
496  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
497  return DiagnoseUnexpandedParameterPacks(Loc, UPPC, Unexpanded);
498 }
499 
502  if (Arg.getArgument().isNull() ||
504  return false;
505 
507  CollectUnexpandedParameterPacksVisitor(Unexpanded)
508  .TraverseTemplateArgumentLoc(Arg);
509  assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
510  return DiagnoseUnexpandedParameterPacks(Arg.getLocation(), UPPC, Unexpanded);
511 }
512 
515  CollectUnexpandedParameterPacksVisitor(Unexpanded)
516  .TraverseTemplateArgument(Arg);
517 }
518 
521  CollectUnexpandedParameterPacksVisitor(Unexpanded)
522  .TraverseTemplateArgumentLoc(Arg);
523 }
524 
527  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
528 }
529 
532  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
533 }
534 
538  CollectUnexpandedParameterPacksVisitor(Unexpanded)
539  .TraverseNestedNameSpecifierLoc(NNS);
540 }
541 
543  const DeclarationNameInfo &NameInfo,
545  CollectUnexpandedParameterPacksVisitor(Unexpanded)
546  .TraverseDeclarationNameInfo(NameInfo);
547 }
548 
549 
552  SourceLocation EllipsisLoc) {
553  if (Arg.isInvalid())
554  return Arg;
555 
556  switch (Arg.getKind()) {
558  TypeResult Result = ActOnPackExpansion(Arg.getAsType(), EllipsisLoc);
559  if (Result.isInvalid())
560  return ParsedTemplateArgument();
561 
562  return ParsedTemplateArgument(Arg.getKind(), Result.get().getAsOpaquePtr(),
563  Arg.getLocation());
564  }
565 
567  ExprResult Result = ActOnPackExpansion(Arg.getAsExpr(), EllipsisLoc);
568  if (Result.isInvalid())
569  return ParsedTemplateArgument();
570 
571  return ParsedTemplateArgument(Arg.getKind(), Result.get(),
572  Arg.getLocation());
573  }
574 
577  SourceRange R(Arg.getLocation());
578  if (Arg.getScopeSpec().isValid())
579  R.setBegin(Arg.getScopeSpec().getBeginLoc());
580  Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
581  << R;
582  return ParsedTemplateArgument();
583  }
584 
585  return Arg.getTemplatePackExpansion(EllipsisLoc);
586  }
587  llvm_unreachable("Unhandled template argument kind?");
588 }
589 
591  SourceLocation EllipsisLoc) {
592  TypeSourceInfo *TSInfo;
593  GetTypeFromParser(Type, &TSInfo);
594  if (!TSInfo)
595  return true;
596 
597  TypeSourceInfo *TSResult = CheckPackExpansion(TSInfo, EllipsisLoc, None);
598  if (!TSResult)
599  return true;
600 
601  return CreateParsedType(TSResult->getType(), TSResult);
602 }
603 
606  Optional<unsigned> NumExpansions) {
607  // Create the pack expansion type and source-location information.
608  QualType Result = CheckPackExpansion(Pattern->getType(),
609  Pattern->getTypeLoc().getSourceRange(),
610  EllipsisLoc, NumExpansions);
611  if (Result.isNull())
612  return nullptr;
613 
614  TypeLocBuilder TLB;
615  TLB.pushFullCopy(Pattern->getTypeLoc());
617  TL.setEllipsisLoc(EllipsisLoc);
618 
619  return TLB.getTypeSourceInfo(Context, Result);
620 }
621 
623  SourceLocation EllipsisLoc,
624  Optional<unsigned> NumExpansions) {
625  // C++11 [temp.variadic]p5:
626  // The pattern of a pack expansion shall name one or more
627  // parameter packs that are not expanded by a nested pack
628  // expansion.
629  //
630  // A pattern containing a deduced type can't occur "naturally" but arises in
631  // the desugaring of an init-capture pack.
632  if (!Pattern->containsUnexpandedParameterPack() &&
633  !Pattern->getContainedDeducedType()) {
634  Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
635  << PatternRange;
636  return QualType();
637  }
638 
639  return Context.getPackExpansionType(Pattern, NumExpansions,
640  /*ExpectPackInType=*/false);
641 }
642 
644  return CheckPackExpansion(Pattern, EllipsisLoc, None);
645 }
646 
648  Optional<unsigned> NumExpansions) {
649  if (!Pattern)
650  return ExprError();
651 
652  // C++0x [temp.variadic]p5:
653  // The pattern of a pack expansion shall name one or more
654  // parameter packs that are not expanded by a nested pack
655  // expansion.
656  if (!Pattern->containsUnexpandedParameterPack()) {
657  Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
658  << Pattern->getSourceRange();
659  CorrectDelayedTyposInExpr(Pattern);
660  return ExprError();
661  }
662 
663  // Create the pack expansion expression and source-location information.
664  return new (Context)
665  PackExpansionExpr(Context.DependentTy, Pattern, EllipsisLoc, NumExpansions);
666 }
667 
669  SourceLocation EllipsisLoc, SourceRange PatternRange,
671  const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
672  bool &RetainExpansion, Optional<unsigned> &NumExpansions) {
673  ShouldExpand = true;
674  RetainExpansion = false;
675  std::pair<IdentifierInfo *, SourceLocation> FirstPack;
676  bool HaveFirstPack = false;
677  Optional<unsigned> NumPartialExpansions;
678  SourceLocation PartiallySubstitutedPackLoc;
679 
680  for (ArrayRef<UnexpandedParameterPack>::iterator i = Unexpanded.begin(),
681  end = Unexpanded.end();
682  i != end; ++i) {
683  // Compute the depth and index for this parameter pack.
684  unsigned Depth = 0, Index = 0;
685  IdentifierInfo *Name;
686  bool IsVarDeclPack = false;
687 
688  if (const TemplateTypeParmType *TTP
689  = i->first.dyn_cast<const TemplateTypeParmType *>()) {
690  Depth = TTP->getDepth();
691  Index = TTP->getIndex();
692  Name = TTP->getIdentifier();
693  } else {
694  NamedDecl *ND = i->first.get<NamedDecl *>();
695  if (isa<VarDecl>(ND))
696  IsVarDeclPack = true;
697  else
698  std::tie(Depth, Index) = getDepthAndIndex(ND);
699 
700  Name = ND->getIdentifier();
701  }
702 
703  // Determine the size of this argument pack.
704  unsigned NewPackSize;
705  if (IsVarDeclPack) {
706  // Figure out whether we're instantiating to an argument pack or not.
707  typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
708 
709  llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation
711  i->first.get<NamedDecl *>());
712  if (Instantiation->is<DeclArgumentPack *>()) {
713  // We could expand this function parameter pack.
714  NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
715  } else {
716  // We can't expand this function parameter pack, so we can't expand
717  // the pack expansion.
718  ShouldExpand = false;
719  continue;
720  }
721  } else {
722  // If we don't have a template argument at this depth/index, then we
723  // cannot expand the pack expansion. Make a note of this, but we still
724  // want to check any parameter packs we *do* have arguments for.
725  if (Depth >= TemplateArgs.getNumLevels() ||
726  !TemplateArgs.hasTemplateArgument(Depth, Index)) {
727  ShouldExpand = false;
728  continue;
729  }
730 
731  // Determine the size of the argument pack.
732  NewPackSize = TemplateArgs(Depth, Index).pack_size();
733  }
734 
735  // C++0x [temp.arg.explicit]p9:
736  // Template argument deduction can extend the sequence of template
737  // arguments corresponding to a template parameter pack, even when the
738  // sequence contains explicitly specified template arguments.
739  if (!IsVarDeclPack && CurrentInstantiationScope) {
740  if (NamedDecl *PartialPack
742  unsigned PartialDepth, PartialIndex;
743  std::tie(PartialDepth, PartialIndex) = getDepthAndIndex(PartialPack);
744  if (PartialDepth == Depth && PartialIndex == Index) {
745  RetainExpansion = true;
746  // We don't actually know the new pack size yet.
747  NumPartialExpansions = NewPackSize;
748  PartiallySubstitutedPackLoc = i->second;
749  continue;
750  }
751  }
752  }
753 
754  if (!NumExpansions) {
755  // The is the first pack we've seen for which we have an argument.
756  // Record it.
757  NumExpansions = NewPackSize;
758  FirstPack.first = Name;
759  FirstPack.second = i->second;
760  HaveFirstPack = true;
761  continue;
762  }
763 
764  if (NewPackSize != *NumExpansions) {
765  // C++0x [temp.variadic]p5:
766  // All of the parameter packs expanded by a pack expansion shall have
767  // the same number of arguments specified.
768  if (HaveFirstPack)
769  Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
770  << FirstPack.first << Name << *NumExpansions << NewPackSize
771  << SourceRange(FirstPack.second) << SourceRange(i->second);
772  else
773  Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_multilevel)
774  << Name << *NumExpansions << NewPackSize
775  << SourceRange(i->second);
776  return true;
777  }
778  }
779 
780  // If we're performing a partial expansion but we also have a full expansion,
781  // expand to the number of common arguments. For example, given:
782  //
783  // template<typename ...T> struct A {
784  // template<typename ...U> void f(pair<T, U>...);
785  // };
786  //
787  // ... a call to 'A<int, int>().f<int>' should expand the pack once and
788  // retain an expansion.
789  if (NumPartialExpansions) {
790  if (NumExpansions && *NumExpansions < *NumPartialExpansions) {
791  NamedDecl *PartialPack =
793  Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict_partial)
794  << PartialPack << *NumPartialExpansions << *NumExpansions
795  << SourceRange(PartiallySubstitutedPackLoc);
796  return true;
797  }
798 
799  NumExpansions = NumPartialExpansions;
800  }
801 
802  return false;
803 }
804 
806  const MultiLevelTemplateArgumentList &TemplateArgs) {
807  QualType Pattern = cast<PackExpansionType>(T)->getPattern();
809  CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(Pattern);
810 
811  Optional<unsigned> Result;
812  for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
813  // Compute the depth and index for this parameter pack.
814  unsigned Depth;
815  unsigned Index;
816 
817  if (const TemplateTypeParmType *TTP
818  = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) {
819  Depth = TTP->getDepth();
820  Index = TTP->getIndex();
821  } else {
822  NamedDecl *ND = Unexpanded[I].first.get<NamedDecl *>();
823  if (isa<VarDecl>(ND)) {
824  // Function parameter pack or init-capture pack.
825  typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
826 
827  llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation
829  Unexpanded[I].first.get<NamedDecl *>());
830  if (Instantiation->is<Decl*>())
831  // The pattern refers to an unexpanded pack. We're not ready to expand
832  // this pack yet.
833  return None;
834 
835  unsigned Size = Instantiation->get<DeclArgumentPack *>()->size();
836  assert((!Result || *Result == Size) && "inconsistent pack sizes");
837  Result = Size;
838  continue;
839  }
840 
841  std::tie(Depth, Index) = getDepthAndIndex(ND);
842  }
843  if (Depth >= TemplateArgs.getNumLevels() ||
844  !TemplateArgs.hasTemplateArgument(Depth, Index))
845  // The pattern refers to an unknown template argument. We're not ready to
846  // expand this pack yet.
847  return None;
848 
849  // Determine the size of the argument pack.
850  unsigned Size = TemplateArgs(Depth, Index).pack_size();
851  assert((!Result || *Result == Size) && "inconsistent pack sizes");
852  Result = Size;
853  }
854 
855  return Result;
856 }
857 
859  const DeclSpec &DS = D.getDeclSpec();
860  switch (DS.getTypeSpecType()) {
861  case TST_typename:
862  case TST_typeofType:
863  case TST_underlyingType:
864  case TST_atomic: {
865  QualType T = DS.getRepAsType().get();
866  if (!T.isNull() && T->containsUnexpandedParameterPack())
867  return true;
868  break;
869  }
870 
871  case TST_typeofExpr:
872  case TST_decltype:
873  case TST_extint:
874  if (DS.getRepAsExpr() &&
876  return true;
877  break;
878 
879  case TST_unspecified:
880  case TST_void:
881  case TST_char:
882  case TST_wchar:
883  case TST_char8:
884  case TST_char16:
885  case TST_char32:
886  case TST_int:
887  case TST_int128:
888  case TST_half:
889  case TST_float:
890  case TST_double:
891  case TST_Accum:
892  case TST_Fract:
893  case TST_Float16:
894  case TST_float128:
895  case TST_ibm128:
896  case TST_bool:
897  case TST_decimal32:
898  case TST_decimal64:
899  case TST_decimal128:
900  case TST_enum:
901  case TST_union:
902  case TST_struct:
903  case TST_interface:
904  case TST_class:
905  case TST_auto:
906  case TST_auto_type:
907  case TST_decltype_auto:
908  case TST_BFloat16:
909 #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
910 #include "clang/Basic/OpenCLImageTypes.def"
911  case TST_unknown_anytype:
912  case TST_error:
913  break;
914  }
915 
916  for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) {
917  const DeclaratorChunk &Chunk = D.getTypeObject(I);
918  switch (Chunk.Kind) {
924  // These declarator chunks cannot contain any parameter packs.
925  break;
926 
928  if (Chunk.Arr.NumElts &&
930  return true;
931  break;
933  for (unsigned i = 0, e = Chunk.Fun.NumParams; i != e; ++i) {
934  ParmVarDecl *Param = cast<ParmVarDecl>(Chunk.Fun.Params[i].Param);
935  QualType ParamTy = Param->getType();
936  assert(!ParamTy.isNull() && "Couldn't parse type?");
937  if (ParamTy->containsUnexpandedParameterPack()) return true;
938  }
939 
940  if (Chunk.Fun.getExceptionSpecType() == EST_Dynamic) {
941  for (unsigned i = 0; i != Chunk.Fun.getNumExceptions(); ++i) {
942  if (Chunk.Fun.Exceptions[i]
943  .Ty.get()
945  return true;
946  }
947  } else if (isComputedNoexcept(Chunk.Fun.getExceptionSpecType()) &&
949  return true;
950 
951  if (Chunk.Fun.hasTrailingReturnType()) {
952  QualType T = Chunk.Fun.getTrailingReturnType().get();
953  if (!T.isNull() && T->containsUnexpandedParameterPack())
954  return true;
955  }
956  break;
957 
959  if (Chunk.Mem.Scope().getScopeRep() &&
961  return true;
962  break;
963  }
964  }
965 
966  if (Expr *TRC = D.getTrailingRequiresClause())
967  if (TRC->containsUnexpandedParameterPack())
968  return true;
969 
970  return false;
971 }
972 
973 namespace {
974 
975 // Callback to only accept typo corrections that refer to parameter packs.
976 class ParameterPackValidatorCCC final : public CorrectionCandidateCallback {
977  public:
978  bool ValidateCandidate(const TypoCorrection &candidate) override {
979  NamedDecl *ND = candidate.getCorrectionDecl();
980  return ND && ND->isParameterPack();
981  }
982 
983  std::unique_ptr<CorrectionCandidateCallback> clone() override {
984  return std::make_unique<ParameterPackValidatorCCC>(*this);
985  }
986 };
987 
988 }
989 
990 /// Called when an expression computing the size of a parameter pack
991 /// is parsed.
992 ///
993 /// \code
994 /// template<typename ...Types> struct count {
995 /// static const unsigned value = sizeof...(Types);
996 /// };
997 /// \endcode
998 ///
999 //
1000 /// \param OpLoc The location of the "sizeof" keyword.
1001 /// \param Name The name of the parameter pack whose size will be determined.
1002 /// \param NameLoc The source location of the name of the parameter pack.
1003 /// \param RParenLoc The location of the closing parentheses.
1005  SourceLocation OpLoc,
1006  IdentifierInfo &Name,
1007  SourceLocation NameLoc,
1008  SourceLocation RParenLoc) {
1009  // C++0x [expr.sizeof]p5:
1010  // The identifier in a sizeof... expression shall name a parameter pack.
1011  LookupResult R(*this, &Name, NameLoc, LookupOrdinaryName);
1012  LookupName(R, S);
1013 
1014  NamedDecl *ParameterPack = nullptr;
1015  switch (R.getResultKind()) {
1016  case LookupResult::Found:
1017  ParameterPack = R.getFoundDecl();
1018  break;
1019 
1022  ParameterPackValidatorCCC CCC{};
1023  if (TypoCorrection Corrected =
1024  CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, nullptr,
1025  CCC, CTK_ErrorRecovery)) {
1026  diagnoseTypo(Corrected,
1027  PDiag(diag::err_sizeof_pack_no_pack_name_suggest) << &Name,
1028  PDiag(diag::note_parameter_pack_here));
1029  ParameterPack = Corrected.getCorrectionDecl();
1030  }
1031  break;
1032  }
1035  break;
1036 
1039  return ExprError();
1040  }
1041 
1042  if (!ParameterPack || !ParameterPack->isParameterPack()) {
1043  Diag(NameLoc, diag::err_sizeof_pack_no_pack_name)
1044  << &Name;
1045  return ExprError();
1046  }
1047 
1048  MarkAnyDeclReferenced(OpLoc, ParameterPack, true);
1049 
1050  return SizeOfPackExpr::Create(Context, OpLoc, ParameterPack, NameLoc,
1051  RParenLoc);
1052 }
1053 
1056  TemplateArgumentLoc OrigLoc,
1057  SourceLocation &Ellipsis, Optional<unsigned> &NumExpansions) const {
1058  const TemplateArgument &Argument = OrigLoc.getArgument();
1059  assert(Argument.isPackExpansion());
1060  switch (Argument.getKind()) {
1061  case TemplateArgument::Type: {
1062  // FIXME: We shouldn't ever have to worry about missing
1063  // type-source info!
1064  TypeSourceInfo *ExpansionTSInfo = OrigLoc.getTypeSourceInfo();
1065  if (!ExpansionTSInfo)
1066  ExpansionTSInfo = Context.getTrivialTypeSourceInfo(Argument.getAsType(),
1067  Ellipsis);
1068  PackExpansionTypeLoc Expansion =
1069  ExpansionTSInfo->getTypeLoc().castAs<PackExpansionTypeLoc>();
1070  Ellipsis = Expansion.getEllipsisLoc();
1071 
1072  TypeLoc Pattern = Expansion.getPatternLoc();
1073  NumExpansions = Expansion.getTypePtr()->getNumExpansions();
1074 
1075  // We need to copy the TypeLoc because TemplateArgumentLocs store a
1076  // TypeSourceInfo.
1077  // FIXME: Find some way to avoid the copy?
1078  TypeLocBuilder TLB;
1079  TLB.pushFullCopy(Pattern);
1080  TypeSourceInfo *PatternTSInfo =
1081  TLB.getTypeSourceInfo(Context, Pattern.getType());
1082  return TemplateArgumentLoc(TemplateArgument(Pattern.getType()),
1083  PatternTSInfo);
1084  }
1085 
1087  PackExpansionExpr *Expansion
1088  = cast<PackExpansionExpr>(Argument.getAsExpr());
1089  Expr *Pattern = Expansion->getPattern();
1090  Ellipsis = Expansion->getEllipsisLoc();
1091  NumExpansions = Expansion->getNumExpansions();
1092  return TemplateArgumentLoc(Pattern, Pattern);
1093  }
1094 
1096  Ellipsis = OrigLoc.getTemplateEllipsisLoc();
1097  NumExpansions = Argument.getNumTemplateExpansions();
1099  OrigLoc.getTemplateQualifierLoc(),
1100  OrigLoc.getTemplateNameLoc());
1101 
1108  return TemplateArgumentLoc();
1109  }
1110 
1111  llvm_unreachable("Invalid TemplateArgument Kind!");
1112 }
1113 
1115  assert(Arg.containsUnexpandedParameterPack());
1116 
1117  // If this is a substituted pack, grab that pack. If not, we don't know
1118  // the size yet.
1119  // FIXME: We could find a size in more cases by looking for a substituted
1120  // pack anywhere within this argument, but that's not necessary in the common
1121  // case for 'sizeof...(A)' handling.
1122  TemplateArgument Pack;
1123  switch (Arg.getKind()) {
1125  if (auto *Subst = Arg.getAsType()->getAs<SubstTemplateTypeParmPackType>())
1126  Pack = Subst->getArgumentPack();
1127  else
1128  return None;
1129  break;
1130 
1132  if (auto *Subst =
1133  dyn_cast<SubstNonTypeTemplateParmPackExpr>(Arg.getAsExpr()))
1134  Pack = Subst->getArgumentPack();
1135  else if (auto *Subst = dyn_cast<FunctionParmPackExpr>(Arg.getAsExpr())) {
1136  for (VarDecl *PD : *Subst)
1137  if (PD->isParameterPack())
1138  return None;
1139  return Subst->getNumExpansions();
1140  } else
1141  return None;
1142  break;
1143 
1147  Pack = Subst->getArgumentPack();
1148  else
1149  return None;
1150  break;
1151 
1158  return None;
1159  }
1160 
1161  // Check that no argument in the pack is itself a pack expansion.
1162  for (TemplateArgument Elem : Pack.pack_elements()) {
1163  // There's no point recursing in this case; we would have already
1164  // expanded this pack expansion into the enclosing pack if we could.
1165  if (Elem.isPackExpansion())
1166  return None;
1167  }
1168  return Pack.pack_size();
1169 }
1170 
1171 static void CheckFoldOperand(Sema &S, Expr *E) {
1172  if (!E)
1173  return;
1174 
1175  E = E->IgnoreImpCasts();
1176  auto *OCE = dyn_cast<CXXOperatorCallExpr>(E);
1177  if ((OCE && OCE->isInfixBinaryOp()) || isa<BinaryOperator>(E) ||
1178  isa<AbstractConditionalOperator>(E)) {
1179  S.Diag(E->getExprLoc(), diag::err_fold_expression_bad_operand)
1180  << E->getSourceRange()
1182  << FixItHint::CreateInsertion(E->getEndLoc(), ")");
1183  }
1184 }
1185 
1187  tok::TokenKind Operator,
1188  SourceLocation EllipsisLoc, Expr *RHS,
1189  SourceLocation RParenLoc) {
1190  // LHS and RHS must be cast-expressions. We allow an arbitrary expression
1191  // in the parser and reduce down to just cast-expressions here.
1192  CheckFoldOperand(*this, LHS);
1193  CheckFoldOperand(*this, RHS);
1194 
1195  auto DiscardOperands = [&] {
1198  };
1199 
1200  // [expr.prim.fold]p3:
1201  // In a binary fold, op1 and op2 shall be the same fold-operator, and
1202  // either e1 shall contain an unexpanded parameter pack or e2 shall contain
1203  // an unexpanded parameter pack, but not both.
1204  if (LHS && RHS &&
1207  DiscardOperands();
1208  return Diag(EllipsisLoc,
1210  ? diag::err_fold_expression_packs_both_sides
1211  : diag::err_pack_expansion_without_parameter_packs)
1212  << LHS->getSourceRange() << RHS->getSourceRange();
1213  }
1214 
1215  // [expr.prim.fold]p2:
1216  // In a unary fold, the cast-expression shall contain an unexpanded
1217  // parameter pack.
1218  if (!LHS || !RHS) {
1219  Expr *Pack = LHS ? LHS : RHS;
1220  assert(Pack && "fold expression with neither LHS nor RHS");
1221  DiscardOperands();
1222  if (!Pack->containsUnexpandedParameterPack())
1223  return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1224  << Pack->getSourceRange();
1225  }
1226 
1227  BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
1228 
1229  // Perform first-phase name lookup now.
1230  UnresolvedLookupExpr *ULE = nullptr;
1231  {
1232  UnresolvedSet<16> Functions;
1233  LookupBinOp(S, EllipsisLoc, Opc, Functions);
1234  if (!Functions.empty()) {
1238  /*NamingClass*/ nullptr, NestedNameSpecifierLoc(),
1239  DeclarationNameInfo(OpName, EllipsisLoc), Functions);
1240  if (Callee.isInvalid())
1241  return ExprError();
1242  ULE = cast<UnresolvedLookupExpr>(Callee.get());
1243  }
1244  }
1245 
1246  return BuildCXXFoldExpr(ULE, LParenLoc, LHS, Opc, EllipsisLoc, RHS, RParenLoc,
1247  None);
1248 }
1249 
1251  SourceLocation LParenLoc, Expr *LHS,
1252  BinaryOperatorKind Operator,
1253  SourceLocation EllipsisLoc, Expr *RHS,
1254  SourceLocation RParenLoc,
1255  Optional<unsigned> NumExpansions) {
1256  return new (Context)
1257  CXXFoldExpr(Context.DependentTy, Callee, LParenLoc, LHS, Operator,
1258  EllipsisLoc, RHS, RParenLoc, NumExpansions);
1259 }
1260 
1262  BinaryOperatorKind Operator) {
1263  // [temp.variadic]p9:
1264  // If N is zero for a unary fold-expression, the value of the expression is
1265  // && -> true
1266  // || -> false
1267  // , -> void()
1268  // if the operator is not listed [above], the instantiation is ill-formed.
1269  //
1270  // Note that we need to use something like int() here, not merely 0, to
1271  // prevent the result from being a null pointer constant.
1272  QualType ScalarType;
1273  switch (Operator) {
1274  case BO_LOr:
1275  return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_false);
1276  case BO_LAnd:
1277  return ActOnCXXBoolLiteral(EllipsisLoc, tok::kw_true);
1278  case BO_Comma:
1279  ScalarType = Context.VoidTy;
1280  break;
1281 
1282  default:
1283  return Diag(EllipsisLoc, diag::err_fold_expression_empty)
1284  << BinaryOperator::getOpcodeStr(Operator);
1285  }
1286 
1287  return new (Context) CXXScalarValueInitExpr(
1288  ScalarType, Context.getTrivialTypeSourceInfo(ScalarType, EllipsisLoc),
1289  EllipsisLoc);
1290 }
clang::DeclaratorChunk::MemberPointer
@ MemberPointer
Definition: DeclSpec.h:1178
clang::SourceRange::setBegin
void setBegin(SourceLocation b)
Definition: SourceLocation.h:224
clang::TST_half
@ TST_half
Definition: Specifiers.h:63
clang::PackExpansionExpr::getPattern
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4080
clang::DeclaratorChunk::FunctionTypeInfo::NumParams
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1316
clang::DeclaratorChunk::Array
@ Array
Definition: DeclSpec.h:1178
clang::OpaquePtr::get
PtrTy get() const
Definition: Ownership.h:80
CheckFoldOperand
static void CheckFoldOperand(Sema &S, Expr *E)
Definition: SemaTemplateVariadic.cpp:1171
clang::LookupResult::NotFound
@ NotFound
No entity found met the criteria.
Definition: Lookup.h:50
clang::TST_Float16
@ TST_Float16
Definition: Specifiers.h:64
clang::DeclaratorChunk::Reference
@ Reference
Definition: DeclSpec.h:1178
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:1499
clang::PackExpansionExpr::getEllipsisLoc
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4087
clang::DeclRefExpr::getLocation
SourceLocation getLocation() const
Definition: Expr.h:1297
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6406
clang::ObjCDictionaryElement
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:263
clang::DeclarationName::Identifier
@ Identifier
Definition: DeclarationName.h:203
clang::TST_underlyingType
@ TST_underlyingType
Definition: Specifiers.h:85
clang::DeclarationName::CXXLiteralOperatorName
@ CXXLiteralOperatorName
Definition: DeclarationName.h:212
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:212
clang::Sema::ActOnCXXBoolLiteral
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
Definition: SemaExprCXX.cpp:805
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:219
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:96
clang::DeclaratorChunk::Mem
MemberPointerTypeInfo Mem
Definition: DeclSpec.h:1555
clang::TemplateArgument::pack_elements
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:366
clang::Declarator::getNumTypeObjects
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Definition: DeclSpec.h:2237
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:68
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::ASTContext::VoidTy
CanQualType VoidTy
Definition: ASTContext.h:1075
clang::DeclarationName::CXXConstructorName
@ CXXConstructorName
Definition: DeclarationName.h:206
llvm::SmallVector
Definition: LLVM.h:38
Lookup.h
clang::TemplateArgumentLoc::getTemplateEllipsisLoc
SourceLocation getTemplateEllipsisLoc() const
Definition: TemplateBase.h:555
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
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:785
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:221
clang::TST_void
@ TST_void
Definition: Specifiers.h:54
clang::Sema::UPPC_Requirement
@ UPPC_Requirement
Definition: Sema.h:8131
clang::DeclSpec::getRepAsExpr
Expr * getRepAsExpr() const
Definition: DeclSpec.h:495
clang::ASTContext::DeclarationNames
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:652
clang::TypeLocBuilder::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Definition: TypeLocBuilder.h:101
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:673
clang::TemplateName::getAsTemplateDecl
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Definition: TemplateName.cpp:101
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::UnresolvedUsingValueDecl::isPackExpansion
bool isPackExpansion() const
Determine whether this is a pack expansion.
Definition: DeclCXX.h:3767
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:475
clang::DeclaratorChunk::Fun
FunctionTypeInfo Fun
Definition: DeclSpec.h:1553
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:1665
clang::Sema::Diag
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: Sema.cpp:1834
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:1114
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:75
clang::BinaryOperator::getOpcodeStr
StringRef getOpcodeStr() const
Definition: Expr.h:3868
clang::Sema::BuildEmptyCXXFoldExpr
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Definition: SemaTemplateVariadic.cpp:1261
clang::DeclarationName::CXXDeductionGuideName
@ CXXDeductionGuideName
Definition: DeclarationName.h:210
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:1878
clang::TST_enum
@ TST_enum
Definition: Specifiers.h:76
clang::TST_error
@ TST_error
Definition: Specifiers.h:93
llvm::Optional< unsigned >
llvm::SmallPtrSet
Definition: ASTContext.h:82
clang::TST_auto
@ TST_auto
Definition: Specifiers.h:86
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:248
clang::CXXScopeSpec
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:64
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::DeclaratorChunk::Pointer
@ Pointer
Definition: DeclSpec.h:1178
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:1480
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:5067
clang::DeclaratorChunk::FunctionTypeInfo::getTrailingReturnType
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1502
clang::DeclaratorChunk::Arr
ArrayTypeInfo Arr
Definition: DeclSpec.h:1552
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:88
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:2899
clang::TST_unknown_anytype
@ TST_unknown_anytype
Definition: Specifiers.h:89
clang::TemplateArgument::getAsExpr
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:342
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
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:1250
clang::TemplateArgumentLoc::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:515
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:97
clang::DeclaratorChunk::Kind
enum clang::DeclaratorChunk::@208 Kind
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:2474
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:411
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::CXXFoldExpr
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4574
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:83
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:668
clang::Declarator::getDeclSpec
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:1911
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:79
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:3809
clang::TemplateArgumentLoc::getLocation
SourceLocation getLocation() const
Definition: TemplateBase.h:496
clang::TypeLocBuilder::push
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
Definition: TypeLocBuilder.h:93
clang::PackExpansionTypeLoc
Definition: TypeLoc.h:2436
Template.h
clang::Sema::getEnclosingLambda
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
Definition: Sema.cpp:2211
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::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:245
clang::DeclaratorChunk::Paren
@ Paren
Definition: DeclSpec.h:1178
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:1353
clang::PackExpansionType
Represents a pack expansion of types.
Definition: Type.h:5632
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:3073
clang::Sema::MarkAnyDeclReferenced
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
Definition: SemaExpr.cpp:18807
clang::DeclSpec::getTypeSpecType
TST getTypeSpecType() const
Definition: DeclSpec.h:477
clang::Sema::CreateParsedType
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6363
clang::TST_decltype
@ TST_decltype
Definition: Specifiers.h:84
clang::PackExpansionTypeLoc::getEllipsisLoc
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2440
clang::LambdaExpr
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1865
clang::Sema::UnexpandedParameterPackContext
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:8066
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:197
clang::DeclarationName::CXXDestructorName
@ CXXDestructorName
Definition: DeclarationName.h:207
clang::LambdaExpr::getTemplateParameterList
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition: ExprCXX.cpp:1266
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:1186
clang::ObjCDictionaryElement::Key
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:265
clang::ASTContext::DependentTy
CanQualType DependentTy
Definition: ASTContext.h:1103
getIdentifier
static StringRef getIdentifier(const Token &Tok)
Definition: ParsePragma.cpp:1380
clang::DeclarationNameTable::getCXXOperatorName
DeclarationName getCXXOperatorName(OverloadedOperatorKind Op)
Get the name of the overloadable C++ operator corresponding to Op.
Definition: DeclarationName.h:639
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:1485
clang::DeclaratorChunk::TypeAndRange::Ty
ParsedType Ty
Definition: DeclSpec.h:1273
clang::RecursiveASTVisitor
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Definition: RecursiveASTVisitor.h:164
Depth
int Depth
Definition: ASTDiff.cpp:191
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7161
clang::TST_atomic
@ TST_atomic
Definition: Specifiers.h:90
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:62
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:380
clang::DeclarationName::CXXOperatorName
@ CXXOperatorName
Definition: DeclarationName.h:209
clang::DeclaratorChunk::FunctionTypeInfo::NoexceptExpr
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1357
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:797
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:2984
clang::DeclRefExpr::getDecl
ValueDecl * getDecl()
Definition: Expr.h:1289
clang::DeclaratorChunk::ArrayTypeInfo::NumElts
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
Definition: DeclSpec.h:1240
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:458
Expr.h
clang::UnresolvedSet
A set of unresolved declarations.
Definition: UnresolvedSet.h:148
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:876
clang::TemplateArgumentLoc::getArgument
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:507
clang::ParsedTemplateArgument::getTemplatePackExpansion
ParsedTemplateArgument getTemplatePackExpansion(SourceLocation EllipsisLoc) const
Retrieve a pack expansion of the given template template argument.
Definition: SemaTemplate.cpp:906
clang::Sema::DiagnoseAmbiguousLookup
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
Definition: SemaLookup.cpp:2526
clang::MultiLevelTemplateArgumentList::getNumLevels
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
Definition: Template.h:114
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:215
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:245
clang::RequiresExpr::getLocalParameters
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:512
clang::SubstTemplateTemplateParmPackStorage
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:135
clang::SubstTemplateTypeParmPackType
Represents the result of substituting a set of types for a template type parameter pack.
Definition: Type.h:4897
clang::UnresolvedUsingValueDecl
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3713
clang::PackExpansionExpr
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4051
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:1341
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:290
clang::Sema::LookupName
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
Definition: SemaLookup.cpp:1914
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:98
clang::TemplateName::isNull
bool isNull() const
Determine whether this template name is NULL.
Definition: TemplateName.cpp:80
clang::DeclaratorChunk::ParamInfo::Param
Decl * Param
Definition: DeclSpec.h:1255
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:410
clang::DeclaratorChunk::BlockPointer
@ BlockPointer
Definition: DeclSpec.h:1178
clang::DeclarationNameInfo::getName
DeclarationName getName() const
getName - Returns the embedded declaration name.
Definition: DeclarationName.h:781
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:3857
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:5013
clang::TST_decimal32
@ TST_decimal32
Definition: Specifiers.h:73
clang::OpaquePtr< QualType >
clang::TemplateTypeParmType
Definition: Type.h:4765
clang::DeclarationName::CXXConversionFunctionName
@ CXXConversionFunctionName
Definition: DeclarationName.h:208
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:4091
clang::Sema::containsUnexpandedParameterPacks
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
Definition: SemaTemplateVariadic.cpp:858
clang::sema::FunctionScopeInfo
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:98
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:91
clang::Sema::diagnoseTypo
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Definition: SemaLookup.cpp:5310
clang::Sema::LookupBinOp
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:14606
clang::ObjCDictionaryLiteral::getKeyValueElement
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:362
clang::RequiresExpr::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprConcepts.h:540
clang::ParsedTemplateArgument::getKind
KindType getKind() const
Determine what kind of template argument we have.
Definition: ParsedTemplate.h:73
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
clang::Sema::CTK_ErrorRecovery
@ CTK_ErrorRecovery
Definition: Sema.h:4210
clang::TemplateArgument::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
Definition: TemplateBase.cpp:268
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:1055
clang::TST_Accum
@ TST_Accum
Definition: Specifiers.h:65
clang::DeclaratorChunk::Pipe
@ Pipe
Definition: DeclSpec.h:1178
clang::LocalInstantiationScope::getPartiallySubstitutedPack
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
Definition: SemaTemplateInstantiate.cpp:3679
clang::ParsedTemplateArgument::isInvalid
bool isInvalid() const
Determine whether the given template argument is invalid.
Definition: ParsedTemplate.h:70
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:149
clang::Attr::isPackExpansion
bool isPackExpansion() const
Definition: Attr.h:103
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:270
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:192
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:229
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:738
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:13272
llvm::ArrayRef
Definition: LLVM.h:34
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::PackExpansionTypeLoc::setEllipsisLoc
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2444
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::DeclarationName::ObjCZeroArgSelector
@ ObjCZeroArgSelector
Definition: DeclarationName.h:204
clang::TemplateArgument::getNumTemplateExpansions
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
Definition: TemplateBase.cpp:272
clang::ParsedTemplateArgument::getAsExpr
Expr * getAsExpr() const
Retrieve the non-type template argument's expression.
Definition: ParsedTemplate.h:82
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:355
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:205
clang::PackExpansionTypeLoc::getPatternLoc
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2456
clang::TST_wchar
@ TST_wchar
Definition: Specifiers.h:56
clang::TemplateTypeParmTypeLoc
Wrapper for template type parameters.
Definition: TypeLoc.h:733
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:9209
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::TST_decimal128
@ TST_decimal128
Definition: Specifiers.h:75
clang::DeclaratorChunk::MemberPointerTypeInfo::Scope
CXXScopeSpec & Scope()
Definition: DeclSpec.h:1531
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:551
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:513
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:1555
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:384
clang::Decl::isParameterPack
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:211
clang::TemplateArgument::Type
@ Type
The template argument is a type.
Definition: TemplateBase.h:71
clang::TemplateTypeParmType::getDepth
unsigned getDepth() const
Definition: Type.h:4806
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:215
clang::TemplateArgument::getPackExpansionPattern
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
Definition: TemplateBase.cpp:392
clang::sema::CompoundScopeInfo
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:68
RecursiveASTVisitor.h
clang::TST_extint
@ TST_extint
Definition: Specifiers.h:62
clang::TemplateArgument::Template
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:87
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:69
clang::TemplateArgument::getAsTemplate
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:293
clang::DeclaratorChunk::Function
@ Function
Definition: DeclSpec.h:1178
clang::Declarator
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1804
clang::CXXScalarValueInitExpr
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Definition: ExprCXX.h:2093
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::CXXScopeSpec::getScopeRep
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:77
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:147
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:46
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:6395
clang::BinaryOperator::getOverloadedOperator
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition: Expr.cpp:2104
clang::Declarator::getTypeObject
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Definition: DeclSpec.h:2241
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:1174
clang::LookupResult::getFoundDecl
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Definition: Lookup.h:517
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:1004
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:2950
clang::Sema::isUnexpandedParameterPackPermitted
bool isUnexpandedParameterPackPermitted()
Determine whether an unexpanded parameter pack might be permitted in this location.
Definition: SemaTemplateVariadic.cpp:280
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:805
clang::TemplateName::getAsSubstTemplateTemplateParmPack
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
Definition: TemplateName.cpp:140
clang::TemplateArgument::pack_size
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:372
clang::Sema::LookupOrdinaryName
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:3972
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: LLVM.h:39
clang::DeclarationName::ObjCMultiArgSelector
@ ObjCMultiArgSelector
Definition: DeclarationName.h:217
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:687
clang::PackExpansionType::getNumExpansions
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5657
clang::TemplateArgumentLoc::getTemplateQualifierLoc
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:541
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:94
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:439
clang::TemplateArgumentLoc::getTemplateNameLoc
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:548
clang::getDepthAndIndex
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
Definition: SemaInternal.h:65
clang::TemplateTypeParmType::isParameterPack
bool isParameterPack() const
Definition: Type.h:4808
clang::TST_Fract
@ TST_Fract
Definition: Specifiers.h:66
clang::CXXScopeSpec::getRange
SourceRange getRange() const
Definition: DeclSpec.h:69
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:2172
clang::CXXScopeSpec::getBeginLoc
SourceLocation getBeginLoc() const
Definition: DeclSpec.h:73
clang::DeclarationNameInfo::getLoc
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Definition: DeclarationName.h:787
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:605
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:758
clang::TST_decltype_auto
@ TST_decltype_auto
Definition: Specifiers.h:87
clang::ParsedTemplateArgument::getAsType
ParsedType getAsType() const
Retrieve the template type argument's type.
Definition: ParsedTemplate.h:76
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:1217
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:229
clang::ParsedTemplateArgument::getAsTemplate
ParsedTemplateTy getAsTemplate() const
Retrieve the template template argument's template name.
Definition: ParsedTemplate.h:88
clang::DeclSpec::getRepAsType
ParsedType getRepAsType() const
Definition: DeclSpec.h:487
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:3561
clang::declaresSameEntity
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1198
clang::TemplateArgument::getAsType
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:269
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:101
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:8501