clang  14.0.0git
SemaTemplateInstantiate.cpp
Go to the documentation of this file.
1 //===------- SemaTemplateInstantiate.cpp - C++ Template Instantiation ------===/
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 C++ template instantiation.
9 //
10 //===----------------------------------------------------------------------===/
11 
12 #include "TreeTransform.h"
13 #include "clang/AST/ASTConsumer.h"
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/ASTLambda.h"
17 #include "clang/AST/DeclTemplate.h"
18 #include "clang/AST/Expr.h"
20 #include "clang/AST/TypeVisitor.h"
22 #include "clang/Basic/Stack.h"
23 #include "clang/Basic/TargetInfo.h"
24 #include "clang/Sema/DeclSpec.h"
26 #include "clang/Sema/Lookup.h"
27 #include "clang/Sema/SemaConcept.h"
29 #include "clang/Sema/Template.h"
32 #include "llvm/Support/TimeProfiler.h"
33 
34 using namespace clang;
35 using namespace sema;
36 
37 //===----------------------------------------------------------------------===/
38 // Template Instantiation Support
39 //===----------------------------------------------------------------------===/
40 
41 /// Retrieve the template argument list(s) that should be used to
42 /// instantiate the definition of the given declaration.
43 ///
44 /// \param D the declaration for which we are computing template instantiation
45 /// arguments.
46 ///
47 /// \param Innermost if non-NULL, the innermost template argument list.
48 ///
49 /// \param RelativeToPrimary true if we should get the template
50 /// arguments relative to the primary template, even when we're
51 /// dealing with a specialization. This is only relevant for function
52 /// template specializations.
53 ///
54 /// \param Pattern If non-NULL, indicates the pattern from which we will be
55 /// instantiating the definition of the given declaration, \p D. This is
56 /// used to determine the proper set of template instantiation arguments for
57 /// friend function template specializations.
60  const TemplateArgumentList *Innermost,
61  bool RelativeToPrimary,
62  const FunctionDecl *Pattern) {
63  // Accumulate the set of template argument lists in this structure.
65 
66  if (Innermost)
67  Result.addOuterTemplateArguments(Innermost);
68 
69  DeclContext *Ctx = dyn_cast<DeclContext>(D);
70  if (!Ctx) {
71  Ctx = D->getDeclContext();
72 
73  // Add template arguments from a variable template instantiation. For a
74  // class-scope explicit specialization, there are no template arguments
75  // at this level, but there may be enclosing template arguments.
77  dyn_cast<VarTemplateSpecializationDecl>(D);
78  if (Spec && !Spec->isClassScopeExplicitSpecialization()) {
79  // We're done when we hit an explicit specialization.
81  !isa<VarTemplatePartialSpecializationDecl>(Spec))
82  return Result;
83 
84  Result.addOuterTemplateArguments(&Spec->getTemplateInstantiationArgs());
85 
86  // If this variable template specialization was instantiated from a
87  // specialized member that is a variable template, we're done.
88  assert(Spec->getSpecializedTemplate() && "No variable template?");
89  llvm::PointerUnion<VarTemplateDecl*,
93  Specialized.dyn_cast<VarTemplatePartialSpecializationDecl *>()) {
94  if (Partial->isMemberSpecialization())
95  return Result;
96  } else {
97  VarTemplateDecl *Tmpl = Specialized.get<VarTemplateDecl *>();
98  if (Tmpl->isMemberSpecialization())
99  return Result;
100  }
101  }
102 
103  // If we have a template template parameter with translation unit context,
104  // then we're performing substitution into a default template argument of
105  // this template template parameter before we've constructed the template
106  // that will own this template template parameter. In this case, we
107  // use empty template parameter lists for all of the outer templates
108  // to avoid performing any substitutions.
109  if (Ctx->isTranslationUnit()) {
110  if (TemplateTemplateParmDecl *TTP
111  = dyn_cast<TemplateTemplateParmDecl>(D)) {
112  for (unsigned I = 0, N = TTP->getDepth() + 1; I != N; ++I)
113  Result.addOuterTemplateArguments(None);
114  return Result;
115  }
116  }
117  }
118 
119  while (!Ctx->isFileContext()) {
120  // Add template arguments from a class template instantiation.
122  = dyn_cast<ClassTemplateSpecializationDecl>(Ctx);
123  if (Spec && !Spec->isClassScopeExplicitSpecialization()) {
124  // We're done when we hit an explicit specialization.
126  !isa<ClassTemplatePartialSpecializationDecl>(Spec))
127  break;
128 
129  Result.addOuterTemplateArguments(&Spec->getTemplateInstantiationArgs());
130 
131  // If this class template specialization was instantiated from a
132  // specialized member that is a class template, we're done.
133  assert(Spec->getSpecializedTemplate() && "No class template?");
135  break;
136  }
137  // Add template arguments from a function template specialization.
138  else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) {
139  if (!RelativeToPrimary &&
140  Function->getTemplateSpecializationKindForInstantiation() ==
142  break;
143 
144  if (!RelativeToPrimary && Function->getTemplateSpecializationKind() ==
146  // This is an implicit instantiation of an explicit specialization. We
147  // don't get any template arguments from this function but might get
148  // some from an enclosing template.
149  } else if (const TemplateArgumentList *TemplateArgs
150  = Function->getTemplateSpecializationArgs()) {
151  // Add the template arguments for this specialization.
152  Result.addOuterTemplateArguments(TemplateArgs);
153 
154  // If this function was instantiated from a specialized member that is
155  // a function template, we're done.
156  assert(Function->getPrimaryTemplate() && "No function template?");
157  if (Function->getPrimaryTemplate()->isMemberSpecialization())
158  break;
159 
160  // If this function is a generic lambda specialization, we are done.
162  break;
163 
164  } else if (Function->getDescribedFunctionTemplate()) {
165  assert(Result.getNumSubstitutedLevels() == 0 &&
166  "Outer template not instantiated?");
167  }
168 
169  // If this is a friend declaration and it declares an entity at
170  // namespace scope, take arguments from its lexical parent
171  // instead of its semantic parent, unless of course the pattern we're
172  // instantiating actually comes from the file's context!
173  if (Function->getFriendObjectKind() &&
174  Function->getDeclContext()->isFileContext() &&
175  (!Pattern || !Pattern->getLexicalDeclContext()->isFileContext())) {
176  Ctx = Function->getLexicalDeclContext();
177  RelativeToPrimary = false;
178  continue;
179  }
180  } else if (CXXRecordDecl *Rec = dyn_cast<CXXRecordDecl>(Ctx)) {
181  if (ClassTemplateDecl *ClassTemplate = Rec->getDescribedClassTemplate()) {
182  assert(Result.getNumSubstitutedLevels() == 0 &&
183  "Outer template not instantiated?");
184  if (ClassTemplate->isMemberSpecialization())
185  break;
186  }
187  }
188 
189  Ctx = Ctx->getParent();
190  RelativeToPrimary = false;
191  }
192 
193  return Result;
194 }
195 
197  switch (Kind) {
198  case TemplateInstantiation:
199  case ExceptionSpecInstantiation:
200  case DefaultTemplateArgumentInstantiation:
201  case DefaultFunctionArgumentInstantiation:
202  case ExplicitTemplateArgumentSubstitution:
203  case DeducedTemplateArgumentSubstitution:
204  case PriorTemplateArgumentSubstitution:
205  case ConstraintsCheck:
206  case NestedRequirementConstraintsCheck:
207  return true;
208 
209  case RequirementInstantiation:
210  case DefaultTemplateArgumentChecking:
211  case DeclaringSpecialMember:
212  case DeclaringImplicitEqualityComparison:
213  case DefiningSynthesizedFunction:
214  case ExceptionSpecEvaluation:
215  case ConstraintSubstitution:
216  case ParameterMappingSubstitution:
217  case ConstraintNormalization:
218  case RewritingOperatorAsSpaceship:
219  case InitializingStructuredBinding:
220  case MarkingClassDllexported:
221  return false;
222 
223  // This function should never be called when Kind's value is Memoization.
224  case Memoization:
225  break;
226  }
227 
228  llvm_unreachable("Invalid SynthesisKind!");
229 }
230 
233  SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
234  Decl *Entity, NamedDecl *Template, ArrayRef<TemplateArgument> TemplateArgs,
235  sema::TemplateDeductionInfo *DeductionInfo)
236  : SemaRef(SemaRef) {
237  // Don't allow further instantiation if a fatal error and an uncompilable
238  // error have occurred. Any diagnostics we might have raised will not be
239  // visible, and we do not need to construct a correct AST.
240  if (SemaRef.Diags.hasFatalErrorOccurred() &&
241  SemaRef.hasUncompilableErrorOccurred()) {
242  Invalid = true;
243  return;
244  }
245  Invalid = CheckInstantiationDepth(PointOfInstantiation, InstantiationRange);
246  if (!Invalid) {
248  Inst.Kind = Kind;
249  Inst.PointOfInstantiation = PointOfInstantiation;
250  Inst.Entity = Entity;
251  Inst.Template = Template;
252  Inst.TemplateArgs = TemplateArgs.data();
253  Inst.NumTemplateArgs = TemplateArgs.size();
254  Inst.DeductionInfo = DeductionInfo;
255  Inst.InstantiationRange = InstantiationRange;
256  SemaRef.pushCodeSynthesisContext(Inst);
257 
258  AlreadyInstantiating = !Inst.Entity ? false :
260  .insert({Inst.Entity->getCanonicalDecl(), Inst.Kind})
261  .second;
262  atTemplateBegin(SemaRef.TemplateInstCallbacks, SemaRef, Inst);
263  }
264 }
265 
267  Sema &SemaRef, SourceLocation PointOfInstantiation, Decl *Entity,
268  SourceRange InstantiationRange)
269  : InstantiatingTemplate(SemaRef,
270  CodeSynthesisContext::TemplateInstantiation,
271  PointOfInstantiation, InstantiationRange, Entity) {}
272 
274  Sema &SemaRef, SourceLocation PointOfInstantiation, FunctionDecl *Entity,
275  ExceptionSpecification, SourceRange InstantiationRange)
277  SemaRef, CodeSynthesisContext::ExceptionSpecInstantiation,
278  PointOfInstantiation, InstantiationRange, Entity) {}
279 
281  Sema &SemaRef, SourceLocation PointOfInstantiation, TemplateParameter Param,
282  TemplateDecl *Template, ArrayRef<TemplateArgument> TemplateArgs,
283  SourceRange InstantiationRange)
285  SemaRef,
286  CodeSynthesisContext::DefaultTemplateArgumentInstantiation,
287  PointOfInstantiation, InstantiationRange, getAsNamedDecl(Param),
288  Template, TemplateArgs) {}
289 
291  Sema &SemaRef, SourceLocation PointOfInstantiation,
292  FunctionTemplateDecl *FunctionTemplate,
293  ArrayRef<TemplateArgument> TemplateArgs,
295  sema::TemplateDeductionInfo &DeductionInfo, SourceRange InstantiationRange)
296  : InstantiatingTemplate(SemaRef, Kind, PointOfInstantiation,
297  InstantiationRange, FunctionTemplate, nullptr,
298  TemplateArgs, &DeductionInfo) {
299  assert(
302 }
303 
305  Sema &SemaRef, SourceLocation PointOfInstantiation,
306  TemplateDecl *Template,
307  ArrayRef<TemplateArgument> TemplateArgs,
308  sema::TemplateDeductionInfo &DeductionInfo, SourceRange InstantiationRange)
310  SemaRef,
311  CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
312  PointOfInstantiation, InstantiationRange, Template, nullptr,
313  TemplateArgs, &DeductionInfo) {}
314 
316  Sema &SemaRef, SourceLocation PointOfInstantiation,
318  ArrayRef<TemplateArgument> TemplateArgs,
319  sema::TemplateDeductionInfo &DeductionInfo, SourceRange InstantiationRange)
321  SemaRef,
322  CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
323  PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
324  TemplateArgs, &DeductionInfo) {}
325 
327  Sema &SemaRef, SourceLocation PointOfInstantiation,
329  ArrayRef<TemplateArgument> TemplateArgs,
330  sema::TemplateDeductionInfo &DeductionInfo, SourceRange InstantiationRange)
332  SemaRef,
333  CodeSynthesisContext::DeducedTemplateArgumentSubstitution,
334  PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
335  TemplateArgs, &DeductionInfo) {}
336 
338  Sema &SemaRef, SourceLocation PointOfInstantiation, ParmVarDecl *Param,
339  ArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange)
341  SemaRef,
342  CodeSynthesisContext::DefaultFunctionArgumentInstantiation,
343  PointOfInstantiation, InstantiationRange, Param, nullptr,
344  TemplateArgs) {}
345 
347  Sema &SemaRef, SourceLocation PointOfInstantiation, NamedDecl *Template,
349  SourceRange InstantiationRange)
351  SemaRef,
352  CodeSynthesisContext::PriorTemplateArgumentSubstitution,
353  PointOfInstantiation, InstantiationRange, Param, Template,
354  TemplateArgs) {}
355 
357  Sema &SemaRef, SourceLocation PointOfInstantiation, NamedDecl *Template,
359  SourceRange InstantiationRange)
361  SemaRef,
362  CodeSynthesisContext::PriorTemplateArgumentSubstitution,
363  PointOfInstantiation, InstantiationRange, Param, Template,
364  TemplateArgs) {}
365 
367  Sema &SemaRef, SourceLocation PointOfInstantiation, TemplateDecl *Template,
368  NamedDecl *Param, ArrayRef<TemplateArgument> TemplateArgs,
369  SourceRange InstantiationRange)
371  SemaRef, CodeSynthesisContext::DefaultTemplateArgumentChecking,
372  PointOfInstantiation, InstantiationRange, Param, Template,
373  TemplateArgs) {}
374 
376  Sema &SemaRef, SourceLocation PointOfInstantiation,
378  SourceRange InstantiationRange)
380  SemaRef, CodeSynthesisContext::RequirementInstantiation,
381  PointOfInstantiation, InstantiationRange, /*Entity=*/nullptr,
382  /*Template=*/nullptr, /*TemplateArgs=*/None, &DeductionInfo) {}
383 
384 
386  Sema &SemaRef, SourceLocation PointOfInstantiation,
388  SourceRange InstantiationRange)
390  SemaRef, CodeSynthesisContext::NestedRequirementConstraintsCheck,
391  PointOfInstantiation, InstantiationRange, /*Entity=*/nullptr,
392  /*Template=*/nullptr, /*TemplateArgs=*/None) {}
393 
394 
396  Sema &SemaRef, SourceLocation PointOfInstantiation,
397  ConstraintsCheck, NamedDecl *Template,
398  ArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange)
401  PointOfInstantiation, InstantiationRange, Template, nullptr,
402  TemplateArgs) {}
403 
405  Sema &SemaRef, SourceLocation PointOfInstantiation,
407  sema::TemplateDeductionInfo &DeductionInfo, SourceRange InstantiationRange)
410  PointOfInstantiation, InstantiationRange, Template, nullptr,
411  {}, &DeductionInfo) {}
412 
414  Sema &SemaRef, SourceLocation PointOfInstantiation,
416  SourceRange InstantiationRange)
419  PointOfInstantiation, InstantiationRange, Template) {}
420 
422  Sema &SemaRef, SourceLocation PointOfInstantiation,
424  SourceRange InstantiationRange)
427  PointOfInstantiation, InstantiationRange, Template) {}
428 
432 
433  CodeSynthesisContexts.push_back(Ctx);
434 
435  if (!Ctx.isInstantiationRecord())
437 
438  // Check to see if we're low on stack space. We can't do anything about this
439  // from here, but we can at least warn the user.
442 }
443 
445  auto &Active = CodeSynthesisContexts.back();
446  if (!Active.isInstantiationRecord()) {
447  assert(NonInstantiationEntries > 0);
449  }
450 
451  InNonInstantiationSFINAEContext = Active.SavedInNonInstantiationSFINAEContext;
452 
453  // Name lookup no longer looks in this template's defining module.
454  assert(CodeSynthesisContexts.size() >=
456  "forgot to remove a lookup module for a template instantiation");
457  if (CodeSynthesisContexts.size() ==
460  LookupModulesCache.erase(M);
462  }
463 
464  // If we've left the code synthesis context for the current context stack,
465  // stop remembering that we've emitted that stack.
466  if (CodeSynthesisContexts.size() ==
469 
470  CodeSynthesisContexts.pop_back();
471 }
472 
474  if (!Invalid) {
475  if (!AlreadyInstantiating) {
476  auto &Active = SemaRef.CodeSynthesisContexts.back();
477  if (Active.Entity)
478  SemaRef.InstantiatingSpecializations.erase(
479  {Active.Entity->getCanonicalDecl(), Active.Kind});
480  }
481 
482  atTemplateEnd(SemaRef.TemplateInstCallbacks, SemaRef,
483  SemaRef.CodeSynthesisContexts.back());
484 
485  SemaRef.popCodeSynthesisContext();
486  Invalid = true;
487  }
488 }
489 
490 bool Sema::InstantiatingTemplate::CheckInstantiationDepth(
491  SourceLocation PointOfInstantiation,
492  SourceRange InstantiationRange) {
493  assert(SemaRef.NonInstantiationEntries <=
494  SemaRef.CodeSynthesisContexts.size());
495  if ((SemaRef.CodeSynthesisContexts.size() -
496  SemaRef.NonInstantiationEntries)
497  <= SemaRef.getLangOpts().InstantiationDepth)
498  return false;
499 
500  SemaRef.Diag(PointOfInstantiation,
501  diag::err_template_recursion_depth_exceeded)
502  << SemaRef.getLangOpts().InstantiationDepth
503  << InstantiationRange;
504  SemaRef.Diag(PointOfInstantiation, diag::note_template_recursion_depth)
505  << SemaRef.getLangOpts().InstantiationDepth;
506  return true;
507 }
508 
509 /// Prints the current instantiation stack through a series of
510 /// notes.
512  // Determine which template instantiations to skip, if any.
513  unsigned SkipStart = CodeSynthesisContexts.size(), SkipEnd = SkipStart;
514  unsigned Limit = Diags.getTemplateBacktraceLimit();
515  if (Limit && Limit < CodeSynthesisContexts.size()) {
516  SkipStart = Limit / 2 + Limit % 2;
517  SkipEnd = CodeSynthesisContexts.size() - Limit / 2;
518  }
519 
520  // FIXME: In all of these cases, we need to show the template arguments
521  unsigned InstantiationIdx = 0;
523  Active = CodeSynthesisContexts.rbegin(),
524  ActiveEnd = CodeSynthesisContexts.rend();
525  Active != ActiveEnd;
526  ++Active, ++InstantiationIdx) {
527  // Skip this instantiation?
528  if (InstantiationIdx >= SkipStart && InstantiationIdx < SkipEnd) {
529  if (InstantiationIdx == SkipStart) {
530  // Note that we're skipping instantiations.
531  Diags.Report(Active->PointOfInstantiation,
532  diag::note_instantiation_contexts_suppressed)
533  << unsigned(CodeSynthesisContexts.size() - Limit);
534  }
535  continue;
536  }
537 
538  switch (Active->Kind) {
540  Decl *D = Active->Entity;
541  if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) {
542  unsigned DiagID = diag::note_template_member_class_here;
543  if (isa<ClassTemplateSpecializationDecl>(Record))
544  DiagID = diag::note_template_class_instantiation_here;
545  Diags.Report(Active->PointOfInstantiation, DiagID)
546  << Record << Active->InstantiationRange;
547  } else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
548  unsigned DiagID;
549  if (Function->getPrimaryTemplate())
550  DiagID = diag::note_function_template_spec_here;
551  else
552  DiagID = diag::note_template_member_function_here;
553  Diags.Report(Active->PointOfInstantiation, DiagID)
554  << Function
555  << Active->InstantiationRange;
556  } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
557  Diags.Report(Active->PointOfInstantiation,
558  VD->isStaticDataMember()?
559  diag::note_template_static_data_member_def_here
560  : diag::note_template_variable_def_here)
561  << VD
562  << Active->InstantiationRange;
563  } else if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
564  Diags.Report(Active->PointOfInstantiation,
565  diag::note_template_enum_def_here)
566  << ED
567  << Active->InstantiationRange;
568  } else if (FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
569  Diags.Report(Active->PointOfInstantiation,
570  diag::note_template_nsdmi_here)
571  << FD << Active->InstantiationRange;
572  } else {
573  Diags.Report(Active->PointOfInstantiation,
574  diag::note_template_type_alias_instantiation_here)
575  << cast<TypeAliasTemplateDecl>(D)
576  << Active->InstantiationRange;
577  }
578  break;
579  }
580 
582  TemplateDecl *Template = cast<TemplateDecl>(Active->Template);
583  SmallString<128> TemplateArgsStr;
584  llvm::raw_svector_ostream OS(TemplateArgsStr);
585  Template->printName(OS);
586  printTemplateArgumentList(OS, Active->template_arguments(),
588  Diags.Report(Active->PointOfInstantiation,
589  diag::note_default_arg_instantiation_here)
590  << OS.str()
591  << Active->InstantiationRange;
592  break;
593  }
594 
596  FunctionTemplateDecl *FnTmpl = cast<FunctionTemplateDecl>(Active->Entity);
597  Diags.Report(Active->PointOfInstantiation,
598  diag::note_explicit_template_arg_substitution_here)
599  << FnTmpl
601  Active->TemplateArgs,
602  Active->NumTemplateArgs)
603  << Active->InstantiationRange;
604  break;
605  }
606 
608  if (FunctionTemplateDecl *FnTmpl =
609  dyn_cast<FunctionTemplateDecl>(Active->Entity)) {
610  Diags.Report(Active->PointOfInstantiation,
611  diag::note_function_template_deduction_instantiation_here)
612  << FnTmpl
613  << getTemplateArgumentBindingsText(FnTmpl->getTemplateParameters(),
614  Active->TemplateArgs,
615  Active->NumTemplateArgs)
616  << Active->InstantiationRange;
617  } else {
618  bool IsVar = isa<VarTemplateDecl>(Active->Entity) ||
619  isa<VarTemplateSpecializationDecl>(Active->Entity);
620  bool IsTemplate = false;
621  TemplateParameterList *Params;
622  if (auto *D = dyn_cast<TemplateDecl>(Active->Entity)) {
623  IsTemplate = true;
624  Params = D->getTemplateParameters();
625  } else if (auto *D = dyn_cast<ClassTemplatePartialSpecializationDecl>(
626  Active->Entity)) {
627  Params = D->getTemplateParameters();
628  } else if (auto *D = dyn_cast<VarTemplatePartialSpecializationDecl>(
629  Active->Entity)) {
630  Params = D->getTemplateParameters();
631  } else {
632  llvm_unreachable("unexpected template kind");
633  }
634 
635  Diags.Report(Active->PointOfInstantiation,
636  diag::note_deduced_template_arg_substitution_here)
637  << IsVar << IsTemplate << cast<NamedDecl>(Active->Entity)
638  << getTemplateArgumentBindingsText(Params, Active->TemplateArgs,
639  Active->NumTemplateArgs)
640  << Active->InstantiationRange;
641  }
642  break;
643  }
644 
646  ParmVarDecl *Param = cast<ParmVarDecl>(Active->Entity);
647  FunctionDecl *FD = cast<FunctionDecl>(Param->getDeclContext());
648 
649  SmallString<128> TemplateArgsStr;
650  llvm::raw_svector_ostream OS(TemplateArgsStr);
651  FD->printName(OS);
652  printTemplateArgumentList(OS, Active->template_arguments(),
654  Diags.Report(Active->PointOfInstantiation,
655  diag::note_default_function_arg_instantiation_here)
656  << OS.str()
657  << Active->InstantiationRange;
658  break;
659  }
660 
662  NamedDecl *Parm = cast<NamedDecl>(Active->Entity);
663  std::string Name;
664  if (!Parm->getName().empty())
665  Name = std::string(" '") + Parm->getName().str() + "'";
666 
667  TemplateParameterList *TemplateParams = nullptr;
668  if (TemplateDecl *Template = dyn_cast<TemplateDecl>(Active->Template))
669  TemplateParams = Template->getTemplateParameters();
670  else
671  TemplateParams =
672  cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
673  ->getTemplateParameters();
674  Diags.Report(Active->PointOfInstantiation,
675  diag::note_prior_template_arg_substitution)
676  << isa<TemplateTemplateParmDecl>(Parm)
677  << Name
678  << getTemplateArgumentBindingsText(TemplateParams,
679  Active->TemplateArgs,
680  Active->NumTemplateArgs)
681  << Active->InstantiationRange;
682  break;
683  }
684 
686  TemplateParameterList *TemplateParams = nullptr;
687  if (TemplateDecl *Template = dyn_cast<TemplateDecl>(Active->Template))
688  TemplateParams = Template->getTemplateParameters();
689  else
690  TemplateParams =
691  cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
692  ->getTemplateParameters();
693 
694  Diags.Report(Active->PointOfInstantiation,
695  diag::note_template_default_arg_checking)
696  << getTemplateArgumentBindingsText(TemplateParams,
697  Active->TemplateArgs,
698  Active->NumTemplateArgs)
699  << Active->InstantiationRange;
700  break;
701  }
702 
704  Diags.Report(Active->PointOfInstantiation,
705  diag::note_evaluating_exception_spec_here)
706  << cast<FunctionDecl>(Active->Entity);
707  break;
708 
710  Diags.Report(Active->PointOfInstantiation,
711  diag::note_template_exception_spec_instantiation_here)
712  << cast<FunctionDecl>(Active->Entity)
713  << Active->InstantiationRange;
714  break;
715 
717  Diags.Report(Active->PointOfInstantiation,
718  diag::note_template_requirement_instantiation_here)
719  << Active->InstantiationRange;
720  break;
721 
723  Diags.Report(Active->PointOfInstantiation,
724  diag::note_nested_requirement_here)
725  << Active->InstantiationRange;
726  break;
727 
729  Diags.Report(Active->PointOfInstantiation,
730  diag::note_in_declaration_of_implicit_special_member)
731  << cast<CXXRecordDecl>(Active->Entity) << Active->SpecialMember;
732  break;
733 
735  Diags.Report(Active->Entity->getLocation(),
736  diag::note_in_declaration_of_implicit_equality_comparison);
737  break;
738 
740  // FIXME: For synthesized functions that are not defaulted,
741  // produce a note.
742  auto *FD = dyn_cast<FunctionDecl>(Active->Entity);
745  if (DFK.isSpecialMember()) {
746  auto *MD = cast<CXXMethodDecl>(FD);
747  Diags.Report(Active->PointOfInstantiation,
748  diag::note_member_synthesized_at)
749  << MD->isExplicitlyDefaulted() << DFK.asSpecialMember()
750  << Context.getTagDeclType(MD->getParent());
751  } else if (DFK.isComparison()) {
752  Diags.Report(Active->PointOfInstantiation,
753  diag::note_comparison_synthesized_at)
754  << (int)DFK.asComparison()
756  cast<CXXRecordDecl>(FD->getLexicalDeclContext()));
757  }
758  break;
759  }
760 
762  Diags.Report(Active->Entity->getLocation(),
763  diag::note_rewriting_operator_as_spaceship);
764  break;
765 
767  Diags.Report(Active->PointOfInstantiation,
768  diag::note_in_binding_decl_init)
769  << cast<BindingDecl>(Active->Entity);
770  break;
771 
773  Diags.Report(Active->PointOfInstantiation,
774  diag::note_due_to_dllexported_class)
775  << cast<CXXRecordDecl>(Active->Entity) << !getLangOpts().CPlusPlus11;
776  break;
777 
779  break;
780 
782  unsigned DiagID = 0;
783  if (!Active->Entity) {
784  Diags.Report(Active->PointOfInstantiation,
785  diag::note_nested_requirement_here)
786  << Active->InstantiationRange;
787  break;
788  }
789  if (isa<ConceptDecl>(Active->Entity))
790  DiagID = diag::note_concept_specialization_here;
791  else if (isa<TemplateDecl>(Active->Entity))
792  DiagID = diag::note_checking_constraints_for_template_id_here;
793  else if (isa<VarTemplatePartialSpecializationDecl>(Active->Entity))
794  DiagID = diag::note_checking_constraints_for_var_spec_id_here;
795  else if (isa<ClassTemplatePartialSpecializationDecl>(Active->Entity))
796  DiagID = diag::note_checking_constraints_for_class_spec_id_here;
797  else {
798  assert(isa<FunctionDecl>(Active->Entity));
799  DiagID = diag::note_checking_constraints_for_function_here;
800  }
801  SmallString<128> TemplateArgsStr;
802  llvm::raw_svector_ostream OS(TemplateArgsStr);
803  cast<NamedDecl>(Active->Entity)->printName(OS);
804  if (!isa<FunctionDecl>(Active->Entity)) {
805  printTemplateArgumentList(OS, Active->template_arguments(),
807  }
808  Diags.Report(Active->PointOfInstantiation, DiagID) << OS.str()
809  << Active->InstantiationRange;
810  break;
811  }
813  Diags.Report(Active->PointOfInstantiation,
814  diag::note_constraint_substitution_here)
815  << Active->InstantiationRange;
816  break;
818  Diags.Report(Active->PointOfInstantiation,
819  diag::note_constraint_normalization_here)
820  << cast<NamedDecl>(Active->Entity)->getName()
821  << Active->InstantiationRange;
822  break;
824  Diags.Report(Active->PointOfInstantiation,
825  diag::note_parameter_mapping_substitution_here)
826  << Active->InstantiationRange;
827  break;
828  }
829  }
830 }
831 
834  return Optional<TemplateDeductionInfo *>(nullptr);
835 
837  Active = CodeSynthesisContexts.rbegin(),
838  ActiveEnd = CodeSynthesisContexts.rend();
839  Active != ActiveEnd;
840  ++Active)
841  {
842  switch (Active->Kind) {
844  // An instantiation of an alias template may or may not be a SFINAE
845  // context, depending on what else is on the stack.
846  if (isa<TypeAliasTemplateDecl>(Active->Entity))
847  break;
848  LLVM_FALLTHROUGH;
855  // This is a template instantiation, so there is no SFINAE.
856  return None;
857 
862  // A default template argument instantiation and substitution into
863  // template parameters with arguments for prior parameters may or may
864  // not be a SFINAE context; look further up the stack.
865  break;
866 
871  // We're either substituting explicitly-specified template arguments,
872  // deduced template arguments, a constraint expression or a requirement
873  // in a requires expression, so SFINAE applies.
874  assert(Active->DeductionInfo && "Missing deduction info pointer");
875  return Active->DeductionInfo;
876 
882  // This happens in a context unrelated to template instantiation, so
883  // there is no SFINAE.
884  return None;
885 
887  // FIXME: This should not be treated as a SFINAE context, because
888  // we will cache an incorrect exception specification. However, clang
889  // bootstrap relies this! See PR31692.
890  break;
891 
893  break;
894  }
895 
896  // The inner context was transparent for SFINAE. If it occurred within a
897  // non-instantiation SFINAE context, then SFINAE applies.
898  if (Active->SavedInNonInstantiationSFINAEContext)
899  return Optional<TemplateDeductionInfo *>(nullptr);
900  }
901 
902  return None;
903 }
904 
905 //===----------------------------------------------------------------------===/
906 // Template Instantiation for Types
907 //===----------------------------------------------------------------------===/
908 namespace {
909  class TemplateInstantiator : public TreeTransform<TemplateInstantiator> {
910  const MultiLevelTemplateArgumentList &TemplateArgs;
911  SourceLocation Loc;
912  DeclarationName Entity;
913 
914  public:
915  typedef TreeTransform<TemplateInstantiator> inherited;
916 
917  TemplateInstantiator(Sema &SemaRef,
918  const MultiLevelTemplateArgumentList &TemplateArgs,
919  SourceLocation Loc,
920  DeclarationName Entity)
921  : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
922  Entity(Entity) { }
923 
924  /// Determine whether the given type \p T has already been
925  /// transformed.
926  ///
927  /// For the purposes of template instantiation, a type has already been
928  /// transformed if it is NULL or if it is not dependent.
929  bool AlreadyTransformed(QualType T);
930 
931  /// Returns the location of the entity being instantiated, if known.
932  SourceLocation getBaseLocation() { return Loc; }
933 
934  /// Returns the name of the entity being instantiated, if any.
935  DeclarationName getBaseEntity() { return Entity; }
936 
937  /// Sets the "base" location and entity when that
938  /// information is known based on another transformation.
939  void setBase(SourceLocation Loc, DeclarationName Entity) {
940  this->Loc = Loc;
941  this->Entity = Entity;
942  }
943 
944  unsigned TransformTemplateDepth(unsigned Depth) {
945  return TemplateArgs.getNewDepth(Depth);
946  }
947 
948  bool TryExpandParameterPacks(SourceLocation EllipsisLoc,
949  SourceRange PatternRange,
951  bool &ShouldExpand, bool &RetainExpansion,
952  Optional<unsigned> &NumExpansions) {
953  return getSema().CheckParameterPacksForExpansion(EllipsisLoc,
954  PatternRange, Unexpanded,
955  TemplateArgs,
956  ShouldExpand,
957  RetainExpansion,
958  NumExpansions);
959  }
960 
961  void ExpandingFunctionParameterPack(ParmVarDecl *Pack) {
963  }
964 
965  TemplateArgument ForgetPartiallySubstitutedPack() {
966  TemplateArgument Result;
967  if (NamedDecl *PartialPack
969  MultiLevelTemplateArgumentList &TemplateArgs
970  = const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
971  unsigned Depth, Index;
972  std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
973  if (TemplateArgs.hasTemplateArgument(Depth, Index)) {
974  Result = TemplateArgs(Depth, Index);
975  TemplateArgs.setArgument(Depth, Index, TemplateArgument());
976  }
977  }
978 
979  return Result;
980  }
981 
982  void RememberPartiallySubstitutedPack(TemplateArgument Arg) {
983  if (Arg.isNull())
984  return;
985 
986  if (NamedDecl *PartialPack
988  MultiLevelTemplateArgumentList &TemplateArgs
989  = const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
990  unsigned Depth, Index;
991  std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
992  TemplateArgs.setArgument(Depth, Index, Arg);
993  }
994  }
995 
996  /// Transform the given declaration by instantiating a reference to
997  /// this declaration.
998  Decl *TransformDecl(SourceLocation Loc, Decl *D);
999 
1000  void transformAttrs(Decl *Old, Decl *New) {
1001  SemaRef.InstantiateAttrs(TemplateArgs, Old, New);
1002  }
1003 
1004  void transformedLocalDecl(Decl *Old, ArrayRef<Decl *> NewDecls) {
1005  if (Old->isParameterPack()) {
1007  for (auto *New : NewDecls)
1009  Old, cast<VarDecl>(New));
1010  return;
1011  }
1012 
1013  assert(NewDecls.size() == 1 &&
1014  "should only have multiple expansions for a pack");
1015  Decl *New = NewDecls.front();
1016 
1017  // If we've instantiated the call operator of a lambda or the call
1018  // operator template of a generic lambda, update the "instantiation of"
1019  // information.
1020  auto *NewMD = dyn_cast<CXXMethodDecl>(New);
1021  if (NewMD && isLambdaCallOperator(NewMD)) {
1022  auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
1023  if (auto *NewTD = NewMD->getDescribedFunctionTemplate())
1024  NewTD->setInstantiatedFromMemberTemplate(
1025  OldMD->getDescribedFunctionTemplate());
1026  else
1027  NewMD->setInstantiationOfMemberFunction(OldMD,
1029  }
1030 
1031  SemaRef.CurrentInstantiationScope->InstantiatedLocal(Old, New);
1032 
1033  // We recreated a local declaration, but not by instantiating it. There
1034  // may be pending dependent diagnostics to produce.
1035  if (auto *DC = dyn_cast<DeclContext>(Old))
1036  SemaRef.PerformDependentDiagnostics(DC, TemplateArgs);
1037  }
1038 
1039  /// Transform the definition of the given declaration by
1040  /// instantiating it.
1041  Decl *TransformDefinition(SourceLocation Loc, Decl *D);
1042 
1043  /// Transform the first qualifier within a scope by instantiating the
1044  /// declaration.
1045  NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc);
1046 
1047  /// Rebuild the exception declaration and register the declaration
1048  /// as an instantiated local.
1049  VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
1051  SourceLocation StartLoc,
1052  SourceLocation NameLoc,
1053  IdentifierInfo *Name);
1054 
1055  /// Rebuild the Objective-C exception declaration and register the
1056  /// declaration as an instantiated local.
1057  VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
1058  TypeSourceInfo *TSInfo, QualType T);
1059 
1060  /// Check for tag mismatches when instantiating an
1061  /// elaborated type.
1062  QualType RebuildElaboratedType(SourceLocation KeywordLoc,
1063  ElaboratedTypeKeyword Keyword,
1064  NestedNameSpecifierLoc QualifierLoc,
1065  QualType T);
1066 
1067  TemplateName
1068  TransformTemplateName(CXXScopeSpec &SS, TemplateName Name,
1069  SourceLocation NameLoc,
1070  QualType ObjectType = QualType(),
1071  NamedDecl *FirstQualifierInScope = nullptr,
1072  bool AllowInjectedClassName = false);
1073 
1074  const LoopHintAttr *TransformLoopHintAttr(const LoopHintAttr *LH);
1075 
1076  ExprResult TransformPredefinedExpr(PredefinedExpr *E);
1077  ExprResult TransformDeclRefExpr(DeclRefExpr *E);
1078  ExprResult TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E);
1079 
1080  ExprResult TransformTemplateParmRefExpr(DeclRefExpr *E,
1082  ExprResult TransformSubstNonTypeTemplateParmPackExpr(
1084  ExprResult TransformSubstNonTypeTemplateParmExpr(
1086 
1087  /// Rebuild a DeclRefExpr for a VarDecl reference.
1088  ExprResult RebuildVarDeclRefExpr(VarDecl *PD, SourceLocation Loc);
1089 
1090  /// Transform a reference to a function or init-capture parameter pack.
1091  ExprResult TransformFunctionParmPackRefExpr(DeclRefExpr *E, VarDecl *PD);
1092 
1093  /// Transform a FunctionParmPackExpr which was built when we couldn't
1094  /// expand a function parameter pack reference which refers to an expanded
1095  /// pack.
1096  ExprResult TransformFunctionParmPackExpr(FunctionParmPackExpr *E);
1097 
1098  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
1099  FunctionProtoTypeLoc TL) {
1100  // Call the base version; it will forward to our overridden version below.
1101  return inherited::TransformFunctionProtoType(TLB, TL);
1102  }
1103 
1104  template<typename Fn>
1105  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
1107  CXXRecordDecl *ThisContext,
1108  Qualifiers ThisTypeQuals,
1109  Fn TransformExceptionSpec);
1110 
1111  ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
1112  int indexAdjustment,
1113  Optional<unsigned> NumExpansions,
1114  bool ExpectParameterPack);
1115 
1116  /// Transforms a template type parameter type by performing
1117  /// substitution of the corresponding template type argument.
1118  QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
1120 
1121  /// Transforms an already-substituted template type parameter pack
1122  /// into either itself (if we aren't substituting into its pack expansion)
1123  /// or the appropriate substituted argument.
1124  QualType TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB,
1126 
1127  ExprResult TransformLambdaExpr(LambdaExpr *E) {
1128  LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
1130  }
1131 
1132  ExprResult TransformRequiresExpr(RequiresExpr *E) {
1133  LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
1135  }
1136 
1137  bool TransformRequiresExprRequirements(
1140  bool SatisfactionDetermined = false;
1141  for (concepts::Requirement *Req : Reqs) {
1142  concepts::Requirement *TransReq = nullptr;
1143  if (!SatisfactionDetermined) {
1144  if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
1145  TransReq = TransformTypeRequirement(TypeReq);
1146  else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
1147  TransReq = TransformExprRequirement(ExprReq);
1148  else
1149  TransReq = TransformNestedRequirement(
1150  cast<concepts::NestedRequirement>(Req));
1151  if (!TransReq)
1152  return true;
1153  if (!TransReq->isDependent() && !TransReq->isSatisfied())
1154  // [expr.prim.req]p6
1155  // [...] The substitution and semantic constraint checking
1156  // proceeds in lexical order and stops when a condition that
1157  // determines the result of the requires-expression is
1158  // encountered. [..]
1159  SatisfactionDetermined = true;
1160  } else
1161  TransReq = Req;
1162  Transformed.push_back(TransReq);
1163  }
1164  return false;
1165  }
1166 
1167  TemplateParameterList *TransformTemplateParameterList(
1168  TemplateParameterList *OrigTPL) {
1169  if (!OrigTPL || !OrigTPL->size()) return OrigTPL;
1170 
1171  DeclContext *Owner = OrigTPL->getParam(0)->getDeclContext();
1172  TemplateDeclInstantiator DeclInstantiator(getSema(),
1173  /* DeclContext *Owner */ Owner, TemplateArgs);
1174  return DeclInstantiator.SubstTemplateParams(OrigTPL);
1175  }
1176 
1178  TransformTypeRequirement(concepts::TypeRequirement *Req);
1180  TransformExprRequirement(concepts::ExprRequirement *Req);
1182  TransformNestedRequirement(concepts::NestedRequirement *Req);
1183 
1184  private:
1185  ExprResult transformNonTypeTemplateParmRef(NonTypeTemplateParmDecl *parm,
1186  SourceLocation loc,
1188  };
1189 }
1190 
1191 bool TemplateInstantiator::AlreadyTransformed(QualType T) {
1192  if (T.isNull())
1193  return true;
1194 
1196  return false;
1197 
1198  getSema().MarkDeclarationsReferencedInType(Loc, T);
1199  return true;
1200 }
1201 
1202 static TemplateArgument
1204  assert(S.ArgumentPackSubstitutionIndex >= 0);
1205  assert(S.ArgumentPackSubstitutionIndex < (int)Arg.pack_size());
1207  if (Arg.isPackExpansion())
1208  Arg = Arg.getPackExpansionPattern();
1209  return Arg;
1210 }
1211 
1212 Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) {
1213  if (!D)
1214  return nullptr;
1215 
1216  if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
1217  if (TTP->getDepth() < TemplateArgs.getNumLevels()) {
1218  // If the corresponding template argument is NULL or non-existent, it's
1219  // because we are performing instantiation from explicitly-specified
1220  // template arguments in a function template, but there were some
1221  // arguments left unspecified.
1222  if (!TemplateArgs.hasTemplateArgument(TTP->getDepth(),
1223  TTP->getPosition()))
1224  return D;
1225 
1226  TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
1227 
1228  if (TTP->isParameterPack()) {
1229  assert(Arg.getKind() == TemplateArgument::Pack &&
1230  "Missing argument pack");
1231  Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
1232  }
1233 
1234  TemplateName Template = Arg.getAsTemplate().getNameToSubstitute();
1235  assert(!Template.isNull() && Template.getAsTemplateDecl() &&
1236  "Wrong kind of template template argument");
1237  return Template.getAsTemplateDecl();
1238  }
1239 
1240  // Fall through to find the instantiated declaration for this template
1241  // template parameter.
1242  }
1243 
1244  return SemaRef.FindInstantiatedDecl(Loc, cast<NamedDecl>(D), TemplateArgs);
1245 }
1246 
1247 Decl *TemplateInstantiator::TransformDefinition(SourceLocation Loc, Decl *D) {
1248  Decl *Inst = getSema().SubstDecl(D, getSema().CurContext, TemplateArgs);
1249  if (!Inst)
1250  return nullptr;
1251 
1252  getSema().CurrentInstantiationScope->InstantiatedLocal(D, Inst);
1253  return Inst;
1254 }
1255 
1256 NamedDecl *
1257 TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D,
1258  SourceLocation Loc) {
1259  // If the first part of the nested-name-specifier was a template type
1260  // parameter, instantiate that type parameter down to a tag type.
1261  if (TemplateTypeParmDecl *TTPD = dyn_cast_or_null<TemplateTypeParmDecl>(D)) {
1262  const TemplateTypeParmType *TTP
1263  = cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD));
1264 
1265  if (TTP->getDepth() < TemplateArgs.getNumLevels()) {
1266  // FIXME: This needs testing w/ member access expressions.
1267  TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getIndex());
1268 
1269  if (TTP->isParameterPack()) {
1270  assert(Arg.getKind() == TemplateArgument::Pack &&
1271  "Missing argument pack");
1272 
1273  if (getSema().ArgumentPackSubstitutionIndex == -1)
1274  return nullptr;
1275 
1276  Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
1277  }
1278 
1279  QualType T = Arg.getAsType();
1280  if (T.isNull())
1281  return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
1282 
1283  if (const TagType *Tag = T->getAs<TagType>())
1284  return Tag->getDecl();
1285 
1286  // The resulting type is not a tag; complain.
1287  getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) << T;
1288  return nullptr;
1289  }
1290  }
1291 
1292  return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
1293 }
1294 
1295 VarDecl *
1296 TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
1298  SourceLocation StartLoc,
1299  SourceLocation NameLoc,
1300  IdentifierInfo *Name) {
1301  VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, Declarator,
1302  StartLoc, NameLoc, Name);
1303  if (Var)
1304  getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
1305  return Var;
1306 }
1307 
1308 VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
1309  TypeSourceInfo *TSInfo,
1310  QualType T) {
1311  VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo, T);
1312  if (Var)
1313  getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
1314  return Var;
1315 }
1316 
1317 QualType
1318 TemplateInstantiator::RebuildElaboratedType(SourceLocation KeywordLoc,
1319  ElaboratedTypeKeyword Keyword,
1320  NestedNameSpecifierLoc QualifierLoc,
1321  QualType T) {
1322  if (const TagType *TT = T->getAs<TagType>()) {
1323  TagDecl* TD = TT->getDecl();
1324 
1325  SourceLocation TagLocation = KeywordLoc;
1326 
1327  IdentifierInfo *Id = TD->getIdentifier();
1328 
1329  // TODO: should we even warn on struct/class mismatches for this? Seems
1330  // like it's likely to produce a lot of spurious errors.
1331  if (Id && Keyword != ETK_None && Keyword != ETK_Typename) {
1333  if (!SemaRef.isAcceptableTagRedeclaration(TD, Kind, /*isDefinition*/false,
1334  TagLocation, Id)) {
1335  SemaRef.Diag(TagLocation, diag::err_use_with_wrong_tag)
1336  << Id
1337  << FixItHint::CreateReplacement(SourceRange(TagLocation),
1338  TD->getKindName());
1339  SemaRef.Diag(TD->getLocation(), diag::note_previous_use);
1340  }
1341  }
1342  }
1343 
1345  Keyword,
1346  QualifierLoc,
1347  T);
1348 }
1349 
1350 TemplateName TemplateInstantiator::TransformTemplateName(
1351  CXXScopeSpec &SS, TemplateName Name, SourceLocation NameLoc,
1352  QualType ObjectType, NamedDecl *FirstQualifierInScope,
1353  bool AllowInjectedClassName) {
1354  if (TemplateTemplateParmDecl *TTP
1355  = dyn_cast_or_null<TemplateTemplateParmDecl>(Name.getAsTemplateDecl())) {
1356  if (TTP->getDepth() < TemplateArgs.getNumLevels()) {
1357  // If the corresponding template argument is NULL or non-existent, it's
1358  // because we are performing instantiation from explicitly-specified
1359  // template arguments in a function template, but there were some
1360  // arguments left unspecified.
1361  if (!TemplateArgs.hasTemplateArgument(TTP->getDepth(),
1362  TTP->getPosition()))
1363  return Name;
1364 
1365  TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
1366 
1367  if (TemplateArgs.isRewrite()) {
1368  // We're rewriting the template parameter as a reference to another
1369  // template parameter.
1370  if (Arg.getKind() == TemplateArgument::Pack) {
1371  assert(Arg.pack_size() == 1 && Arg.pack_begin()->isPackExpansion() &&
1372  "unexpected pack arguments in template rewrite");
1373  Arg = Arg.pack_begin()->getPackExpansionPattern();
1374  }
1375  assert(Arg.getKind() == TemplateArgument::Template &&
1376  "unexpected nontype template argument kind in template rewrite");
1377  return Arg.getAsTemplate();
1378  }
1379 
1380  if (TTP->isParameterPack()) {
1381  assert(Arg.getKind() == TemplateArgument::Pack &&
1382  "Missing argument pack");
1383 
1384  if (getSema().ArgumentPackSubstitutionIndex == -1) {
1385  // We have the template argument pack to substitute, but we're not
1386  // actually expanding the enclosing pack expansion yet. So, just
1387  // keep the entire argument pack.
1388  return getSema().Context.getSubstTemplateTemplateParmPack(TTP, Arg);
1389  }
1390 
1391  Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
1392  }
1393 
1394  TemplateName Template = Arg.getAsTemplate().getNameToSubstitute();
1395  assert(!Template.isNull() && "Null template template argument");
1396  assert(!Template.getAsQualifiedTemplateName() &&
1397  "template decl to substitute is qualified?");
1398 
1399  Template = getSema().Context.getSubstTemplateTemplateParm(TTP, Template);
1400  return Template;
1401  }
1402  }
1403 
1405  = Name.getAsSubstTemplateTemplateParmPack()) {
1406  if (getSema().ArgumentPackSubstitutionIndex == -1)
1407  return Name;
1408 
1409  TemplateArgument Arg = SubstPack->getArgumentPack();
1410  Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
1411  return Arg.getAsTemplate().getNameToSubstitute();
1412  }
1413 
1414  return inherited::TransformTemplateName(SS, Name, NameLoc, ObjectType,
1415  FirstQualifierInScope,
1416  AllowInjectedClassName);
1417 }
1418 
1419 ExprResult
1420 TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) {
1421  if (!E->isTypeDependent())
1422  return E;
1423 
1424  return getSema().BuildPredefinedExpr(E->getLocation(), E->getIdentKind());
1425 }
1426 
1427 ExprResult
1428 TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E,
1429  NonTypeTemplateParmDecl *NTTP) {
1430  // If the corresponding template argument is NULL or non-existent, it's
1431  // because we are performing instantiation from explicitly-specified
1432  // template arguments in a function template, but there were some
1433  // arguments left unspecified.
1434  if (!TemplateArgs.hasTemplateArgument(NTTP->getDepth(),
1435  NTTP->getPosition()))
1436  return E;
1437 
1438  TemplateArgument Arg = TemplateArgs(NTTP->getDepth(), NTTP->getPosition());
1439 
1440  if (TemplateArgs.isRewrite()) {
1441  // We're rewriting the template parameter as a reference to another
1442  // template parameter.
1443  if (Arg.getKind() == TemplateArgument::Pack) {
1444  assert(Arg.pack_size() == 1 && Arg.pack_begin()->isPackExpansion() &&
1445  "unexpected pack arguments in template rewrite");
1446  Arg = Arg.pack_begin()->getPackExpansionPattern();
1447  }
1448  assert(Arg.getKind() == TemplateArgument::Expression &&
1449  "unexpected nontype template argument kind in template rewrite");
1450  // FIXME: This can lead to the same subexpression appearing multiple times
1451  // in a complete expression.
1452  return Arg.getAsExpr();
1453  }
1454 
1455  if (NTTP->isParameterPack()) {
1456  assert(Arg.getKind() == TemplateArgument::Pack &&
1457  "Missing argument pack");
1458 
1459  if (getSema().ArgumentPackSubstitutionIndex == -1) {
1460  // We have an argument pack, but we can't select a particular argument
1461  // out of it yet. Therefore, we'll build an expression to hold on to that
1462  // argument pack.
1463  QualType TargetType = SemaRef.SubstType(NTTP->getType(), TemplateArgs,
1464  E->getLocation(),
1465  NTTP->getDeclName());
1466  if (TargetType.isNull())
1467  return ExprError();
1468 
1469  QualType ExprType = TargetType.getNonLValueExprType(SemaRef.Context);
1470  if (TargetType->isRecordType())
1471  ExprType.addConst();
1472 
1473  return new (SemaRef.Context) SubstNonTypeTemplateParmPackExpr(
1474  ExprType, TargetType->isReferenceType() ? VK_LValue : VK_PRValue,
1475  NTTP, E->getLocation(), Arg);
1476  }
1477 
1478  Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
1479  }
1480 
1481  return transformNonTypeTemplateParmRef(NTTP, E->getLocation(), Arg);
1482 }
1483 
1484 const LoopHintAttr *
1485 TemplateInstantiator::TransformLoopHintAttr(const LoopHintAttr *LH) {
1486  Expr *TransformedExpr = getDerived().TransformExpr(LH->getValue()).get();
1487 
1488  if (TransformedExpr == LH->getValue())
1489  return LH;
1490 
1491  // Generate error if there is a problem with the value.
1492  if (getSema().CheckLoopHintExpr(TransformedExpr, LH->getLocation()))
1493  return LH;
1494 
1495  // Create new LoopHintValueAttr with integral expression in place of the
1496  // non-type template parameter.
1497  return LoopHintAttr::CreateImplicit(getSema().Context, LH->getOption(),
1498  LH->getState(), TransformedExpr, *LH);
1499 }
1500 
1501 ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef(
1503  SourceLocation loc,
1505  ExprResult result;
1506 
1507  // Determine the substituted parameter type. We can usually infer this from
1508  // the template argument, but not always.
1509  auto SubstParamType = [&] {
1510  QualType T;
1511  if (parm->isExpandedParameterPack())
1513  else
1514  T = parm->getType();
1515  if (parm->isParameterPack() && isa<PackExpansionType>(T))
1516  T = cast<PackExpansionType>(T)->getPattern();
1517  return SemaRef.SubstType(T, TemplateArgs, loc, parm->getDeclName());
1518  };
1519 
1520  bool refParam = false;
1521 
1522  // The template argument itself might be an expression, in which case we just
1523  // return that expression. This happens when substituting into an alias
1524  // template.
1525  if (arg.getKind() == TemplateArgument::Expression) {
1526  Expr *argExpr = arg.getAsExpr();
1527  result = argExpr;
1528  if (argExpr->isLValue()) {
1529  if (argExpr->getType()->isRecordType()) {
1530  // Check whether the parameter was actually a reference.
1531  QualType paramType = SubstParamType();
1532  if (paramType.isNull())
1533  return ExprError();
1534  refParam = paramType->isReferenceType();
1535  } else {
1536  refParam = true;
1537  }
1538  }
1539  } else if (arg.getKind() == TemplateArgument::Declaration ||
1540  arg.getKind() == TemplateArgument::NullPtr) {
1541  ValueDecl *VD;
1542  if (arg.getKind() == TemplateArgument::Declaration) {
1543  VD = arg.getAsDecl();
1544 
1545  // Find the instantiation of the template argument. This is
1546  // required for nested templates.
1547  VD = cast_or_null<ValueDecl>(
1548  getSema().FindInstantiatedDecl(loc, VD, TemplateArgs));
1549  if (!VD)
1550  return ExprError();
1551  } else {
1552  // Propagate NULL template argument.
1553  VD = nullptr;
1554  }
1555 
1556  QualType paramType = VD ? arg.getParamTypeForDecl() : arg.getNullPtrType();
1557  assert(!paramType.isNull() && "type substitution failed for param type");
1558  assert(!paramType->isDependentType() && "param type still dependent");
1559  result = SemaRef.BuildExpressionFromDeclTemplateArgument(arg, paramType, loc);
1560  refParam = paramType->isReferenceType();
1561  } else {
1562  result = SemaRef.BuildExpressionFromIntegralTemplateArgument(arg, loc);
1563  assert(result.isInvalid() ||
1564  SemaRef.Context.hasSameType(result.get()->getType(),
1565  arg.getIntegralType()));
1566  }
1567 
1568  if (result.isInvalid())
1569  return ExprError();
1570 
1571  Expr *resultExpr = result.get();
1572  return new (SemaRef.Context) SubstNonTypeTemplateParmExpr(
1573  resultExpr->getType(), resultExpr->getValueKind(), loc, parm, refParam,
1574  resultExpr);
1575 }
1576 
1577 ExprResult
1578 TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr(
1580  if (getSema().ArgumentPackSubstitutionIndex == -1) {
1581  // We aren't expanding the parameter pack, so just return ourselves.
1582  return E;
1583  }
1584 
1585  TemplateArgument Arg = E->getArgumentPack();
1586  Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
1587  return transformNonTypeTemplateParmRef(E->getParameterPack(),
1589  Arg);
1590 }
1591 
1592 ExprResult
1593 TemplateInstantiator::TransformSubstNonTypeTemplateParmExpr(
1595  ExprResult SubstReplacement = E->getReplacement();
1596  if (!isa<ConstantExpr>(SubstReplacement.get()))
1597  SubstReplacement = TransformExpr(E->getReplacement());
1598  if (SubstReplacement.isInvalid())
1599  return true;
1600  QualType SubstType = TransformType(E->getParameterType(getSema().Context));
1601  if (SubstType.isNull())
1602  return true;
1603  // The type may have been previously dependent and not now, which means we
1604  // might have to implicit cast the argument to the new type, for example:
1605  // template<auto T, decltype(T) U>
1606  // concept C = sizeof(U) == 4;
1607  // void foo() requires C<2, 'a'> { }
1608  // When normalizing foo(), we first form the normalized constraints of C:
1609  // AtomicExpr(sizeof(U) == 4,
1610  // U=SubstNonTypeTemplateParmExpr(Param=U,
1611  // Expr=DeclRef(U),
1612  // Type=decltype(T)))
1613  // Then we substitute T = 2, U = 'a' into the parameter mapping, and need to
1614  // produce:
1615  // AtomicExpr(sizeof(U) == 4,
1616  // U=SubstNonTypeTemplateParmExpr(Param=U,
1617  // Expr=ImpCast(
1618  // decltype(2),
1619  // SubstNTTPE(Param=U, Expr='a',
1620  // Type=char)),
1621  // Type=decltype(2)))
1622  // The call to CheckTemplateArgument here produces the ImpCast.
1623  TemplateArgument Converted;
1624  if (SemaRef.CheckTemplateArgument(E->getParameter(), SubstType,
1625  SubstReplacement.get(),
1626  Converted).isInvalid())
1627  return true;
1628  return transformNonTypeTemplateParmRef(E->getParameter(),
1629  E->getExprLoc(), Converted);
1630 }
1631 
1632 ExprResult TemplateInstantiator::RebuildVarDeclRefExpr(VarDecl *PD,
1633  SourceLocation Loc) {
1634  DeclarationNameInfo NameInfo(PD->getDeclName(), Loc);
1635  return getSema().BuildDeclarationNameExpr(CXXScopeSpec(), NameInfo, PD);
1636 }
1637 
1638 ExprResult
1639 TemplateInstantiator::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
1640  if (getSema().ArgumentPackSubstitutionIndex != -1) {
1641  // We can expand this parameter pack now.
1643  VarDecl *VD = cast_or_null<VarDecl>(TransformDecl(E->getExprLoc(), D));
1644  if (!VD)
1645  return ExprError();
1646  return RebuildVarDeclRefExpr(VD, E->getExprLoc());
1647  }
1648 
1649  QualType T = TransformType(E->getType());
1650  if (T.isNull())
1651  return ExprError();
1652 
1653  // Transform each of the parameter expansions into the corresponding
1654  // parameters in the instantiation of the function decl.
1656  Vars.reserve(E->getNumExpansions());
1657  for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
1658  I != End; ++I) {
1659  VarDecl *D = cast_or_null<VarDecl>(TransformDecl(E->getExprLoc(), *I));
1660  if (!D)
1661  return ExprError();
1662  Vars.push_back(D);
1663  }
1664 
1665  auto *PackExpr =
1667  E->getParameterPackLocation(), Vars);
1668  getSema().MarkFunctionParmPackReferenced(PackExpr);
1669  return PackExpr;
1670 }
1671 
1672 ExprResult
1673 TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E,
1674  VarDecl *PD) {
1675  typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
1676  llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
1677  = getSema().CurrentInstantiationScope->findInstantiationOf(PD);
1678  assert(Found && "no instantiation for parameter pack");
1679 
1680  Decl *TransformedDecl;
1681  if (DeclArgumentPack *Pack = Found->dyn_cast<DeclArgumentPack *>()) {
1682  // If this is a reference to a function parameter pack which we can
1683  // substitute but can't yet expand, build a FunctionParmPackExpr for it.
1684  if (getSema().ArgumentPackSubstitutionIndex == -1) {
1685  QualType T = TransformType(E->getType());
1686  if (T.isNull())
1687  return ExprError();
1688  auto *PackExpr = FunctionParmPackExpr::Create(getSema().Context, T, PD,
1689  E->getExprLoc(), *Pack);
1690  getSema().MarkFunctionParmPackReferenced(PackExpr);
1691  return PackExpr;
1692  }
1693 
1694  TransformedDecl = (*Pack)[getSema().ArgumentPackSubstitutionIndex];
1695  } else {
1696  TransformedDecl = Found->get<Decl*>();
1697  }
1698 
1699  // We have either an unexpanded pack or a specific expansion.
1700  return RebuildVarDeclRefExpr(cast<VarDecl>(TransformedDecl), E->getExprLoc());
1701 }
1702 
1703 ExprResult
1704 TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
1705  NamedDecl *D = E->getDecl();
1706 
1707  // Handle references to non-type template parameters and non-type template
1708  // parameter packs.
1709  if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
1710  if (NTTP->getDepth() < TemplateArgs.getNumLevels())
1711  return TransformTemplateParmRefExpr(E, NTTP);
1712 
1713  // We have a non-type template parameter that isn't fully substituted;
1714  // FindInstantiatedDecl will find it in the local instantiation scope.
1715  }
1716 
1717  // Handle references to function parameter packs.
1718  if (VarDecl *PD = dyn_cast<VarDecl>(D))
1719  if (PD->isParameterPack())
1720  return TransformFunctionParmPackRefExpr(E, PD);
1721 
1723 }
1724 
1725 ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
1726  CXXDefaultArgExpr *E) {
1727  assert(!cast<FunctionDecl>(E->getParam()->getDeclContext())->
1728  getDescribedFunctionTemplate() &&
1729  "Default arg expressions are never formed in dependent cases.");
1730  return SemaRef.BuildCXXDefaultArgExpr(E->getUsedLocation(),
1731  cast<FunctionDecl>(E->getParam()->getDeclContext()),
1732  E->getParam());
1733 }
1734 
1735 template<typename Fn>
1736 QualType TemplateInstantiator::TransformFunctionProtoType(TypeLocBuilder &TLB,
1738  CXXRecordDecl *ThisContext,
1739  Qualifiers ThisTypeQuals,
1740  Fn TransformExceptionSpec) {
1741  // We need a local instantiation scope for this function prototype.
1742  LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
1743  return inherited::TransformFunctionProtoType(
1744  TLB, TL, ThisContext, ThisTypeQuals, TransformExceptionSpec);
1745 }
1746 
1747 ParmVarDecl *
1748 TemplateInstantiator::TransformFunctionTypeParam(ParmVarDecl *OldParm,
1749  int indexAdjustment,
1750  Optional<unsigned> NumExpansions,
1751  bool ExpectParameterPack) {
1752  auto NewParm =
1753  SemaRef.SubstParmVarDecl(OldParm, TemplateArgs, indexAdjustment,
1754  NumExpansions, ExpectParameterPack);
1755  if (NewParm && SemaRef.getLangOpts().OpenCL)
1756  SemaRef.deduceOpenCLAddressSpace(NewParm);
1757  return NewParm;
1758 }
1759 
1760 QualType
1761 TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
1763  const TemplateTypeParmType *T = TL.getTypePtr();
1764  if (T->getDepth() < TemplateArgs.getNumLevels()) {
1765  // Replace the template type parameter with its corresponding
1766  // template argument.
1767 
1768  // If the corresponding template argument is NULL or doesn't exist, it's
1769  // because we are performing instantiation from explicitly-specified
1770  // template arguments in a function template class, but there were some
1771  // arguments left unspecified.
1772  if (!TemplateArgs.hasTemplateArgument(T->getDepth(), T->getIndex())) {
1774  = TLB.push<TemplateTypeParmTypeLoc>(TL.getType());
1775  NewTL.setNameLoc(TL.getNameLoc());
1776  return TL.getType();
1777  }
1778 
1779  TemplateArgument Arg = TemplateArgs(T->getDepth(), T->getIndex());
1780 
1781  if (TemplateArgs.isRewrite()) {
1782  // We're rewriting the template parameter as a reference to another
1783  // template parameter.
1784  if (Arg.getKind() == TemplateArgument::Pack) {
1785  assert(Arg.pack_size() == 1 && Arg.pack_begin()->isPackExpansion() &&
1786  "unexpected pack arguments in template rewrite");
1787  Arg = Arg.pack_begin()->getPackExpansionPattern();
1788  }
1789  assert(Arg.getKind() == TemplateArgument::Type &&
1790  "unexpected nontype template argument kind in template rewrite");
1791  QualType NewT = Arg.getAsType();
1792  assert(isa<TemplateTypeParmType>(NewT) &&
1793  "type parm not rewritten to type parm");
1794  auto NewTL = TLB.push<TemplateTypeParmTypeLoc>(NewT);
1795  NewTL.setNameLoc(TL.getNameLoc());
1796  return NewT;
1797  }
1798 
1799  if (T->isParameterPack()) {
1800  assert(Arg.getKind() == TemplateArgument::Pack &&
1801  "Missing argument pack");
1802 
1803  if (getSema().ArgumentPackSubstitutionIndex == -1) {
1804  // We have the template argument pack, but we're not expanding the
1805  // enclosing pack expansion yet. Just save the template argument
1806  // pack for later substitution.
1807  QualType Result
1808  = getSema().Context.getSubstTemplateTypeParmPackType(T, Arg);
1810  = TLB.push<SubstTemplateTypeParmPackTypeLoc>(Result);
1811  NewTL.setNameLoc(TL.getNameLoc());
1812  return Result;
1813  }
1814 
1815  Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
1816  }
1817 
1818  assert(Arg.getKind() == TemplateArgument::Type &&
1819  "Template argument kind mismatch");
1820 
1821  QualType Replacement = Arg.getAsType();
1822 
1823  // TODO: only do this uniquing once, at the start of instantiation.
1824  QualType Result
1825  = getSema().Context.getSubstTemplateTypeParmType(T, Replacement);
1827  = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
1828  NewTL.setNameLoc(TL.getNameLoc());
1829  return Result;
1830  }
1831 
1832  // The template type parameter comes from an inner template (e.g.,
1833  // the template parameter list of a member template inside the
1834  // template we are instantiating). Create a new template type
1835  // parameter with the template "level" reduced by one.
1836  TemplateTypeParmDecl *NewTTPDecl = nullptr;
1837  if (TemplateTypeParmDecl *OldTTPDecl = T->getDecl())
1838  NewTTPDecl = cast_or_null<TemplateTypeParmDecl>(
1839  TransformDecl(TL.getNameLoc(), OldTTPDecl));
1840 
1841  QualType Result = getSema().Context.getTemplateTypeParmType(
1842  T->getDepth() - TemplateArgs.getNumSubstitutedLevels(), T->getIndex(),
1843  T->isParameterPack(), NewTTPDecl);
1845  NewTL.setNameLoc(TL.getNameLoc());
1846  return Result;
1847 }
1848 
1849 QualType
1850 TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
1851  TypeLocBuilder &TLB,
1853  if (getSema().ArgumentPackSubstitutionIndex == -1) {
1854  // We aren't expanding the parameter pack, so just return ourselves.
1857  NewTL.setNameLoc(TL.getNameLoc());
1858  return TL.getType();
1859  }
1860 
1862  Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
1863  QualType Result = Arg.getAsType();
1864 
1865  Result = getSema().Context.getSubstTemplateTypeParmType(
1867  Result);
1869  = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
1870  NewTL.setNameLoc(TL.getNameLoc());
1871  return Result;
1872 }
1873 
1874 template<typename EntityPrinter>
1876 createSubstDiag(Sema &S, TemplateDeductionInfo &Info, EntityPrinter Printer) {
1877  SmallString<128> Message;
1878  SourceLocation ErrorLoc;
1879  if (Info.hasSFINAEDiagnostic()) {
1882  Info.takeSFINAEDiagnostic(PDA);
1883  PDA.second.EmitToString(S.getDiagnostics(), Message);
1884  ErrorLoc = PDA.first;
1885  } else {
1886  ErrorLoc = Info.getLocation();
1887  }
1888  char *MessageBuf = new (S.Context) char[Message.size()];
1889  std::copy(Message.begin(), Message.end(), MessageBuf);
1890  SmallString<128> Entity;
1891  llvm::raw_svector_ostream OS(Entity);
1892  Printer(OS);
1893  char *EntityBuf = new (S.Context) char[Entity.size()];
1894  std::copy(Entity.begin(), Entity.end(), EntityBuf);
1896  StringRef(EntityBuf, Entity.size()), ErrorLoc,
1897  StringRef(MessageBuf, Message.size())};
1898 }
1899 
1901 TemplateInstantiator::TransformTypeRequirement(concepts::TypeRequirement *Req) {
1902  if (!Req->isDependent() && !AlwaysRebuild())
1903  return Req;
1904  if (Req->isSubstitutionFailure()) {
1905  if (AlwaysRebuild())
1906  return RebuildTypeRequirement(
1907  Req->getSubstitutionDiagnostic());
1908  return Req;
1909  }
1910 
1911  Sema::SFINAETrap Trap(SemaRef);
1913  Sema::InstantiatingTemplate TypeInst(SemaRef,
1914  Req->getType()->getTypeLoc().getBeginLoc(), Req, Info,
1915  Req->getType()->getTypeLoc().getSourceRange());
1916  if (TypeInst.isInvalid())
1917  return nullptr;
1918  TypeSourceInfo *TransType = TransformType(Req->getType());
1919  if (!TransType || Trap.hasErrorOccurred())
1920  return RebuildTypeRequirement(createSubstDiag(SemaRef, Info,
1921  [&] (llvm::raw_ostream& OS) {
1922  Req->getType()->getType().print(OS, SemaRef.getPrintingPolicy());
1923  }));
1924  return RebuildTypeRequirement(TransType);
1925 }
1926 
1928 TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
1929  if (!Req->isDependent() && !AlwaysRebuild())
1930  return Req;
1931 
1932  Sema::SFINAETrap Trap(SemaRef);
1933 
1934  llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *>
1935  TransExpr;
1936  if (Req->isExprSubstitutionFailure())
1937  TransExpr = Req->getExprSubstitutionDiagnostic();
1938  else {
1939  Expr *E = Req->getExpr();
1941  Sema::InstantiatingTemplate ExprInst(SemaRef, E->getBeginLoc(), Req, Info,
1942  E->getSourceRange());
1943  if (ExprInst.isInvalid())
1944  return nullptr;
1945  ExprResult TransExprRes = TransformExpr(E);
1946  if (TransExprRes.isInvalid() || Trap.hasErrorOccurred())
1947  TransExpr = createSubstDiag(SemaRef, Info, [&](llvm::raw_ostream &OS) {
1948  E->printPretty(OS, nullptr, SemaRef.getPrintingPolicy());
1949  });
1950  else
1951  TransExpr = TransExprRes.get();
1952  }
1953 
1955  const auto &RetReq = Req->getReturnTypeRequirement();
1956  if (RetReq.isEmpty())
1957  TransRetReq.emplace();
1958  else if (RetReq.isSubstitutionFailure())
1959  TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
1960  else if (RetReq.isTypeConstraint()) {
1961  TemplateParameterList *OrigTPL =
1962  RetReq.getTypeConstraintTemplateParameterList();
1963  TemplateDeductionInfo Info(OrigTPL->getTemplateLoc());
1964  Sema::InstantiatingTemplate TPLInst(SemaRef, OrigTPL->getTemplateLoc(),
1965  Req, Info, OrigTPL->getSourceRange());
1966  if (TPLInst.isInvalid())
1967  return nullptr;
1968  TemplateParameterList *TPL =
1969  TransformTemplateParameterList(OrigTPL);
1970  if (!TPL)
1971  TransRetReq.emplace(createSubstDiag(SemaRef, Info,
1972  [&] (llvm::raw_ostream& OS) {
1973  RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
1974  ->printPretty(OS, nullptr, SemaRef.getPrintingPolicy());
1975  }));
1976  else {
1977  TPLInst.Clear();
1978  TransRetReq.emplace(TPL);
1979  }
1980  }
1981  assert(TransRetReq.hasValue() &&
1982  "All code paths leading here must set TransRetReq");
1983  if (Expr *E = TransExpr.dyn_cast<Expr *>())
1984  return RebuildExprRequirement(E, Req->isSimple(), Req->getNoexceptLoc(),
1985  std::move(*TransRetReq));
1986  return RebuildExprRequirement(
1988  Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
1989 }
1990 
1992 TemplateInstantiator::TransformNestedRequirement(
1994  if (!Req->isDependent() && !AlwaysRebuild())
1995  return Req;
1996  if (Req->isSubstitutionFailure()) {
1997  if (AlwaysRebuild())
1998  return RebuildNestedRequirement(
1999  Req->getSubstitutionDiagnostic());
2000  return Req;
2001  }
2002  Sema::InstantiatingTemplate ReqInst(SemaRef,
2003  Req->getConstraintExpr()->getBeginLoc(), Req,
2005  Req->getConstraintExpr()->getSourceRange());
2006 
2007  ExprResult TransConstraint;
2009  {
2012  Sema::SFINAETrap Trap(SemaRef);
2013  Sema::InstantiatingTemplate ConstrInst(SemaRef,
2014  Req->getConstraintExpr()->getBeginLoc(), Req, Info,
2015  Req->getConstraintExpr()->getSourceRange());
2016  if (ConstrInst.isInvalid())
2017  return nullptr;
2018  TransConstraint = TransformExpr(Req->getConstraintExpr());
2019  if (TransConstraint.isInvalid() || Trap.hasErrorOccurred())
2020  return RebuildNestedRequirement(createSubstDiag(SemaRef, Info,
2021  [&] (llvm::raw_ostream& OS) {
2022  Req->getConstraintExpr()->printPretty(OS, nullptr,
2023  SemaRef.getPrintingPolicy());
2024  }));
2025  }
2026  return RebuildNestedRequirement(TransConstraint.get());
2027 }
2028 
2029 
2030 /// Perform substitution on the type T with a given set of template
2031 /// arguments.
2032 ///
2033 /// This routine substitutes the given template arguments into the
2034 /// type T and produces the instantiated type.
2035 ///
2036 /// \param T the type into which the template arguments will be
2037 /// substituted. If this type is not dependent, it will be returned
2038 /// immediately.
2039 ///
2040 /// \param Args the template arguments that will be
2041 /// substituted for the top-level template parameters within T.
2042 ///
2043 /// \param Loc the location in the source code where this substitution
2044 /// is being performed. It will typically be the location of the
2045 /// declarator (if we're instantiating the type of some declaration)
2046 /// or the location of the type in the source code (if, e.g., we're
2047 /// instantiating the type of a cast expression).
2048 ///
2049 /// \param Entity the name of the entity associated with a declaration
2050 /// being instantiated (if any). May be empty to indicate that there
2051 /// is no such entity (if, e.g., this is a type that occurs as part of
2052 /// a cast expression) or that the entity has no name (e.g., an
2053 /// unnamed function parameter).
2054 ///
2055 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
2056 /// acceptable as the top level type of the result.
2057 ///
2058 /// \returns If the instantiation succeeds, the instantiated
2059 /// type. Otherwise, produces diagnostics and returns a NULL type.
2061  const MultiLevelTemplateArgumentList &Args,
2062  SourceLocation Loc,
2063  DeclarationName Entity,
2064  bool AllowDeducedTST) {
2065  assert(!CodeSynthesisContexts.empty() &&
2066  "Cannot perform an instantiation without some context on the "
2067  "instantiation stack");
2068 
2069  if (!T->getType()->isInstantiationDependentType() &&
2071  return T;
2072 
2073  TemplateInstantiator Instantiator(*this, Args, Loc, Entity);
2074  return AllowDeducedTST ? Instantiator.TransformTypeWithDeducedTST(T)
2075  : Instantiator.TransformType(T);
2076 }
2077 
2079  const MultiLevelTemplateArgumentList &Args,
2080  SourceLocation Loc,
2081  DeclarationName Entity) {
2082  assert(!CodeSynthesisContexts.empty() &&
2083  "Cannot perform an instantiation without some context on the "
2084  "instantiation stack");
2085 
2086  if (TL.getType().isNull())
2087  return nullptr;
2088 
2089  if (!TL.getType()->isInstantiationDependentType() &&
2090  !TL.getType()->isVariablyModifiedType()) {
2091  // FIXME: Make a copy of the TypeLoc data here, so that we can
2092  // return a new TypeSourceInfo. Inefficient!
2093  TypeLocBuilder TLB;
2094  TLB.pushFullCopy(TL);
2095  return TLB.getTypeSourceInfo(Context, TL.getType());
2096  }
2097 
2098  TemplateInstantiator Instantiator(*this, Args, Loc, Entity);
2099  TypeLocBuilder TLB;
2100  TLB.reserve(TL.getFullDataSize());
2101  QualType Result = Instantiator.TransformType(TLB, TL);
2102  if (Result.isNull())
2103  return nullptr;
2104 
2105  return TLB.getTypeSourceInfo(Context, Result);
2106 }
2107 
2108 /// Deprecated form of the above.
2110  const MultiLevelTemplateArgumentList &TemplateArgs,
2111  SourceLocation Loc, DeclarationName Entity) {
2112  assert(!CodeSynthesisContexts.empty() &&
2113  "Cannot perform an instantiation without some context on the "
2114  "instantiation stack");
2115 
2116  // If T is not a dependent type or a variably-modified type, there
2117  // is nothing to do.
2119  return T;
2120 
2121  TemplateInstantiator Instantiator(*this, TemplateArgs, Loc, Entity);
2122  return Instantiator.TransformType(T);
2123 }
2124 
2126  if (T->getType()->isInstantiationDependentType() ||
2128  return true;
2129 
2130  TypeLoc TL = T->getTypeLoc().IgnoreParens();
2131  if (!TL.getAs<FunctionProtoTypeLoc>())
2132  return false;
2133 
2135  for (ParmVarDecl *P : FP.getParams()) {
2136  // This must be synthesized from a typedef.
2137  if (!P) continue;
2138 
2139  // If there are any parameters, a new TypeSourceInfo that refers to the
2140  // instantiated parameters must be built.
2141  return true;
2142  }
2143 
2144  return false;
2145 }
2146 
2147 /// A form of SubstType intended specifically for instantiating the
2148 /// type of a FunctionDecl. Its purpose is solely to force the
2149 /// instantiation of default-argument expressions and to avoid
2150 /// instantiating an exception-specification.
2152  const MultiLevelTemplateArgumentList &Args,
2153  SourceLocation Loc,
2154  DeclarationName Entity,
2155  CXXRecordDecl *ThisContext,
2156  Qualifiers ThisTypeQuals) {
2157  assert(!CodeSynthesisContexts.empty() &&
2158  "Cannot perform an instantiation without some context on the "
2159  "instantiation stack");
2160 
2162  return T;
2163 
2164  TemplateInstantiator Instantiator(*this, Args, Loc, Entity);
2165 
2166  TypeLocBuilder TLB;
2167 
2168  TypeLoc TL = T->getTypeLoc();
2169  TLB.reserve(TL.getFullDataSize());
2170 
2171  QualType Result;
2172 
2173  if (FunctionProtoTypeLoc Proto =
2175  // Instantiate the type, other than its exception specification. The
2176  // exception specification is instantiated in InitFunctionInstantiation
2177  // once we've built the FunctionDecl.
2178  // FIXME: Set the exception specification to EST_Uninstantiated here,
2179  // instead of rebuilding the function type again later.
2180  Result = Instantiator.TransformFunctionProtoType(
2181  TLB, Proto, ThisContext, ThisTypeQuals,
2183  bool &Changed) { return false; });
2184  } else {
2185  Result = Instantiator.TransformType(TLB, TL);
2186  }
2187  if (Result.isNull())
2188  return nullptr;
2189 
2190  return TLB.getTypeSourceInfo(Context, Result);
2191 }
2192 
2195  SmallVectorImpl<QualType> &ExceptionStorage,
2196  const MultiLevelTemplateArgumentList &Args) {
2197  assert(ESI.Type != EST_Uninstantiated);
2198 
2199  bool Changed = false;
2200  TemplateInstantiator Instantiator(*this, Args, Loc, DeclarationName());
2201  return Instantiator.TransformExceptionSpec(Loc, ESI, ExceptionStorage,
2202  Changed);
2203 }
2204 
2206  const MultiLevelTemplateArgumentList &Args) {
2208  Proto->getExtProtoInfo().ExceptionSpec;
2209 
2210  SmallVector<QualType, 4> ExceptionStorage;
2212  ESI, ExceptionStorage, Args))
2213  // On error, recover by dropping the exception specification.
2214  ESI.Type = EST_None;
2215 
2216  UpdateExceptionSpec(New, ESI);
2217 }
2218 
2219 namespace {
2220 
2221  struct GetContainedInventedTypeParmVisitor :
2222  public TypeVisitor<GetContainedInventedTypeParmVisitor,
2223  TemplateTypeParmDecl *> {
2224  using TypeVisitor<GetContainedInventedTypeParmVisitor,
2225  TemplateTypeParmDecl *>::Visit;
2226 
2227  TemplateTypeParmDecl *Visit(QualType T) {
2228  if (T.isNull())
2229  return nullptr;
2230  return Visit(T.getTypePtr());
2231  }
2232  // The deduced type itself.
2233  TemplateTypeParmDecl *VisitTemplateTypeParmType(
2234  const TemplateTypeParmType *T) {
2235  if (!T->getDecl() || !T->getDecl()->isImplicit())
2236  return nullptr;
2237  return T->getDecl();
2238  }
2239 
2240  // Only these types can contain 'auto' types, and subsequently be replaced
2241  // by references to invented parameters.
2242 
2243  TemplateTypeParmDecl *VisitElaboratedType(const ElaboratedType *T) {
2244  return Visit(T->getNamedType());
2245  }
2246 
2247  TemplateTypeParmDecl *VisitPointerType(const PointerType *T) {
2248  return Visit(T->getPointeeType());
2249  }
2250 
2251  TemplateTypeParmDecl *VisitBlockPointerType(const BlockPointerType *T) {
2252  return Visit(T->getPointeeType());
2253  }
2254 
2255  TemplateTypeParmDecl *VisitReferenceType(const ReferenceType *T) {
2256  return Visit(T->getPointeeTypeAsWritten());
2257  }
2258 
2259  TemplateTypeParmDecl *VisitMemberPointerType(const MemberPointerType *T) {
2260  return Visit(T->getPointeeType());
2261  }
2262 
2263  TemplateTypeParmDecl *VisitArrayType(const ArrayType *T) {
2264  return Visit(T->getElementType());
2265  }
2266 
2267  TemplateTypeParmDecl *VisitDependentSizedExtVectorType(
2268  const DependentSizedExtVectorType *T) {
2269  return Visit(T->getElementType());
2270  }
2271 
2272  TemplateTypeParmDecl *VisitVectorType(const VectorType *T) {
2273  return Visit(T->getElementType());
2274  }
2275 
2276  TemplateTypeParmDecl *VisitFunctionProtoType(const FunctionProtoType *T) {
2277  return VisitFunctionType(T);
2278  }
2279 
2280  TemplateTypeParmDecl *VisitFunctionType(const FunctionType *T) {
2281  return Visit(T->getReturnType());
2282  }
2283 
2284  TemplateTypeParmDecl *VisitParenType(const ParenType *T) {
2285  return Visit(T->getInnerType());
2286  }
2287 
2288  TemplateTypeParmDecl *VisitAttributedType(const AttributedType *T) {
2289  return Visit(T->getModifiedType());
2290  }
2291 
2292  TemplateTypeParmDecl *VisitMacroQualifiedType(const MacroQualifiedType *T) {
2293  return Visit(T->getUnderlyingType());
2294  }
2295 
2296  TemplateTypeParmDecl *VisitAdjustedType(const AdjustedType *T) {
2297  return Visit(T->getOriginalType());
2298  }
2299 
2300  TemplateTypeParmDecl *VisitPackExpansionType(const PackExpansionType *T) {
2301  return Visit(T->getPattern());
2302  }
2303  };
2304 
2305 } // namespace
2306 
2308  TemplateTypeParmDecl *Inst, const TypeConstraint *TC,
2309  const MultiLevelTemplateArgumentList &TemplateArgs) {
2310  const ASTTemplateArgumentListInfo *TemplArgInfo =
2312  TemplateArgumentListInfo InstArgs;
2313 
2314  if (TemplArgInfo) {
2315  InstArgs.setLAngleLoc(TemplArgInfo->LAngleLoc);
2316  InstArgs.setRAngleLoc(TemplArgInfo->RAngleLoc);
2317  if (SubstTemplateArguments(TemplArgInfo->arguments(), TemplateArgs,
2318  InstArgs))
2319  return true;
2320  }
2321  return AttachTypeConstraint(
2323  TC->getNamedConcept(), &InstArgs, Inst,
2324  Inst->isParameterPack()
2325  ? cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint())
2326  ->getEllipsisLoc()
2327  : SourceLocation());
2328 }
2329 
2331  const MultiLevelTemplateArgumentList &TemplateArgs,
2332  int indexAdjustment,
2333  Optional<unsigned> NumExpansions,
2334  bool ExpectParameterPack) {
2335  TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
2336  TypeSourceInfo *NewDI = nullptr;
2337 
2338  TypeLoc OldTL = OldDI->getTypeLoc();
2339  if (PackExpansionTypeLoc ExpansionTL = OldTL.getAs<PackExpansionTypeLoc>()) {
2340 
2341  // We have a function parameter pack. Substitute into the pattern of the
2342  // expansion.
2343  NewDI = SubstType(ExpansionTL.getPatternLoc(), TemplateArgs,
2344  OldParm->getLocation(), OldParm->getDeclName());
2345  if (!NewDI)
2346  return nullptr;
2347 
2348  if (NewDI->getType()->containsUnexpandedParameterPack()) {
2349  // We still have unexpanded parameter packs, which means that
2350  // our function parameter is still a function parameter pack.
2351  // Therefore, make its type a pack expansion type.
2352  NewDI = CheckPackExpansion(NewDI, ExpansionTL.getEllipsisLoc(),
2353  NumExpansions);
2354  } else if (ExpectParameterPack) {
2355  // We expected to get a parameter pack but didn't (because the type
2356  // itself is not a pack expansion type), so complain. This can occur when
2357  // the substitution goes through an alias template that "loses" the
2358  // pack expansion.
2359  Diag(OldParm->getLocation(),
2360  diag::err_function_parameter_pack_without_parameter_packs)
2361  << NewDI->getType();
2362  return nullptr;
2363  }
2364  } else {
2365  NewDI = SubstType(OldDI, TemplateArgs, OldParm->getLocation(),
2366  OldParm->getDeclName());
2367  }
2368 
2369  if (!NewDI)
2370  return nullptr;
2371 
2372  if (NewDI->getType()->isVoidType()) {
2373  Diag(OldParm->getLocation(), diag::err_param_with_void_type);
2374  return nullptr;
2375  }
2376 
2377  // In abbreviated templates, TemplateTypeParmDecls with possible
2378  // TypeConstraints are created when the parameter list is originally parsed.
2379  // The TypeConstraints can therefore reference other functions parameters in
2380  // the abbreviated function template, which is why we must instantiate them
2381  // here, when the instantiated versions of those referenced parameters are in
2382  // scope.
2383  if (TemplateTypeParmDecl *TTP =
2384  GetContainedInventedTypeParmVisitor().Visit(OldDI->getType())) {
2385  if (const TypeConstraint *TC = TTP->getTypeConstraint()) {
2386  auto *Inst = cast_or_null<TemplateTypeParmDecl>(
2387  FindInstantiatedDecl(TTP->getLocation(), TTP, TemplateArgs));
2388  // We will first get here when instantiating the abbreviated function
2389  // template's described function, but we might also get here later.
2390  // Make sure we do not instantiate the TypeConstraint more than once.
2391  if (Inst && !Inst->getTypeConstraint()) {
2392  // TODO: Concepts: do not instantiate the constraint (delayed constraint
2393  // substitution)
2394  if (SubstTypeConstraint(Inst, TC, TemplateArgs))
2395  return nullptr;
2396  }
2397  }
2398  }
2399 
2401  OldParm->getInnerLocStart(),
2402  OldParm->getLocation(),
2403  OldParm->getIdentifier(),
2404  NewDI->getType(), NewDI,
2405  OldParm->getStorageClass());
2406  if (!NewParm)
2407  return nullptr;
2408 
2409  // Mark the (new) default argument as uninstantiated (if any).
2410  if (OldParm->hasUninstantiatedDefaultArg()) {
2411  Expr *Arg = OldParm->getUninstantiatedDefaultArg();
2412  NewParm->setUninstantiatedDefaultArg(Arg);
2413  } else if (OldParm->hasUnparsedDefaultArg()) {
2414  NewParm->setUnparsedDefaultArg();
2415  UnparsedDefaultArgInstantiations[OldParm].push_back(NewParm);
2416  } else if (Expr *Arg = OldParm->getDefaultArg()) {
2417  FunctionDecl *OwningFunc = cast<FunctionDecl>(OldParm->getDeclContext());
2418  if (OwningFunc->isInLocalScopeForInstantiation()) {
2419  // Instantiate default arguments for methods of local classes (DR1484)
2420  // and non-defining declarations.
2421  Sema::ContextRAII SavedContext(*this, OwningFunc);
2422  LocalInstantiationScope Local(*this, true);
2423  ExprResult NewArg = SubstExpr(Arg, TemplateArgs);
2424  if (NewArg.isUsable()) {
2425  // It would be nice if we still had this.
2426  SourceLocation EqualLoc = NewArg.get()->getBeginLoc();
2427  ExprResult Result =
2428  ConvertParamDefaultArgument(NewParm, NewArg.get(), EqualLoc);
2429  if (Result.isInvalid())
2430  return nullptr;
2431 
2432  SetParamDefaultArgument(NewParm, Result.getAs<Expr>(), EqualLoc);
2433  }
2434  } else {
2435  // FIXME: if we non-lazily instantiated non-dependent default args for
2436  // non-dependent parameter types we could remove a bunch of duplicate
2437  // conversion warnings for such arguments.
2438  NewParm->setUninstantiatedDefaultArg(Arg);
2439  }
2440  }
2441 
2443 
2444  if (OldParm->isParameterPack() && !NewParm->isParameterPack()) {
2445  // Add the new parameter to the instantiated parameter pack.
2447  } else {
2448  // Introduce an Old -> New mapping
2449  CurrentInstantiationScope->InstantiatedLocal(OldParm, NewParm);
2450  }
2451 
2452  // FIXME: OldParm may come from a FunctionProtoType, in which case CurContext
2453  // can be anything, is this right ?
2454  NewParm->setDeclContext(CurContext);
2455 
2456  NewParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
2457  OldParm->getFunctionScopeIndex() + indexAdjustment);
2458 
2459  InstantiateAttrs(TemplateArgs, OldParm, NewParm);
2460 
2461  return NewParm;
2462 }
2463 
2464 /// Substitute the given template arguments into the given set of
2465 /// parameters, producing the set of parameter types that would be generated
2466 /// from such a substitution.
2469  const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
2470  const MultiLevelTemplateArgumentList &TemplateArgs,
2471  SmallVectorImpl<QualType> &ParamTypes,
2472  SmallVectorImpl<ParmVarDecl *> *OutParams,
2473  ExtParameterInfoBuilder &ParamInfos) {
2474  assert(!CodeSynthesisContexts.empty() &&
2475  "Cannot perform an instantiation without some context on the "
2476  "instantiation stack");
2477 
2478  TemplateInstantiator Instantiator(*this, TemplateArgs, Loc,
2479  DeclarationName());
2480  return Instantiator.TransformFunctionTypeParams(
2481  Loc, Params, nullptr, ExtParamInfos, ParamTypes, OutParams, ParamInfos);
2482 }
2483 
2484 /// Perform substitution on the base class specifiers of the
2485 /// given class template specialization.
2486 ///
2487 /// Produces a diagnostic and returns true on error, returns false and
2488 /// attaches the instantiated base classes to the class template
2489 /// specialization if successful.
2490 bool
2492  CXXRecordDecl *Pattern,
2493  const MultiLevelTemplateArgumentList &TemplateArgs) {
2494  bool Invalid = false;
2495  SmallVector<CXXBaseSpecifier*, 4> InstantiatedBases;
2496  for (const auto &Base : Pattern->bases()) {
2497  if (!Base.getType()->isDependentType()) {
2498  if (const CXXRecordDecl *RD = Base.getType()->getAsCXXRecordDecl()) {
2499  if (RD->isInvalidDecl())
2500  Instantiation->setInvalidDecl();
2501  }
2502  InstantiatedBases.push_back(new (Context) CXXBaseSpecifier(Base));
2503  continue;
2504  }
2505 
2506  SourceLocation EllipsisLoc;
2507  TypeSourceInfo *BaseTypeLoc;
2508  if (Base.isPackExpansion()) {
2509  // This is a pack expansion. See whether we should expand it now, or
2510  // wait until later.
2512  collectUnexpandedParameterPacks(Base.getTypeSourceInfo()->getTypeLoc(),
2513  Unexpanded);
2514  bool ShouldExpand = false;
2515  bool RetainExpansion = false;
2516  Optional<unsigned> NumExpansions;
2517  if (CheckParameterPacksForExpansion(Base.getEllipsisLoc(),
2518  Base.getSourceRange(),
2519  Unexpanded,
2520  TemplateArgs, ShouldExpand,
2521  RetainExpansion,
2522  NumExpansions)) {
2523  Invalid = true;
2524  continue;
2525  }
2526 
2527  // If we should expand this pack expansion now, do so.
2528  if (ShouldExpand) {
2529  for (unsigned I = 0; I != *NumExpansions; ++I) {
2530  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I);
2531 
2532  TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
2533  TemplateArgs,
2534  Base.getSourceRange().getBegin(),
2535  DeclarationName());
2536  if (!BaseTypeLoc) {
2537  Invalid = true;
2538  continue;
2539  }
2540 
2541  if (CXXBaseSpecifier *InstantiatedBase
2542  = CheckBaseSpecifier(Instantiation,
2543  Base.getSourceRange(),
2544  Base.isVirtual(),
2545  Base.getAccessSpecifierAsWritten(),
2546  BaseTypeLoc,
2547  SourceLocation()))
2548  InstantiatedBases.push_back(InstantiatedBase);
2549  else
2550  Invalid = true;
2551  }
2552 
2553  continue;
2554  }
2555 
2556  // The resulting base specifier will (still) be a pack expansion.
2557  EllipsisLoc = Base.getEllipsisLoc();
2558  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, -1);
2559  BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
2560  TemplateArgs,
2561  Base.getSourceRange().getBegin(),
2562  DeclarationName());
2563  } else {
2564  BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
2565  TemplateArgs,
2566  Base.getSourceRange().getBegin(),
2567  DeclarationName());
2568  }
2569 
2570  if (!BaseTypeLoc) {
2571  Invalid = true;
2572  continue;
2573  }
2574 
2575  if (CXXBaseSpecifier *InstantiatedBase
2576  = CheckBaseSpecifier(Instantiation,
2577  Base.getSourceRange(),
2578  Base.isVirtual(),
2579  Base.getAccessSpecifierAsWritten(),
2580  BaseTypeLoc,
2581  EllipsisLoc))
2582  InstantiatedBases.push_back(InstantiatedBase);
2583  else
2584  Invalid = true;
2585  }
2586 
2587  if (!Invalid && AttachBaseSpecifiers(Instantiation, InstantiatedBases))
2588  Invalid = true;
2589 
2590  return Invalid;
2591 }
2592 
2593 // Defined via #include from SemaTemplateInstantiateDecl.cpp
2594 namespace clang {
2595  namespace sema {
2597  const MultiLevelTemplateArgumentList &TemplateArgs);
2599  const Attr *At, ASTContext &C, Sema &S,
2600  const MultiLevelTemplateArgumentList &TemplateArgs);
2601  }
2602 }
2603 
2604 /// Instantiate the definition of a class from a given pattern.
2605 ///
2606 /// \param PointOfInstantiation The point of instantiation within the
2607 /// source code.
2608 ///
2609 /// \param Instantiation is the declaration whose definition is being
2610 /// instantiated. This will be either a class template specialization
2611 /// or a member class of a class template specialization.
2612 ///
2613 /// \param Pattern is the pattern from which the instantiation
2614 /// occurs. This will be either the declaration of a class template or
2615 /// the declaration of a member class of a class template.
2616 ///
2617 /// \param TemplateArgs The template arguments to be substituted into
2618 /// the pattern.
2619 ///
2620 /// \param TSK the kind of implicit or explicit instantiation to perform.
2621 ///
2622 /// \param Complain whether to complain if the class cannot be instantiated due
2623 /// to the lack of a definition.
2624 ///
2625 /// \returns true if an error occurred, false otherwise.
2626 bool
2628  CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
2629  const MultiLevelTemplateArgumentList &TemplateArgs,
2631  bool Complain) {
2632  CXXRecordDecl *PatternDef
2633  = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
2634  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Instantiation,
2635  Instantiation->getInstantiatedFromMemberClass(),
2636  Pattern, PatternDef, TSK, Complain))
2637  return true;
2638 
2639  llvm::TimeTraceScope TimeScope("InstantiateClass", [&]() {
2640  std::string Name;
2641  llvm::raw_string_ostream OS(Name);
2642  Instantiation->getNameForDiagnostic(OS, getPrintingPolicy(),
2643  /*Qualified=*/true);
2644  return Name;
2645  });
2646 
2647  Pattern = PatternDef;
2648 
2649  // Record the point of instantiation.
2650  if (MemberSpecializationInfo *MSInfo
2651  = Instantiation->getMemberSpecializationInfo()) {
2652  MSInfo->setTemplateSpecializationKind(TSK);
2653  MSInfo->setPointOfInstantiation(PointOfInstantiation);
2654  } else if (ClassTemplateSpecializationDecl *Spec
2655  = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
2656  Spec->setTemplateSpecializationKind(TSK);
2657  Spec->setPointOfInstantiation(PointOfInstantiation);
2658  }
2659 
2660  InstantiatingTemplate Inst(*this, PointOfInstantiation, Instantiation);
2661  if (Inst.isInvalid())
2662  return true;
2663  assert(!Inst.isAlreadyInstantiating() && "should have been caught by caller");
2664  PrettyDeclStackTraceEntry CrashInfo(Context, Instantiation, SourceLocation(),
2665  "instantiating class definition");
2666 
2667  // Enter the scope of this instantiation. We don't use
2668  // PushDeclContext because we don't have a scope.
2669  ContextRAII SavedContext(*this, Instantiation);
2672 
2673  // If this is an instantiation of a local class, merge this local
2674  // instantiation scope with the enclosing scope. Otherwise, every
2675  // instantiation of a class has its own local instantiation scope.
2676  bool MergeWithParentScope = !Instantiation->isDefinedOutsideFunctionOrMethod();
2677  LocalInstantiationScope Scope(*this, MergeWithParentScope);
2678 
2679  // Some class state isn't processed immediately but delayed till class
2680  // instantiation completes. We may not be ready to handle any delayed state
2681  // already on the stack as it might correspond to a different class, so save
2682  // it now and put it back later.
2683  SavePendingParsedClassStateRAII SavedPendingParsedClassState(*this);
2684 
2685  // Pull attributes from the pattern onto the instantiation.
2686  InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
2687 
2688  // Start the definition of this instantiation.
2689  Instantiation->startDefinition();
2690 
2691  // The instantiation is visible here, even if it was first declared in an
2692  // unimported module.
2693  Instantiation->setVisibleDespiteOwningModule();
2694 
2695  // FIXME: This loses the as-written tag kind for an explicit instantiation.
2696  Instantiation->setTagKind(Pattern->getTagKind());
2697 
2698  // Do substitution on the base class specifiers.
2699  if (SubstBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
2700  Instantiation->setInvalidDecl();
2701 
2702  TemplateDeclInstantiator Instantiator(*this, Instantiation, TemplateArgs);
2703  SmallVector<Decl*, 4> Fields;
2704  // Delay instantiation of late parsed attributes.
2705  LateInstantiatedAttrVec LateAttrs;
2706  Instantiator.enableLateAttributeInstantiation(&LateAttrs);
2707 
2708  bool MightHaveConstexprVirtualFunctions = false;
2709  for (auto *Member : Pattern->decls()) {
2710  // Don't instantiate members not belonging in this semantic context.
2711  // e.g. for:
2712  // @code
2713  // template <int i> class A {
2714  // class B *g;
2715  // };
2716  // @endcode
2717  // 'class B' has the template as lexical context but semantically it is
2718  // introduced in namespace scope.
2719  if (Member->getDeclContext() != Pattern)
2720  continue;
2721 
2722  // BlockDecls can appear in a default-member-initializer. They must be the
2723  // child of a BlockExpr, so we only know how to instantiate them from there.
2724  // Similarly, lambda closure types are recreated when instantiating the
2725  // corresponding LambdaExpr.
2726  if (isa<BlockDecl>(Member) ||
2727  (isa<CXXRecordDecl>(Member) && cast<CXXRecordDecl>(Member)->isLambda()))
2728  continue;
2729 
2730  if (Member->isInvalidDecl()) {
2731  Instantiation->setInvalidDecl();
2732  continue;
2733  }
2734 
2735  Decl *NewMember = Instantiator.Visit(Member);
2736  if (NewMember) {
2737  if (FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) {
2738  Fields.push_back(Field);
2739  } else if (EnumDecl *Enum = dyn_cast<EnumDecl>(NewMember)) {
2740  // C++11 [temp.inst]p1: The implicit instantiation of a class template
2741  // specialization causes the implicit instantiation of the definitions
2742  // of unscoped member enumerations.
2743  // Record a point of instantiation for this implicit instantiation.
2744  if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped() &&
2745  Enum->isCompleteDefinition()) {
2746  MemberSpecializationInfo *MSInfo =Enum->getMemberSpecializationInfo();
2747  assert(MSInfo && "no spec info for member enum specialization");
2749  MSInfo->setPointOfInstantiation(PointOfInstantiation);
2750  }
2751  } else if (StaticAssertDecl *SA = dyn_cast<StaticAssertDecl>(NewMember)) {
2752  if (SA->isFailed()) {
2753  // A static_assert failed. Bail out; instantiating this
2754  // class is probably not meaningful.
2755  Instantiation->setInvalidDecl();
2756  break;
2757  }
2758  } else if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewMember)) {
2759  if (MD->isConstexpr() && !MD->getFriendObjectKind() &&
2760  (MD->isVirtualAsWritten() || Instantiation->getNumBases()))
2761  MightHaveConstexprVirtualFunctions = true;
2762  }
2763 
2764  if (NewMember->isInvalidDecl())
2765  Instantiation->setInvalidDecl();
2766  } else {
2767  // FIXME: Eventually, a NULL return will mean that one of the
2768  // instantiations was a semantic disaster, and we'll want to mark the
2769  // declaration invalid.
2770  // For now, we expect to skip some members that we can't yet handle.
2771  }
2772  }
2773 
2774  // Finish checking fields.
2775  ActOnFields(nullptr, Instantiation->getLocation(), Instantiation, Fields,
2777  CheckCompletedCXXClass(nullptr, Instantiation);
2778 
2779  // Default arguments are parsed, if not instantiated. We can go instantiate
2780  // default arg exprs for default constructors if necessary now. Unless we're
2781  // parsing a class, in which case wait until that's finished.
2782  if (ParsingClassDepth == 0)
2784 
2785  // Instantiate late parsed attributes, and attach them to their decls.
2786  // See Sema::InstantiateAttrs
2787  for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
2788  E = LateAttrs.end(); I != E; ++I) {
2789  assert(CurrentInstantiationScope == Instantiator.getStartingScope());
2790  CurrentInstantiationScope = I->Scope;
2791 
2792  // Allow 'this' within late-parsed attributes.
2793  NamedDecl *ND = dyn_cast<NamedDecl>(I->NewDecl);
2794  CXXRecordDecl *ThisContext =
2795  dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext());
2796  CXXThisScopeRAII ThisScope(*this, ThisContext, Qualifiers(),
2797  ND && ND->isCXXInstanceMember());
2798 
2799  Attr *NewAttr =
2800  instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
2801  if (NewAttr)
2802  I->NewDecl->addAttr(NewAttr);
2804  Instantiator.getStartingScope());
2805  }
2806  Instantiator.disableLateAttributeInstantiation();
2807  LateAttrs.clear();
2808 
2809  ActOnFinishDelayedMemberInitializers(Instantiation);
2810 
2811  // FIXME: We should do something similar for explicit instantiations so they
2812  // end up in the right module.
2813  if (TSK == TSK_ImplicitInstantiation) {
2814  Instantiation->setLocation(Pattern->getLocation());
2815  Instantiation->setLocStart(Pattern->getInnerLocStart());
2816  Instantiation->setBraceRange(Pattern->getBraceRange());
2817  }
2818 
2819  if (!Instantiation->isInvalidDecl()) {
2820  // Perform any dependent diagnostics from the pattern.
2821  if (Pattern->isDependentContext())
2822  PerformDependentDiagnostics(Pattern, TemplateArgs);
2823 
2824  // Instantiate any out-of-line class template partial
2825  // specializations now.
2827  P = Instantiator.delayed_partial_spec_begin(),
2828  PEnd = Instantiator.delayed_partial_spec_end();
2829  P != PEnd; ++P) {
2831  P->first, P->second)) {
2832  Instantiation->setInvalidDecl();
2833  break;
2834  }
2835  }
2836 
2837  // Instantiate any out-of-line variable template partial
2838  // specializations now.
2840  P = Instantiator.delayed_var_partial_spec_begin(),
2841  PEnd = Instantiator.delayed_var_partial_spec_end();
2842  P != PEnd; ++P) {
2844  P->first, P->second)) {
2845  Instantiation->setInvalidDecl();
2846  break;
2847  }
2848  }
2849  }
2850 
2851  // Exit the scope of this instantiation.
2852  SavedContext.pop();
2853 
2854  if (!Instantiation->isInvalidDecl()) {
2855  // Always emit the vtable for an explicit instantiation definition
2856  // of a polymorphic class template specialization. Otherwise, eagerly
2857  // instantiate only constexpr virtual functions in preparation for their use
2858  // in constant evaluation.
2860  MarkVTableUsed(PointOfInstantiation, Instantiation, true);
2861  else if (MightHaveConstexprVirtualFunctions)
2862  MarkVirtualMembersReferenced(PointOfInstantiation, Instantiation,
2863  /*ConstexprOnly*/ true);
2864  }
2865 
2866  Consumer.HandleTagDeclDefinition(Instantiation);
2867 
2868  return Instantiation->isInvalidDecl();
2869 }
2870 
2871 /// Instantiate the definition of an enum from a given pattern.
2872 ///
2873 /// \param PointOfInstantiation The point of instantiation within the
2874 /// source code.
2875 /// \param Instantiation is the declaration whose definition is being
2876 /// instantiated. This will be a member enumeration of a class
2877 /// temploid specialization, or a local enumeration within a
2878 /// function temploid specialization.
2879 /// \param Pattern The templated declaration from which the instantiation
2880 /// occurs.
2881 /// \param TemplateArgs The template arguments to be substituted into
2882 /// the pattern.
2883 /// \param TSK The kind of implicit or explicit instantiation to perform.
2884 ///
2885 /// \return \c true if an error occurred, \c false otherwise.
2886 bool Sema::InstantiateEnum(SourceLocation PointOfInstantiation,
2887  EnumDecl *Instantiation, EnumDecl *Pattern,
2888  const MultiLevelTemplateArgumentList &TemplateArgs,
2890  EnumDecl *PatternDef = Pattern->getDefinition();
2891  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Instantiation,
2892  Instantiation->getInstantiatedFromMemberEnum(),
2893  Pattern, PatternDef, TSK,/*Complain*/true))
2894  return true;
2895  Pattern = PatternDef;
2896 
2897  // Record the point of instantiation.
2898  if (MemberSpecializationInfo *MSInfo
2899  = Instantiation->getMemberSpecializationInfo()) {
2900  MSInfo->setTemplateSpecializationKind(TSK);
2901  MSInfo->setPointOfInstantiation(PointOfInstantiation);
2902  }
2903 
2904  InstantiatingTemplate Inst(*this, PointOfInstantiation, Instantiation);
2905  if (Inst.isInvalid())
2906  return true;
2907  if (Inst.isAlreadyInstantiating())
2908  return false;
2909  PrettyDeclStackTraceEntry CrashInfo(Context, Instantiation, SourceLocation(),
2910  "instantiating enum definition");
2911 
2912  // The instantiation is visible here, even if it was first declared in an
2913  // unimported module.
2914  Instantiation->setVisibleDespiteOwningModule();
2915 
2916  // Enter the scope of this instantiation. We don't use
2917  // PushDeclContext because we don't have a scope.
2918  ContextRAII SavedContext(*this, Instantiation);
2921 
2922  LocalInstantiationScope Scope(*this, /*MergeWithParentScope*/true);
2923 
2924  // Pull attributes from the pattern onto the instantiation.
2925  InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
2926 
2927  TemplateDeclInstantiator Instantiator(*this, Instantiation, TemplateArgs);
2928  Instantiator.InstantiateEnumDefinition(Instantiation, Pattern);
2929 
2930  // Exit the scope of this instantiation.
2931  SavedContext.pop();
2932 
2933  return Instantiation->isInvalidDecl();
2934 }
2935 
2936 
2937 /// Instantiate the definition of a field from the given pattern.
2938 ///
2939 /// \param PointOfInstantiation The point of instantiation within the
2940 /// source code.
2941 /// \param Instantiation is the declaration whose definition is being
2942 /// instantiated. This will be a class of a class temploid
2943 /// specialization, or a local enumeration within a function temploid
2944 /// specialization.
2945 /// \param Pattern The templated declaration from which the instantiation
2946 /// occurs.
2947 /// \param TemplateArgs The template arguments to be substituted into
2948 /// the pattern.
2949 ///
2950 /// \return \c true if an error occurred, \c false otherwise.
2952  SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
2953  FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs) {
2954  // If there is no initializer, we don't need to do anything.
2955  if (!Pattern->hasInClassInitializer())
2956  return false;
2957 
2958  assert(Instantiation->getInClassInitStyle() ==
2959  Pattern->getInClassInitStyle() &&
2960  "pattern and instantiation disagree about init style");
2961 
2962  // Error out if we haven't parsed the initializer of the pattern yet because
2963  // we are waiting for the closing brace of the outer class.
2964  Expr *OldInit = Pattern->getInClassInitializer();
2965  if (!OldInit) {
2966  RecordDecl *PatternRD = Pattern->getParent();
2967  RecordDecl *OutermostClass = PatternRD->getOuterLexicalRecordContext();
2968  Diag(PointOfInstantiation,
2969  diag::err_default_member_initializer_not_yet_parsed)
2970  << OutermostClass << Pattern;
2971  Diag(Pattern->getEndLoc(),
2972  diag::note_default_member_initializer_not_yet_parsed);
2973  Instantiation->setInvalidDecl();
2974  return true;
2975  }
2976 
2977  InstantiatingTemplate Inst(*this, PointOfInstantiation, Instantiation);
2978  if (Inst.isInvalid())
2979  return true;
2980  if (Inst.isAlreadyInstantiating()) {
2981  // Error out if we hit an instantiation cycle for this initializer.
2982  Diag(PointOfInstantiation, diag::err_default_member_initializer_cycle)
2983  << Instantiation;
2984  return true;
2985  }
2986  PrettyDeclStackTraceEntry CrashInfo(Context, Instantiation, SourceLocation(),
2987  "instantiating default member init");
2988 
2989  // Enter the scope of this instantiation. We don't use PushDeclContext because
2990  // we don't have a scope.
2991  ContextRAII SavedContext(*this, Instantiation->getParent());
2994 
2995  LocalInstantiationScope Scope(*this, true);
2996 
2997  // Instantiate the initializer.
2999  CXXThisScopeRAII ThisScope(*this, Instantiation->getParent(), Qualifiers());
3000 
3001  ExprResult NewInit = SubstInitializer(OldInit, TemplateArgs,
3002  /*CXXDirectInit=*/false);
3003  Expr *Init = NewInit.get();
3004  assert((!Init || !isa<ParenListExpr>(Init)) && "call-style init in class");
3006  Instantiation, Init ? Init->getBeginLoc() : SourceLocation(), Init);
3007 
3008  if (auto *L = getASTMutationListener())
3009  L->DefaultMemberInitializerInstantiated(Instantiation);
3010 
3011  // Return true if the in-class initializer is still missing.
3012  return !Instantiation->getInClassInitializer();
3013 }
3014 
3015 namespace {
3016  /// A partial specialization whose template arguments have matched
3017  /// a given template-id.
3018  struct PartialSpecMatchResult {
3020  TemplateArgumentList *Args;
3021  };
3022 }
3023 
3025  SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec) {
3026  if (ClassTemplateSpec->getTemplateSpecializationKind() ==
3028  return true;
3029 
3031  ClassTemplateSpec->getSpecializedTemplate()
3032  ->getPartialSpecializations(PartialSpecs);
3033  for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
3034  TemplateDeductionInfo Info(Loc);
3035  if (!DeduceTemplateArguments(PartialSpecs[I],
3036  ClassTemplateSpec->getTemplateArgs(), Info))
3037  return true;
3038  }
3039 
3040  return false;
3041 }
3042 
3043 /// Get the instantiation pattern to use to instantiate the definition of a
3044 /// given ClassTemplateSpecializationDecl (either the pattern of the primary
3045 /// template or of a partial specialization).
3048  Sema &S, SourceLocation PointOfInstantiation,
3049  ClassTemplateSpecializationDecl *ClassTemplateSpec,
3051  Sema::InstantiatingTemplate Inst(S, PointOfInstantiation, ClassTemplateSpec);
3052  if (Inst.isInvalid())
3053  return {/*Invalid=*/true};
3054  if (Inst.isAlreadyInstantiating())
3055  return {/*Invalid=*/false};
3056 
3057  llvm::PointerUnion<ClassTemplateDecl *,
3059  Specialized = ClassTemplateSpec->getSpecializedTemplateOrPartial();
3060  if (!Specialized.is<ClassTemplatePartialSpecializationDecl *>()) {
3061  // Find best matching specialization.
3062  ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
3063 
3064  // C++ [temp.class.spec.match]p1:
3065  // When a class template is used in a context that requires an
3066  // instantiation of the class, it is necessary to determine
3067  // whether the instantiation is to be generated using the primary
3068  // template or one of the partial specializations. This is done by
3069  // matching the template arguments of the class template
3070  // specialization with the template argument lists of the partial
3071  // specializations.
3072  typedef PartialSpecMatchResult MatchResult;
3075  Template->getPartialSpecializations(PartialSpecs);
3076  TemplateSpecCandidateSet FailedCandidates(PointOfInstantiation);
3077  for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
3078  ClassTemplatePartialSpecializationDecl *Partial = PartialSpecs[I];
3079  TemplateDeductionInfo Info(FailedCandidates.getLocation());
3081  Partial, ClassTemplateSpec->getTemplateArgs(), Info)) {
3082  // Store the failed-deduction information for use in diagnostics, later.
3083  // TODO: Actually use the failed-deduction info?
3084  FailedCandidates.addCandidate().set(
3085  DeclAccessPair::make(Template, AS_public), Partial,
3086  MakeDeductionFailureInfo(S.Context, Result, Info));
3087  (void)Result;
3088  } else {
3089  Matched.push_back(PartialSpecMatchResult());
3090  Matched.back().Partial = Partial;
3091  Matched.back().Args = Info.take();
3092  }
3093  }
3094 
3095  // If we're dealing with a member template where the template parameters
3096  // have been instantiated, this provides the original template parameters
3097  // from which the member template's parameters were instantiated.
3098 
3099  if (Matched.size() >= 1) {
3100  SmallVectorImpl<MatchResult>::iterator Best = Matched.begin();
3101  if (Matched.size() == 1) {
3102  // -- If exactly one matching specialization is found, the
3103  // instantiation is generated from that specialization.
3104  // We don't need to do anything for this.
3105  } else {
3106  // -- If more than one matching specialization is found, the
3107  // partial order rules (14.5.4.2) are used to determine
3108  // whether one of the specializations is more specialized
3109  // than the others. If none of the specializations is more
3110  // specialized than all of the other matching
3111  // specializations, then the use of the class template is
3112  // ambiguous and the program is ill-formed.
3113  for (SmallVectorImpl<MatchResult>::iterator P = Best + 1,
3114  PEnd = Matched.end();
3115  P != PEnd; ++P) {
3117  P->Partial, Best->Partial, PointOfInstantiation) ==
3118  P->Partial)
3119  Best = P;
3120  }
3121 
3122  // Determine if the best partial specialization is more specialized than
3123  // the others.
3124  bool Ambiguous = false;
3125  for (SmallVectorImpl<MatchResult>::iterator P = Matched.begin(),
3126  PEnd = Matched.end();
3127  P != PEnd; ++P) {
3128  if (P != Best && S.getMoreSpecializedPartialSpecialization(
3129  P->Partial, Best->Partial,
3130  PointOfInstantiation) != Best->Partial) {
3131  Ambiguous = true;
3132  break;
3133  }
3134  }
3135 
3136  if (Ambiguous) {
3137  // Partial ordering did not produce a clear winner. Complain.
3138  Inst.Clear();
3139  ClassTemplateSpec->setInvalidDecl();
3140  S.Diag(PointOfInstantiation,
3141  diag::err_partial_spec_ordering_ambiguous)
3142  << ClassTemplateSpec;
3143 
3144  // Print the matching partial specializations.
3145  for (SmallVectorImpl<MatchResult>::iterator P = Matched.begin(),
3146  PEnd = Matched.end();
3147  P != PEnd; ++P)
3148  S.Diag(P->Partial->getLocation(), diag::note_partial_spec_match)
3150  P->Partial->getTemplateParameters(), *P->Args);
3151 
3152  return {/*Invalid=*/true};
3153  }
3154  }
3155 
3156  ClassTemplateSpec->setInstantiationOf(Best->Partial, Best->Args);
3157  } else {
3158  // -- If no matches are found, the instantiation is generated
3159  // from the primary template.
3160  }
3161  }
3162 
3163  CXXRecordDecl *Pattern = nullptr;
3164  Specialized = ClassTemplateSpec->getSpecializedTemplateOrPartial();
3165  if (auto *PartialSpec =
3166  Specialized.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) {
3167  // Instantiate using the best class template partial specialization.
3168  while (PartialSpec->getInstantiatedFromMember()) {
3169  // If we've found an explicit specialization of this class template,
3170  // stop here and use that as the pattern.
3171  if (PartialSpec->isMemberSpecialization())
3172  break;
3173 
3174  PartialSpec = PartialSpec->getInstantiatedFromMember();
3175  }
3176  Pattern = PartialSpec;
3177  } else {
3178  ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
3179  while (Template->getInstantiatedFromMemberTemplate()) {
3180  // If we've found an explicit specialization of this class template,
3181  // stop here and use that as the pattern.
3182  if (Template->isMemberSpecialization())
3183  break;
3184 
3185  Template = Template->getInstantiatedFromMemberTemplate();
3186  }
3187  Pattern = Template->getTemplatedDecl();
3188  }
3189 
3190  return Pattern;
3191 }
3192 
3194  SourceLocation PointOfInstantiation,
3195  ClassTemplateSpecializationDecl *ClassTemplateSpec,
3196  TemplateSpecializationKind TSK, bool Complain) {
3197  // Perform the actual instantiation on the canonical declaration.
3198  ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>(
3199  ClassTemplateSpec->getCanonicalDecl());
3200  if (ClassTemplateSpec->isInvalidDecl())
3201  return true;
3202 
3204  getPatternForClassTemplateSpecialization(*this, PointOfInstantiation,
3205  ClassTemplateSpec, TSK);
3206  if (!Pattern.isUsable())
3207  return Pattern.isInvalid();
3208 
3209  return InstantiateClass(
3210  PointOfInstantiation, ClassTemplateSpec, Pattern.get(),
3211  getTemplateInstantiationArgs(ClassTemplateSpec), TSK, Complain);
3212 }
3213 
3214 /// Instantiates the definitions of all of the member
3215 /// of the given class, which is an instantiation of a class template
3216 /// or a member class of a template.
3217 void
3219  CXXRecordDecl *Instantiation,
3220  const MultiLevelTemplateArgumentList &TemplateArgs,
3222  // FIXME: We need to notify the ASTMutationListener that we did all of these
3223  // things, in case we have an explicit instantiation definition in a PCM, a
3224  // module, or preamble, and the declaration is in an imported AST.
3225  assert(
3228  (TSK == TSK_ImplicitInstantiation && Instantiation->isLocalClass())) &&
3229  "Unexpected template specialization kind!");
3230  for (auto *D : Instantiation->decls()) {
3231  bool SuppressNew = false;
3232  if (auto *Function = dyn_cast<FunctionDecl>(D)) {
3233  if (FunctionDecl *Pattern =
3234  Function->getInstantiatedFromMemberFunction()) {
3235 
3236  if (Function->hasAttr<ExcludeFromExplicitInstantiationAttr>())
3237  continue;
3238 
3239  MemberSpecializationInfo *MSInfo =
3240  Function->getMemberSpecializationInfo();
3241  assert(MSInfo && "No member specialization information?");
3242  if (MSInfo->getTemplateSpecializationKind()
3244  continue;
3245 
3246  if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
3247  Function,
3249  MSInfo->getPointOfInstantiation(),
3250  SuppressNew) ||
3251  SuppressNew)
3252  continue;
3253 
3254  // C++11 [temp.explicit]p8:
3255  // An explicit instantiation definition that names a class template
3256  // specialization explicitly instantiates the class template
3257  // specialization and is only an explicit instantiation definition
3258  // of members whose definition is visible at the point of
3259  // instantiation.
3260  if (TSK == TSK_ExplicitInstantiationDefinition && !Pattern->isDefined())
3261  continue;
3262 
3263  Function->setTemplateSpecializationKind(TSK, PointOfInstantiation);
3264 
3265  if (Function->isDefined()) {
3266  // Let the ASTConsumer know that this function has been explicitly
3267  // instantiated now, and its linkage might have changed.
3269  } else if (TSK == TSK_ExplicitInstantiationDefinition) {
3270  InstantiateFunctionDefinition(PointOfInstantiation, Function);
3271  } else if (TSK == TSK_ImplicitInstantiation) {
3273  std::make_pair(Function, PointOfInstantiation));
3274  }
3275  }
3276  } else if (auto *Var = dyn_cast<VarDecl>(D)) {
3277  if (isa<VarTemplateSpecializationDecl>(Var))
3278  continue;
3279 
3280  if (Var->isStaticDataMember()) {
3281  if (Var->hasAttr<ExcludeFromExplicitInstantiationAttr>())
3282  continue;
3283 
3285  assert(MSInfo && "No member specialization information?");
3286  if (MSInfo->getTemplateSpecializationKind()
3288  continue;
3289 
3290  if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
3291  Var,
3293  MSInfo->getPointOfInstantiation(),
3294  SuppressNew) ||
3295  SuppressNew)
3296  continue;
3297 
3299  // C++0x [temp.explicit]p8:
3300  // An explicit instantiation definition that names a class template
3301  // specialization explicitly instantiates the class template
3302  // specialization and is only an explicit instantiation definition
3303  // of members whose definition is visible at the point of
3304  // instantiation.
3306  continue;
3307 
3308  Var->setTemplateSpecializationKind(TSK, PointOfInstantiation);
3309  InstantiateVariableDefinition(PointOfInstantiation, Var);
3310  } else {
3311  Var->setTemplateSpecializationKind(TSK, PointOfInstantiation);
3312  }
3313  }
3314  } else if (auto *Record = dyn_cast<CXXRecordDecl>(D)) {
3315  if (Record->hasAttr<ExcludeFromExplicitInstantiationAttr>())
3316  continue;
3317 
3318  // Always skip the injected-class-name, along with any
3319  // redeclarations of nested classes, since both would cause us
3320  // to try to instantiate the members of a class twice.
3321  // Skip closure types; they'll get instantiated when we instantiate
3322  // the corresponding lambda-expression.
3323  if (Record->isInjectedClassName() || Record->getPreviousDecl() ||
3324  Record->isLambda())
3325  continue;
3326 
3327  MemberSpecializationInfo *MSInfo = Record->getMemberSpecializationInfo();
3328  assert(MSInfo && "No member specialization information?");
3329 
3330  if (MSInfo->getTemplateSpecializationKind()
3332  continue;
3333 
3334  if (Context.getTargetInfo().getTriple().isOSWindows() &&
3336  // On Windows, explicit instantiation decl of the outer class doesn't
3337  // affect the inner class. Typically extern template declarations are
3338  // used in combination with dll import/export annotations, but those
3339  // are not propagated from the outer class templates to inner classes.
3340  // Therefore, do not instantiate inner classes on this platform, so
3341  // that users don't end up with undefined symbols during linking.
3342  continue;
3343  }
3344 
3345  if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
3346  Record,
3348  MSInfo->getPointOfInstantiation(),
3349  SuppressNew) ||
3350  SuppressNew)
3351  continue;
3352 
3353  CXXRecordDecl *Pattern = Record->getInstantiatedFromMemberClass();
3354  assert(Pattern && "Missing instantiated-from-template information");
3355 
3356  if (!Record->getDefinition()) {
3357  if (!Pattern->getDefinition()) {
3358  // C++0x [temp.explicit]p8:
3359  // An explicit instantiation definition that names a class template
3360  // specialization explicitly instantiates the class template
3361  // specialization and is only an explicit instantiation definition
3362  // of members whose definition is visible at the point of
3363  // instantiation.
3365  MSInfo->setTemplateSpecializationKind(TSK);
3366  MSInfo->setPointOfInstantiation(PointOfInstantiation);
3367  }
3368 
3369  continue;
3370  }
3371 
3372  InstantiateClass(PointOfInstantiation, Record, Pattern,
3373  TemplateArgs,
3374  TSK);
3375  } else {
3377  Record->getTemplateSpecializationKind() ==
3379  Record->setTemplateSpecializationKind(TSK);
3380  MarkVTableUsed(PointOfInstantiation, Record, true);
3381  }
3382  }
3383 
3384  Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition());
3385  if (Pattern)
3386  InstantiateClassMembers(PointOfInstantiation, Pattern, TemplateArgs,
3387  TSK);
3388  } else if (auto *Enum = dyn_cast<EnumDecl>(D)) {
3389  MemberSpecializationInfo *MSInfo = Enum->getMemberSpecializationInfo();
3390  assert(MSInfo && "No member specialization information?");
3391 
3392  if (MSInfo->getTemplateSpecializationKind()
3394  continue;
3395 
3397  PointOfInstantiation, TSK, Enum,
3399  MSInfo->getPointOfInstantiation(), SuppressNew) ||
3400  SuppressNew)
3401  continue;
3402 
3403  if (Enum->getDefinition())
3404  continue;
3405 
3406  EnumDecl *Pattern = Enum->getTemplateInstantiationPattern();
3407  assert(Pattern && "Missing instantiated-from-template information");
3408 
3410  if (!Pattern->getDefinition())
3411  continue;
3412 
3413  InstantiateEnum(PointOfInstantiation, Enum, Pattern, TemplateArgs, TSK);
3414  } else {
3415  MSInfo->setTemplateSpecializationKind(TSK);
3416  MSInfo->setPointOfInstantiation(PointOfInstantiation);
3417  }
3418  } else if (auto *Field = dyn_cast<FieldDecl>(D)) {
3419  // No need to instantiate in-class initializers during explicit
3420  // instantiation.
3421  if (Field->hasInClassInitializer() && TSK == TSK_ImplicitInstantiation) {
3422  CXXRecordDecl *ClassPattern =
3423  Instantiation->getTemplateInstantiationPattern();
3425  ClassPattern->lookup(Field->getDeclName());
3426  FieldDecl *Pattern = Lookup.find_first<FieldDecl>();
3427  assert(Pattern);
3428  InstantiateInClassInitializer(PointOfInstantiation, Field, Pattern,
3429  TemplateArgs);
3430  }
3431  }
3432  }
3433 }
3434 
3435 /// Instantiate the definitions of all of the members of the
3436 /// given class template specialization, which was named as part of an
3437 /// explicit instantiation.
3438 void
3440  SourceLocation PointOfInstantiation,
3441  ClassTemplateSpecializationDecl *ClassTemplateSpec,
3443  // C++0x [temp.explicit]p7:
3444  // An explicit instantiation that names a class template
3445  // specialization is an explicit instantion of the same kind
3446  // (declaration or definition) of each of its members (not
3447  // including members inherited from base classes) that has not
3448  // been previously explicitly specialized in the translation unit
3449  // containing the explicit instantiation, except as described
3450  // below.
3451  InstantiateClassMembers(PointOfInstantiation, ClassTemplateSpec,
3452  getTemplateInstantiationArgs(ClassTemplateSpec),
3453  TSK);
3454 }
3455 
3456 StmtResult
3458  if (!S)
3459  return S;
3460 
3461  TemplateInstantiator Instantiator(*this, TemplateArgs,
3462  SourceLocation(),
3463  DeclarationName());
3464  return Instantiator.TransformStmt(S);
3465 }
3466 
3469  const MultiLevelTemplateArgumentList &TemplateArgs,
3470  TemplateArgumentListInfo &Out) {
3471  TemplateInstantiator Instantiator(*this, TemplateArgs,
3472  SourceLocation(),
3473  DeclarationName());
3474  return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(),
3475  Out);
3476 }
3477 
3478 ExprResult
3480  if (!E)
3481  return E;
3482 
3483  TemplateInstantiator Instantiator(*this, TemplateArgs,
3484  SourceLocation(),
3485  DeclarationName());
3486  return Instantiator.TransformExpr(E);
3487 }
3488 
3490  const MultiLevelTemplateArgumentList &TemplateArgs,
3491  bool CXXDirectInit) {
3492  TemplateInstantiator Instantiator(*this, TemplateArgs,
3493  SourceLocation(),
3494  DeclarationName());
3495  return Instantiator.TransformInitializer(Init, CXXDirectInit);
3496 }
3497 
3498 bool Sema::SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
3499  const MultiLevelTemplateArgumentList &TemplateArgs,
3500  SmallVectorImpl<Expr *> &Outputs) {
3501  if (Exprs.empty())
3502  return false;
3503 
3504  TemplateInstantiator Instantiator(*this, TemplateArgs,
3505  SourceLocation(),
3506  DeclarationName());
3507  return Instantiator.TransformExprs(Exprs.data(), Exprs.size(),
3508  IsCall, Outputs);
3509 }
3510 
3513  const MultiLevelTemplateArgumentList &TemplateArgs) {
3514  if (!NNS)
3515  return NestedNameSpecifierLoc();
3516 
3517  TemplateInstantiator Instantiator(*this, TemplateArgs, NNS.getBeginLoc(),
3518  DeclarationName());
3519  return Instantiator.TransformNestedNameSpecifierLoc(NNS);
3520 }
3521 
3522 /// Do template substitution on declaration name info.
3525  const MultiLevelTemplateArgumentList &TemplateArgs) {
3526  TemplateInstantiator Instantiator(*this, TemplateArgs, NameInfo.getLoc(),
3527  NameInfo.getName());
3528  return Instantiator.TransformDeclarationNameInfo(NameInfo);
3529 }
3530 
3533  TemplateName Name, SourceLocation Loc,
3534  const MultiLevelTemplateArgumentList &TemplateArgs) {
3535  TemplateInstantiator Instantiator(*this, TemplateArgs, Loc,
3536  DeclarationName());
3537  CXXScopeSpec SS;
3538  SS.Adopt(QualifierLoc);
3539  return Instantiator.TransformTemplateName(SS, Name, Loc);
3540 }
3541 
3542 static const Decl *getCanonicalParmVarDecl(const Decl *D) {
3543  // When storing ParmVarDecls in the local instantiation scope, we always
3544  // want to use the ParmVarDecl from the canonical function declaration,
3545  // since the map is then valid for any redeclaration or definition of that
3546  // function.
3547  if (const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(D)) {
3548  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
3549  unsigned i = PV->getFunctionScopeIndex();
3550  // This parameter might be from a freestanding function type within the
3551  // function and isn't necessarily referring to one of FD's parameters.
3552  if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
3553  return FD->getCanonicalDecl()->getParamDecl(i);
3554  }
3555  }
3556  return D;
3557 }
3558 
3559 
3560 llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
3562  D = getCanonicalParmVarDecl(D);
3563  for (LocalInstantiationScope *Current = this; Current;
3564  Current = Current->Outer) {
3565 
3566  // Check if we found something within this scope.
3567  const Decl *CheckD = D;
3568  do {
3569  LocalDeclsMap::iterator Found = Current->LocalDecls.find(CheckD);
3570  if (Found != Current->LocalDecls.end())
3571  return &Found->second;
3572 
3573  // If this is a tag declaration, it's possible that we need to look for
3574  // a previous declaration.
3575  if (const TagDecl *Tag = dyn_cast<TagDecl>(CheckD))
3576  CheckD = Tag->getPreviousDecl();
3577  else
3578  CheckD = nullptr;
3579  } while (CheckD);
3580 
3581  // If we aren't combined with our outer scope, we're done.
3582  if (!Current->CombineWithOuterScope)
3583  break;
3584  }
3585 
3586  // If we're performing a partial substitution during template argument
3587  // deduction, we may not have values for template parameters yet.
3588  if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
3589  isa<TemplateTemplateParmDecl>(D))
3590  return nullptr;
3591 
3592  // Local types referenced prior to definition may require instantiation.
3593  if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D))
3594  if (RD->isLocalClass())
3595  return nullptr;
3596 
3597  // Enumeration types referenced prior to definition may appear as a result of
3598  // error recovery.
3599  if (isa<EnumDecl>(D))
3600  return nullptr;
3601 
3602  // Materialized typedefs/type alias for implicit deduction guides may require
3603  // instantiation.
3604  if (isa<TypedefNameDecl>(D) &&
3605  isa<CXXDeductionGuideDecl>(D->getDeclContext()))
3606  return nullptr;
3607 
3608  // If we didn't find the decl, then we either have a sema bug, or we have a
3609  // forward reference to a label declaration. Return null to indicate that
3610  // we have an uninstantiated label.
3611  assert(isa<LabelDecl>(D) && "declaration not instantiated in this scope");
3612  return nullptr;
3613 }
3614 
3616  D = getCanonicalParmVarDecl(D);
3617  llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
3618  if (Stored.isNull()) {
3619 #ifndef NDEBUG
3620  // It should not be present in any surrounding scope either.
3621  LocalInstantiationScope *Current = this;
3622  while (Current->CombineWithOuterScope && Current->Outer) {
3623  Current = Current->Outer;
3624  assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
3625  "Instantiated local in inner and outer scopes");
3626  }
3627 #endif
3628  Stored = Inst;
3629  } else if (DeclArgumentPack *Pack = Stored.dyn_cast<DeclArgumentPack *>()) {
3630  Pack->push_back(cast<VarDecl>(Inst));
3631  } else {
3632  assert(Stored.get<Decl *>() == Inst && "Already instantiated this local");
3633  }
3634 }
3635 
3637  VarDecl *Inst) {
3638  D = getCanonicalParmVarDecl(D);
3639  DeclArgumentPack *Pack = LocalDecls[D].get<DeclArgumentPack *>();
3640  Pack->push_back(Inst);
3641 }
3642 
3644 #ifndef NDEBUG
3645  // This should be the first time we've been told about this decl.
3646  for (LocalInstantiationScope *Current = this;
3647  Current && Current->CombineWithOuterScope; Current = Current->Outer)
3648  assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
3649  "Creating local pack after instantiation of local");
3650 #endif
3651 
3652  D = getCanonicalParmVarDecl(D);
3653  llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
3654  DeclArgumentPack *Pack = new DeclArgumentPack;
3655  Stored = Pack;
3656  ArgumentPacks.push_back(Pack);
3657 }
3658 
3660  for (DeclArgumentPack *Pack : ArgumentPacks)
3661  if (llvm::is_contained(*Pack, D))
3662  return true;
3663  return false;
3664 }
3665 
3667  const TemplateArgument *ExplicitArgs,
3668  unsigned NumExplicitArgs) {
3669  assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
3670  "Already have a partially-substituted pack");
3671  assert((!PartiallySubstitutedPack
3672  || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
3673  "Wrong number of arguments in partially-substituted pack");
3674  PartiallySubstitutedPack = Pack;
3675  ArgsInPartiallySubstitutedPack = ExplicitArgs;
3676  NumArgsInPartiallySubstitutedPack = NumExplicitArgs;
3677 }
3678 
3680  const TemplateArgument **ExplicitArgs,
3681  unsigned *NumExplicitArgs) const {
3682  if (ExplicitArgs)
3683  *ExplicitArgs = nullptr;
3684  if (NumExplicitArgs)
3685  *NumExplicitArgs = 0;
3686 
3687  for (const LocalInstantiationScope *Current = this; Current;
3688  Current = Current->Outer) {
3689  if (Current->PartiallySubstitutedPack) {
3690  if (ExplicitArgs)
3691  *ExplicitArgs = Current->ArgsInPartiallySubstitutedPack;
3692  if (NumExplicitArgs)
3693  *NumExplicitArgs = Current->NumArgsInPartiallySubstitutedPack;
3694 
3695  return Current->PartiallySubstitutedPack;
3696  }
3697 
3698  if (!Current->CombineWithOuterScope)
3699  break;
3700  }
3701 
3702  return nullptr;
3703 }
clang::ElaboratedTypeKeyword
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:5327
clang::DeclaratorDecl::getInnerLocStart
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition: Decl.h:771
clang::sema::TemplateDeductionInfo::take
TemplateArgumentList * take()
Take ownership of the deduced template argument list.
Definition: TemplateDeduction.h:95
clang::TagDecl::getKindName
StringRef getKindName() const
Definition: Decl.h:3503
clang::ASTConsumer::HandleTagDeclDefinition
virtual void HandleTagDeclDefinition(TagDecl *D)
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
Definition: ASTConsumer.h:72
clang::Sema::CurContext
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:423
clang::SubstNonTypeTemplateParmExpr
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4245
clang::Expr::getValueKind
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition: Expr.h:430
clang::MultiLevelTemplateArgumentList::setArgument
void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg)
Clear out a specific template argument.
Definition: Template.h:162
clang::concepts::ExprRequirement::getExprSubstitutionDiagnostic
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
Definition: ExprConcepts.h:386
clang::Type::isRecordType
bool isRecordType() const
Definition: Type.h:6762
clang::Sema::warnStackExhausted
void warnStackExhausted(SourceLocation Loc)
Warn that the stack is nearly exhausted.
Definition: Sema.cpp:478
NeedsInstantiationAsFunctionType
static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T)
Definition: SemaTemplateInstantiate.cpp:2125
clang::isLambdaCallOperator
bool isLambdaCallOperator(const CXXMethodDecl *MD)
Definition: ASTLambda.h:27
clang::Sema::InstantiatingTemplate::ParameterMappingSubstitution
Definition: Sema.h:9043
clang::ParenType::getInnerType
QualType getInnerType() const
Definition: Type.h:2623
clang::ParmVarDecl::setUnparsedDefaultArg
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
Definition: Decl.h:1794
clang::Sema::InstantiateClass
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
Definition: SemaTemplateInstantiate.cpp:2627
clang::ASTContext::getTypeDeclType
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1538
clang::TemplateDeclInstantiator::delayed_var_partial_spec_begin
delayed_var_partial_spec_iterator delayed_var_partial_spec_begin()
Definition: Template.h:572
clang::Sema::UnparsedDefaultArgInstantiations
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
Definition: Sema.h:1405
clang::Sema::SubstDeclarationNameInfo
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
Definition: SemaTemplateInstantiate.cpp:3524
clang::DeclContext::decls
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2115
clang::Decl::setDeclContext
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
Definition: DeclBase.cpp:327
clang::DeclRefExpr::getLocation
SourceLocation getLocation() const
Definition: Expr.h:1297
TreeTransform.h
clang::VarDecl::setTemplateSpecializationKind
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
Definition: Decl.cpp:2714
clang::Sema::deduceOpenCLAddressSpace
void deduceOpenCLAddressSpace(ValueDecl *decl)
Definition: SemaDecl.cpp:6432
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6406
clang::NamedDecl::isCXXInstanceMember
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
Definition: Decl.cpp:1844
clang::concepts::TypeRequirement::getSubstitutionDiagnostic
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:238
clang::FunctionTypeLoc::getParams
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1416
clang::AttributedType
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4668
clang::MemberSpecializationInfo
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:619
clang::isStackNearlyExhausted
bool isStackNearlyExhausted()
Determine whether the stack is nearly exhausted.
Definition: Stack.cpp:46
clang::Sema::pushCodeSynthesisContext
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
Definition: SemaTemplateInstantiate.cpp:429
clang::CXXScopeSpec::Adopt
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:131
clang::TemplateTypeParmType::getDecl
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:4810
clang::Sema::CXXThisScopeRAII
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:6240
clang::Sema::SubstParmTypes
bool SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams, ExtParameterInfoBuilder &ParamInfos)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
Definition: SemaTemplateInstantiate.cpp:2467
clang::SubstTemplateTypeParmPackType::getArgumentPack
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3605
createSubstDiag
static concepts::Requirement::SubstitutionDiagnostic * createSubstDiag(Sema &S, TemplateDeductionInfo &Info, EntityPrinter Printer)
Definition: SemaTemplateInstantiate.cpp:1876
clang::Expr::isLValue
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
Definition: Expr.h:270
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:547
clang::CXXRecordDecl::getMemberSpecializationInfo
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
Definition: DeclCXX.cpp:1795
clang::PartialDiagnostic::NullDiagnostic
Definition: PartialDiagnostic.h:43
clang::TemplateArgument::pack_begin
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:352
clang::Sema::ActOnFinishCXXNonNestedClass
void ActOnFinishCXXNonNestedClass()
Definition: SemaDeclCXX.cpp:13701
clang::Sema::InstantiateVariableDefinition
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
Definition: SemaTemplateInstantiateDecl.cpp:5351
clang::TypeLocBuilder::pushFullCopy
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
Definition: TypeLocBuilder.cpp:18
clang::Sema::ArgumentPackSubstitutionIndex
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:8888
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:4312
clang::FunctionParmPackExpr::getParameterPack
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:4409
llvm::SmallVector
Definition: LLVM.h:38
Lookup.h
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::Sema::CodeSynthesisContext::ParameterMappingSubstitution
@ ParameterMappingSubstitution
Definition: Sema.h:8748
clang::Sema::CodeSynthesisContext::PointOfInstantiation
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:8770
clang::VarTemplateSpecializationDecl::getTemplateInstantiationArgs
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
Definition: DeclTemplate.h:2838
clang::TemplateSpecCandidateSet::getLocation
SourceLocation getLocation() const
Definition: TemplateDeduction.h:335
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::Sema::AttachTypeConstraint
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
Definition: SemaTemplate.cpp:1212
clang::ClassTemplateSpecializationDecl::getSpecializedTemplate
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:963
clang::TreeTransform
A semantic tree transformation that allows one to transform one abstract syntax tree into another.
Definition: TreeTransform.h:101
TargetInfo.h
clang::Sema::FindInstantiatedDecl
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
Definition: SemaTemplateInstantiateDecl.cpp:5959
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::ConceptReference::getNamedConcept
ConceptDecl * getNamedConcept() const
Definition: ASTConcept.h:154
clang::CXXRecordDecl::getDefinition
CXXRecordDecl * getDefinition() const
Definition: DeclCXX.h:535
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1384
clang::TemplateName::getAsTemplateDecl
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Definition: TemplateName.cpp:101
clang::EST_None
@ EST_None
no exception specification
Definition: ExceptionSpecificationType.h:21
clang::TypeConstraint::getImmediatelyDeclaredConstraint
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
Definition: ASTConcept.h:187
clang::ClassTemplateDecl::getInstantiatedFromMemberTemplate
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
Definition: DeclTemplate.h:2353
clang::Sema::getMoreSpecializedPartialSpecialization
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
Definition: SemaTemplateDeduction.cpp:5516
clang::concepts::Requirement::SubstitutionDiagnostic
Definition: ExprConcepts.h:161
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2835
clang::ClassTemplateSpecializationDecl::getSpecializationKind
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Definition: DeclTemplate.h:1901
clang::TagDecl::setBraceRange
void setBraceRange(SourceRange R)
Definition: Decl.h:3410
clang::RequiresExpr
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:475
clang::FieldDecl::getInClassInitializer
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
Definition: Decl.h:2982
clang::Qualifiers
The collection of all-type qualifiers we support.
Definition: Type.h:145
clang::TemplateDeclInstantiator::delayed_var_partial_spec_iterator
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
Definition: Template.h:562
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::ParmVarDecl::getDefaultArg
Expr * getDefaultArg()
Definition: Decl.cpp:2806
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::Sema::ContextRAII::pop
void pop()
Definition: Sema.h:1006
clang::concepts::NestedRequirement::getSubstitutionDiagnostic
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:441
clang::Sema::CodeSynthesisContexts
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition: Sema.h:8823
clang::TemplateArgument::Declaration
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:75
clang::ClassTemplateSpecializationDecl::setInstantiationOf
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
Definition: DeclTemplate.h:1997
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::NonTypeTemplateParmDecl::getExpansionType
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
Definition: DeclTemplate.h:1544
clang::Sema::CheckTemplateArgument
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &Converted, CheckTemplateArgumentKind CTAK=CTAK_Specified)
Check that the given template argument corresponds to the given template parameter.
Definition: SemaTemplate.cpp:5356
clang::TemplateDeclInstantiator::delayed_partial_spec_end
delayed_partial_spec_iterator delayed_partial_spec_end()
Return an iterator to the end of the set of "delayed" partial specializations, which must be passed t...
Definition: Template.h:580
clang::concepts::ExprRequirement::getExpr
Expr * getExpr() const
Definition: ExprConcepts.h:393
llvm::Optional
Definition: LLVM.h:40
clang::Sema::PrintInstantiationStack
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
Definition: SemaTemplateInstantiate.cpp:511
TypeVisitor.h
clang::TypeLoc::getEndLoc
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:228
clang::Sema::ActOnFields
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
Definition: SemaDecl.cpp:17294
clang::TagType
Definition: Type.h:4589
clang::Sema::CheckCompletedCXXClass
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
Definition: SemaDeclCXX.cpp:6687
clang::Type::isVoidType
bool isVoidType() const
Definition: Type.h:6955
clang::Sema::ActOnFinishCXXInClassMemberInitializer
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
Definition: SemaDeclCXX.cpp:3984
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
getPatternForClassTemplateSpecialization
static ActionResult< CXXRecordDecl * > getPatternForClassTemplateSpecialization(Sema &S, SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Get the instantiation pattern to use to instantiate the definition of a given ClassTemplateSpecializa...
Definition: SemaTemplateInstantiate.cpp:3047
DeclSpec.h
clang::printTemplateArgumentList
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
Definition: TypePrinter.cpp:2082
clang::LocalInstantiationScope::deleteScopes
static void deleteScopes(LocalInstantiationScope *Scope, LocalInstantiationScope *Outermost)
deletes the given scope, and all otuer scopes, down to the given outermost scope.
Definition: Template.h:403
clang::Sema::TemplateInstCallbacks
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:8880
clang::CXXScopeSpec
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:64
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2075
clang::ReferenceType::getPointeeTypeAsWritten
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2767
clang::Sema::LastEmittedCodeSynthesisContextDepth
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
Definition: Sema.h:8872
clang::TemplateDeclInstantiator::disableLateAttributeInstantiation
void disableLateAttributeInstantiation()
Definition: Template.h:551
ASTLambda.h
clang::concepts::Requirement::isSatisfied
bool isSatisfied() const
Definition: ExprConcepts.h:178
clang::FunctionParmPackExpr::Create
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, VarDecl *ParamPack, SourceLocation NameLoc, ArrayRef< VarDecl * > Params)
Definition: ExprCXX.cpp:1610
print
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
Definition: InterpFrame.cpp:62
clang::TypeDecl::setLocStart
void setLocStart(SourceLocation L)
Definition: Decl.h:3166
clang::NamedDecl::getNameForDiagnostic
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
Definition: Decl.cpp:1726
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3546
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2664
clang::TemplateName::getNameToSubstitute
TemplateName getNameToSubstitute() const
Get the template name to substitute when this template name is used as a template template argument.
Definition: TemplateName.cpp:156
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
End
SourceLocation End
Definition: USRLocFinder.cpp:167
clang::ASTContext::getTranslationUnitDecl
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1057
clang::Sema::BuildExpressionFromIntegralTemplateArgument
ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
Definition: SemaTemplate.cpp:7584
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::ASTTemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:641
clang::Sema::CodeSynthesisContextLookupModules
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition: Sema.h:8834
clang::EnumDecl::setTemplateSpecializationKind
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class,...
Definition: Decl.cpp:4477
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3590
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:411
clang::Sema::InstantiatingTemplate::isAlreadyInstantiating
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:9074
clang::PredefinedExpr::getIdentKind
IdentKind getIdentKind() const
Definition: Expr.h:2001
clang::Sema::CodeSynthesisContext::SynthesisKind
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:8671
clang::ExprError
ExprResult ExprError()
Definition: Ownership.h:278
clang::SubstTemplateTypeParmPackType::getReplacedParameter
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4915
clang::Sema::SFINAETrap
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:9151
clang::Sema::MarkVirtualMembersReferenced
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
Definition: SemaDeclCXX.cpp:17671
clang::TreeTransform::RebuildElaboratedType
QualType RebuildElaboratedType(SourceLocation KeywordLoc, ElaboratedTypeKeyword Keyword, NestedNameSpecifierLoc QualifierLoc, QualType Named)
Build a new qualified name type.
Definition: TreeTransform.h:1024
clang::TypeLoc::getBeginLoc
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
clang::Sema::CodeSynthesisContext::DefaultTemplateArgumentInstantiation
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition: Sema.h:8681
clang::Sema::InstantiatingTemplate::ConstraintsCheck
Definition: Sema.h:9019
clang::Sema::getLangOpts
const LangOptions & getLangOpts() const
Definition: Sema.h:1569
clang::ClassTemplateDecl::getPartialSpecializations
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
Definition: DeclTemplate.cpp:477
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:669
clang::FunctionParmPackExpr
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4380
clang::Sema::CodeSynthesisContext::ConstraintSubstitution
@ ConstraintSubstitution
Definition: Sema.h:8741
clang::TagDecl::setTagKind
void setTagKind(TagKind TK)
Definition: Decl.h:3511
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::ParmVarDecl::setScopeInfo
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1698
clang::Decl::getLexicalDeclContext
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:843
clang::Sema::SubstTemplateName
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition: SemaTemplateInstantiate.cpp:3532
clang::VarDecl::isParameterPack
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Definition: Decl.cpp:2537
clang::Sema::CodeSynthesisContext::TemplateArgs
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:8782
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:978
clang::FunctionParmPackExpr::begin
iterator begin() const
Definition: ExprCXX.h:4417
clang::concepts::NestedRequirement::getConstraintExpr
Expr * getConstraintExpr() const
Definition: ExprConcepts.h:448
clang::CXXRecordDecl::getInstantiatedFromMemberClass
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
Definition: DeclCXX.cpp:1788
clang::TypeLocBuilder::push
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
Definition: TypeLocBuilder.h:93
clang::Type::isReferenceType
bool isReferenceType() const
Definition: Type.h:6684
clang::PackExpansionTypeLoc
Definition: TypeLoc.h:2436
clang::TSK_ExplicitInstantiationDeclaration
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:187
Template.h
clang::PackExpansionType::getPattern
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:5653
clang::Sema::NonInstantiationEntries
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore,...
Definition: Sema.h:8864
clang::Sema::BuildCXXDefaultArgExpr
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
Definition: SemaExpr.cpp:5701
clang::ConceptReference::getTemplateArgsAsWritten
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: ASTConcept.h:158
clang::ElaboratedType
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Definition: Type.h:5403
clang::Expr::isTypeDependent
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:185
clang::Sema::CodeSynthesisContext::Template
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition: Sema.h:8778
clang::TypeWithKeyword::getTagTypeKindForKeyword
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition: Type.cpp:2840
clang::VarDecl::getInstantiatedFromStaticDataMember
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
Definition: Decl.cpp:2623
clang::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:245
clang::Sema::AttachBaseSpecifiers
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
Definition: SemaDeclCXX.cpp:2692
clang::Sema::CodeSynthesisContext::ExceptionSpecInstantiation
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:8714
clang::SubstTemplateTypeParmPackTypeLoc
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:839
clang::Module
Describes a module or submodule.
Definition: Module.h:96
clang::ClassTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Definition: DeclTemplate.h:1891
clang::TemplateParameterList::getParam
NamedDecl * getParam(unsigned Idx)
Definition: DeclTemplate.h:138
DeclTemplate.h
clang::PackExpansionType
Represents a pack expansion of types.
Definition: Type.h:5632
clang::Sema::CodeSynthesisContext::isInstantiationRecord
bool isInstantiationRecord() const
Determines whether this template is an actual instantiation that should be counted toward the maximum...
Definition: SemaTemplateInstantiate.cpp:196
clang::PartialDiagnosticAt
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
Definition: PartialDiagnostic.h:208
clang::Sema::getDiagnostics
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:1573
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:564
clang::Sema::ArgumentPackSubstitutionIndexRAII
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:8894
clang::QualType::getNonLValueExprType
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
Definition: Type.cpp:3122
clang::DeclAccessPair::make
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
Definition: DeclAccessPair.h:35
clang::Stmt::printPretty
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Definition: StmtPrinter.cpp:2589
clang::TagTypeKind
TagTypeKind
The kind of a tag type.
Definition: Type.h:5308
clang::Sema::UpdateExceptionSpec
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
Definition: SemaExceptionSpec.cpp:242
clang::Sema::ActOnFinishDelayedMemberInitializers
void ActOnFinishDelayedMemberInitializers(Decl *Record)
Definition: SemaDeclCXX.cpp:13379
clang::DiagnosticsEngine::hasFatalErrorOccurred
bool hasFatalErrorOccurred() const
Definition: Diagnostic.h:843
clang::FunctionParmPackExpr::getNumExpansions
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
Definition: ExprCXX.h:4421
clang::TemplateTypeParmType::getIndex
unsigned getIndex() const
Definition: Type.h:4807
Id
int Id
Definition: ASTDiff.cpp:191
clang::FunctionProtoType::ExceptionSpecInfo
Holds information about the various types of exception specification.
Definition: Type.h:3942
clang::Sema::hasUncompilableErrorOccurred
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
Definition: Sema.cpp:1542
clang::SubstNonTypeTemplateParmPackExpr::getParameterPack
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.h:4340
clang::LambdaExpr
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1865
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
clang::Sema::DefaultedFunctionKind::isComparison
bool isComparison() const
Definition: Sema.h:3133
MatchResult
MatchFinder::MatchResult MatchResult
Definition: RangeSelector.cpp:30
clang::Sema::BuildExpressionFromDeclTemplateArgument
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
Definition: SemaTemplate.cpp:7474
clang::SubstNonTypeTemplateParmExpr::getReplacement
Expr * getReplacement() const
Definition: ExprCXX.h:4277
PrettyDeclStackTrace.h
clang::Sema::CodeSynthesisContext::TemplateInstantiation
@ TemplateInstantiation
We are instantiating a template declaration.
Definition: Sema.h:8674
clang::AS_public
@ AS_public
Definition: Specifiers.h:109
clang::Sema::PendingLocalImplicitInstantiations
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:9301
clang::VectorType
Represents a GCC generic vector type.
Definition: Type.h:3229
clang::VarDecl::getMemberSpecializationInfo
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Definition: Decl.cpp:2705
clang::VarDecl::isStaticDataMember
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition: Decl.h:1200
clang::Sema::CodeSynthesisContext::RequirementInstantiation
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition: Sema.h:8717
clang::Sema::InstantiatingTemplate::ConstraintSubstitution
Definition: Sema.h:9028
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::TemplateDeclInstantiator
Definition: Template.h:463
clang::Sema::InstantiateAttrs
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
Definition: SemaTemplateInstantiateDecl.cpp:639
clang::ArrayType
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2883
clang::DeclaratorContext::Member
@ Member
LangOptions.h
clang::MemberPointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2847
getCanonicalParmVarDecl
static const Decl * getCanonicalParmVarDecl(const Decl *D)
Definition: SemaTemplateInstantiate.cpp:3542
Depth
int Depth
Definition: ASTDiff.cpp:191
clang::EnumDecl::getDefinition
EnumDecl * getDefinition() const
Definition: Decl.h:3693
clang::concepts::NestedRequirement
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
Definition: ExprConcepts.h:407
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7161
clang::CXXRecordDecl::getNumBases
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Definition: DeclCXX.h:583
clang::Decl::isInvalidDecl
bool isInvalidDecl() const
Definition: DeclBase.h:558
clang::TemplateSpecCandidate::set
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
Definition: TemplateDeduction.h:302
clang::Sema::SubstTemplateArguments
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
Definition: SemaTemplateInstantiate.cpp:3467
clang::sema::instantiateTemplateAttribute
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:62
clang::isGenericLambdaCallOperatorOrStaticInvokerSpecialization
bool isGenericLambdaCallOperatorOrStaticInvokerSpecialization(DeclContext *DC)
Definition: ASTLambda.h:67
clang::atTemplateEnd
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
Definition: TemplateInstCallback.h:71
clang::MemberSpecializationInfo::setTemplateSpecializationKind
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
Definition: DeclTemplate.h:650
TemplateInstCallback.h
clang::concepts::Requirement
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:149
clang::sema::instantiateTemplateAttributeForDecl
Attr * instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
clang::MultiLevelTemplateArgumentList
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition: Template.h:75
clang::Sema::CodeSynthesisContext::DeducedTemplateArgumentSubstitution
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:8697
clang::Sema::Diags
DiagnosticsEngine & Diags
Definition: Sema.h:413
clang::ParmVarDecl::hasUnparsedDefaultArg
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
Definition: Decl.h:1782
clang::Decl::getCanonicalDecl
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:901
clang::EnumDecl::getMemberSpecializationInfo
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition: Decl.h:3840
clang::MacroQualifiedType
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
Definition: Type.h:4391
clang::Sema::InstantiatingTemplate::isInvalid
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:9070
clang::DeclContext::isTranslationUnit
bool isTranslationUnit() const
Definition: DeclBase.h:1935
clang::DeclRefExpr::getDecl
ValueDecl * getDecl()
Definition: Expr.h:1289
clang::Sema::InstantiateClassTemplateSpecializationMembers
void InstantiateClassTemplateSpecializationMembers(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Instantiate the definitions of all of the members of the given class template specialization,...
Definition: SemaTemplateInstantiate.cpp:3439
clang::TemplateSpecCandidateSet
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
Definition: TemplateDeduction.h:316
clang::FieldDecl::hasInClassInitializer
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:2975
Expr.h
clang::Sema::CodeSynthesisContext
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:8669
llvm::SmallString< 128 >
clang::TemplateTemplateParmDecl
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Definition: DeclTemplate.h:1601
clang::Sema::getDefaultedFunctionKind
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
Definition: SemaDeclCXX.cpp:6461
clang::TemplateArgumentListInfo::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:583
ASTContext.h
clang::Sema::SubstExpr
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition: SemaTemplateInstantiate.cpp:3479
clang::ParmVarDecl::setUninstantiatedDefaultArg
void setUninstantiatedDefaultArg(Expr *arg)
Definition: Decl.cpp:2843
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:876
clang::atTemplateBegin
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
Definition: TemplateInstCallback.h:61
clang::Sema::CodeSynthesisContext::NestedRequirementConstraintsCheck
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition: Sema.h:8721
getPackSubstitutedTemplateArgument
static TemplateArgument getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg)
Definition: SemaTemplateInstantiate.cpp:1203
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3328
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::TSK_ExplicitInstantiationDefinition
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:191
clang::MacroQualifiedType::getUnderlyingType
QualType getUnderlyingType() const
Definition: Type.h:4407
clang::MultiLevelTemplateArgumentList::getNumLevels
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
Definition: Template.h:114
clang::Decl::setVisibleDespiteOwningModule
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
Definition: DeclBase.h:795
clang::Type::isVariablyModifiedType
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Definition: Type.h:2192
clang::CXXRecordDecl::bases
base_class_range bases()
Definition: DeclCXX.h:589
clang::Sema::DeduceTemplateArguments
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
Definition: SemaTemplateDeduction.cpp:3078
clang::DeclContextLookupResult::find_first
T * find_first() const
Definition: DeclBase.h:1321
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::TypeVisitor
An operation on a type.
Definition: TypeVisitor.h:64
Base
clang::TemplateArgument::isPackExpansion
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
Definition: TemplateBase.cpp:245
clang::ClassTemplateSpecializationDecl::getTemplateInstantiationArgs
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
Definition: DeclTemplate.h:1986
clang::SubstTemplateTemplateParmPackStorage
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:135
clang::CXXDefaultArgExpr
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1241
clang::Sema::InstantiatingTemplate::ConstraintNormalization
Definition: Sema.h:9037
clang::Sema::InstantiateFunctionDefinition
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
Definition: SemaTemplateInstantiateDecl.cpp:4755
clang::concepts::TypeRequirement::isSubstitutionFailure
bool isSubstitutionFailure() const
Definition: ExprConcepts.h:234
clang::BlockPointerType
Pointer to a block type.
Definition: Type.h:2720
clang::Sema::InstantiatingSpecializations
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:8826
clang::Sema::getASTMutationListener
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:516
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1178
clang::ParmVarDecl::getFunctionScopeDepth
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1715
clang::ClassTemplateSpecializationDecl::getSpecializedTemplateOrPartial
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
Definition: DeclTemplate.h:1967
clang::AdjustedType
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Definition: Type.h:2669
clang::TemplateParameterList::getTemplateLoc
SourceLocation getTemplateLoc() const
Definition: DeclTemplate.h:193
clang::TypeLocBuilder
Definition: TypeLocBuilder.h:22
clang::TemplateName::isNull
bool isNull() const
Determine whether this template name is NULL.
Definition: TemplateName.cpp:80
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:563
clang::MemberSpecializationInfo::getPointOfInstantiation
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
Definition: DeclTemplate.h:659
clang::TypeLocBuilder::reserve
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
Definition: TypeLocBuilder.h:56
clang::ASTConsumer::HandleTopLevelDecl
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
Definition: ASTConsumer.cpp:18
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:418
clang::Sema::DefaultedFunctionKind::isSpecialMember
bool isSpecialMember() const
Definition: Sema.h:3132
clang::ETK_None
@ ETK_None
No keyword precedes the qualified type name.
Definition: Type.h:5348
clang::DeclarationNameInfo::getName
DeclarationName getName() const
getName - Returns the embedded declaration name.
Definition: DeclarationName.h:781
clang::Sema::CodeSynthesisContext::ExplicitTemplateArgumentSubstitution
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition: Sema.h:8690
clang::ParmVarDecl::setHasInheritedDefaultArg
void setHasInheritedDefaultArg(bool I=true)
Definition: Decl.h:1802
clang::TemplateTypeParmType
Definition: Type.h:4765
clang::Sema::InstantiateInClassInitializer
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
Definition: SemaTemplateInstantiate.cpp:2951
clang::Sema::isAcceptableTagRedeclaration
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
Definition: SemaDecl.cpp:15385
clang::VK_LValue
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:124
clang::ParmVarDecl::getUninstantiatedDefaultArg
Expr * getUninstantiatedDefaultArg()
Definition: Decl.cpp:2848
clang::Sema::InstantiatingTemplate::InstantiatingTemplate
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Decl *Entity, SourceRange InstantiationRange=SourceRange())
Note that we are instantiating a class template, function template, variable template,...
Definition: SemaTemplateInstantiate.cpp:266
clang::TemplateName::getAsQualifiedTemplateName
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Definition: TemplateName.cpp:148
clang::Sema::CheckLoopHintExpr
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc)
Definition: SemaExpr.cpp:3636
clang::TemplateDeclInstantiator::delayed_var_partial_spec_end
delayed_var_partial_spec_iterator delayed_var_partial_spec_end()
Definition: Template.h:584
clang::TargetInfo::getTriple
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:1130
clang::TemplateDeclInstantiator::delayed_partial_spec_begin
delayed_partial_spec_iterator delayed_partial_spec_begin()
Return an iterator to the beginning of the set of "delayed" partial specializations,...
Definition: Template.h:568
clang::Decl::setLocation
void setLocation(SourceLocation L)
Definition: DeclBase.h:431
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
clang::Sema::MarkVTableUsed
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
Definition: SemaDeclCXX.cpp:17512
clang::Sema::CodeSynthesisContext::Memoization
@ Memoization
Added for Template instantiation observation.
Definition: Sema.h:8763
clang::EnumDecl::getInstantiatedFromMemberEnum
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
Definition: Decl.cpp:4503
clang::Sema::CodeSynthesisContext::DefaultFunctionArgumentInstantiation
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition: Sema.h:8686
clang::Sema::SetParamDefaultArgument
void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
Definition: SemaDeclCXX.cpp:286
clang::sema::TemplateDeductionInfo::hasSFINAEDiagnostic
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
Definition: TemplateDeduction.h:135
clang::declvisitor::Base::Visit
RetTy Visit(PTR(Decl) D)
Definition: DeclVisitor.h:37
clang::EST_Uninstantiated
@ EST_Uninstantiated
not instantiated yet
Definition: ExceptionSpecificationType.h:31
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::SubstTemplateTypeParmTypeLoc
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:832
clang::Sema::TemplateDeductionResult
TemplateDeductionResult
Describes the result of template argument deduction.
Definition: Sema.h:8434
clang::Type::isDependentType
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2174
clang::Sema::LookupModulesCache
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
Definition: Sema.h:8839
clang::Type::isInstantiationDependentType
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:2182
clang::VK_PRValue
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:120
clang::TemplateSpecializationKind
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:173
clang::Sema::DefaultedFunctionKind
For a defaulted function, the kind of defaulted function that it is.
Definition: Sema.h:3119
clang::TagDecl::startDefinition
void startDefinition()
Starts the definition of this tag declaration.
Definition: Decl.cpp:4319
clang::Decl::getPreviousDecl
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition: DeclBase.h:984
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::TypeLoc::getFullDataSize
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:163
clang::getAsNamedDecl
NamedDecl * getAsNamedDecl(TemplateParameter P)
Definition: DeclTemplate.h:3343
false
#define false
Definition: stdbool.h:17
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::StaticAssertDecl
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3910
clang::Sema::SubstStmt
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition: SemaTemplateInstantiate.cpp:3457
clang::PredefinedExpr::getLocation
SourceLocation getLocation() const
Definition: Expr.h:2005
clang::concepts::TypeRequirement
A requires-expression requirement which queries the existence of a type name or type template special...
Definition: ExprConcepts.h:203
clang::Sema::ExtParameterInfoBuilder
A helper class for building up ExtParameterInfos.
Definition: Sema.h:9326
clang::Sema::CheckSpecializationInstantiationRedecl
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind NewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
Definition: SemaTemplate.cpp:8706
clang::ActionResult::get
PtrTy get() const
Definition: Ownership.h:169
clang::ElaboratedType::getNamedType
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:5447
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:270
clang::ASTTemplateArgumentListInfo::LAngleLoc
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:624
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2247
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:676
clang::Sema::SubstFunctionDeclType
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
Definition: SemaTemplateInstantiate.cpp:2151
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:192
clang::VarDecl::getStorageClass
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1085
clang::Sema::CodeSynthesisContext::DeclaringSpecialMember
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition: Sema.h:8724
clang::SubstNonTypeTemplateParmExpr::getParameter
NonTypeTemplateParmDecl * getParameter() const
Definition: ExprCXX.h:4279
clang::ASTContext::getTagDeclType
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
Definition: ASTContext.cpp:5702
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3885
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1860
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::TypeLoc::getAs
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:88
TemplateDeduction.h
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:399
clang::NonTypeTemplateParmDecl::isExpandedParameterPack
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
Definition: DeclTemplate.h:1533
clang::BlockPointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2732
clang::VarTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2925
clang::TemplateDeclInstantiator::InstantiateEnumDefinition
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
Definition: SemaTemplateInstantiateDecl.cpp:1429
clang::VarDecl::getDefinition
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
Definition: Decl.cpp:2250
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:738
llvm::ArrayRef
Definition: LLVM.h:34
clang::FunctionParmPackExpr::iterator
VarDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
Definition: ExprCXX.h:4416
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::PrettyDeclStackTraceEntry
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
Definition: PrettyDeclStackTrace.h:30
clang::EnterExpressionEvaluationContext
RAII object that enters a new expression evaluation context.
Definition: Sema.h:13071
clang::ParmVarDecl::getFunctionScopeIndex
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1725
clang::Sema::PerformDependentDiagnostics
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition: SemaTemplateInstantiateDecl.cpp:6333
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::FunctionType::ExtParameterInfo
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition: Type.h:3572
clang::DeclGroupRef
Definition: DeclGroup.h:51
clang::MakeDeductionFailureInfo
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
Definition: SemaOverload.cpp:613
clang::Sema::Consumer
ASTConsumer & Consumer
Definition: Sema.h:412
ASTMutationListener.h
clang::DeclContext::getOuterLexicalRecordContext
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
Definition: DeclBase.cpp:1806
clang::Sema::popCodeSynthesisContext
void popCodeSynthesisContext()
Definition: SemaTemplateInstantiate.cpp:444
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:355
clang::DependentSizedExtVectorType::getElementType
QualType getElementType() const
Definition: Type.h:3205
clang::ActionResult::isInvalid
bool isInvalid() const
Definition: Ownership.h:165
clang::TypeLoc::getType
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:132
clang::NonTypeTemplateParmDecl::getDepth
unsigned getDepth() const
Get the nesting depth of the template parameter.
Definition: DeclTemplate.h:1161
clang::Sema::CodeSynthesisContext::ConstraintsCheck
@ ConstraintsCheck
Definition: Sema.h:8738
clang::Sema::SubstInitializer
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
Definition: SemaTemplateInstantiate.cpp:3489
clang::ClassTemplateDecl::getTemplatedDecl
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
Definition: DeclTemplate.h:2295
clang::TSK_ExplicitSpecialization
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
Definition: Specifiers.h:183
clang::Sema::DiagnoseUninstantiableTemplate
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
Definition: SemaTemplate.cpp:783
clang::sema::TemplateDeductionInfo::getLocation
SourceLocation getLocation() const
Returns the location at which template argument is occurring.
Definition: TemplateDeduction.h:79
clang::concepts::TypeRequirement::getType
TypeSourceInfo * getType() const
Definition: ExprConcepts.h:245
clang::Sema::CodeSynthesisContext::DefaultTemplateArgumentChecking
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:8706
clang::TemplateTypeParmTypeLoc
Wrapper for template type parameters.
Definition: TypeLoc.h:733
ASTConsumer.h
clang::Sema::CodeSynthesisContext::InstantiationRange
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:8806
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:236
clang::DeclContext::isFileContext
bool isFileContext() const
Definition: DeclBase.h:1930
clang::Sema::ContextRAII
A RAII object to temporarily push a declaration context.
Definition: Sema.h:980
clang::TemplateParameterList::size
unsigned size() const
Definition: DeclTemplate.h:129
clang::Sema::CurrentInstantiationScope
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:9209
clang::sema::TemplateDeductionInfo
Provides information about an attempted template argument deduction, whose success or failure was des...
Definition: TemplateDeduction.h:42
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:747
clang::Sema::InstantiateEnum
bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiate the definition of an enum from a given pattern.
Definition: SemaTemplateInstantiate.cpp:2886
clang::FieldDecl::getInClassInitStyle
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Definition: Decl.h:2968
clang::MultiLevelTemplateArgumentList::getNewDepth
unsigned getNewDepth(unsigned OldDepth) const
Determine how many of the OldDepth outermost template parameter lists would be removed by substitutin...
Definition: Template.h:130
clang::VarTemplateSpecializationDecl::getSpecializedTemplateOrPartial
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
Definition: DeclTemplate.h:2819
clang::Sema::InstantiatingTemplate
A stack object to be created when performing template instantiation.
Definition: Sema.h:8931
clang::TemplateTypeParmDecl::isParameterPack
bool isParameterPack() const
Returns whether this is a parameter pack.
Definition: DeclTemplate.cpp:684
clang::MemberPointerType
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2831
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::Sema::CodeSynthesisContext::ConstraintNormalization
@ ConstraintNormalization
Definition: Sema.h:8744
clang::SubstNonTypeTemplateParmPackExpr::getParameterPackLocation
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
Definition: ExprCXX.h:4343
clang::TemplateParameterList::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Definition: DeclTemplate.h:197
clang::ActionResult
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
Definition: Ownership.h:152
clang::CXXRecordDecl::isLocalClass
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
Definition: DeclCXX.h:1487
clang::Sema::CodeSynthesisContext::DeclaringImplicitEqualityComparison
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition: Sema.h:8728
clang::FunctionProtoType::ExceptionSpecInfo::Type
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3944
clang::CXXRecordDecl::setTemplateSpecializationKind
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Definition: DeclCXX.cpp:1828
clang::FunctionProtoType::ExtProtoInfo::ExceptionSpec
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3974
clang::LocalInstantiationScope::SetPartiallySubstitutedPack
void SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs)
Note that the given parameter pack has been partially substituted via explicit specification of templ...
Definition: SemaTemplateInstantiate.cpp:3666
clang::Sema::ExpressionEvaluationContext::ConstantEvaluated
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
clang::TypeLoc::IgnoreParens
TypeLoc IgnoreParens() const
Definition: TypeLoc.h:1150
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:514
clang::Sema::CodeSynthesisContext::ExceptionSpecEvaluation
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:8710
clang::PredefinedExpr
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1953
clang::PointerType
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2640
clang::Sema::CodeSynthesisContext::SavedInNonInstantiationSFINAEContext
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:8767
clang::Sema::InNonInstantiationSFINAEContext
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
Definition: Sema.h:8855
clang::MultiLevelTemplateArgumentList::getNumSubstitutedLevels
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
Definition: Template.h:120
clang::Sema::CodeSynthesisContext::InitializingStructuredBinding
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition: Sema.h:8754
clang::Decl::isParameterPack
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:211
clang::Sema::CheckParameter
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
Definition: SemaDecl.cpp:13885
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::Sema::usesPartialOrExplicitSpecialization
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
Definition: SemaTemplateInstantiate.cpp:3024
clang::FieldDecl::getParent
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
Definition: Decl.h:3027
clang::CXXRecordDecl::getTemplateSpecializationKind
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition: DeclCXX.cpp:1817
clang::CXXDefaultArgExpr::getUsedLocation
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
Definition: ExprCXX.h:1287
clang
Definition: CalledOnceCheck.h:17
clang::VarTemplateSpecializationDecl::isClassScopeExplicitSpecialization
bool isClassScopeExplicitSpecialization() const
Definition: DeclTemplate.h:2774
clang::TemplateArgumentListInfo::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:584
clang::DeclContext::lookup
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1645
clang::VectorType::getElementType
QualType getElementType() const
Definition: Type.h:3270
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::FunctionParmPackExpr::getExpansion
VarDecl * getExpansion(unsigned I) const
Get an expansion of the parameter pack by index.
Definition: ExprCXX.h:4424
clang::ClassTemplateSpecializationDecl::isClassScopeExplicitSpecialization
bool isClassScopeExplicitSpecialization() const
Is this an explicit specialization at class scope (within the class that owns the primary template)?...
Definition: DeclTemplate.h:1918
clang::sema::TemplateDeductionInfo::takeSFINAEDiagnostic
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
Definition: TemplateDeduction.h:102
clang::TemplateArgument::Template
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:87
clang::NonTypeTemplateParmDecl::isParameterPack
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
Definition: DeclTemplate.h:1498
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::TemplateSpecCandidateSet::addCandidate
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
Definition: TemplateDeduction.h:351
std::arg
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
Definition: complex_cmath.h:40
clang::CXXRecordDecl::getCanonicalDecl
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclCXX.h:494
clang::ParmVarDecl::hasUninstantiatedDefaultArg
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1786
clang::Declarator
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1804
clang::Expr::getType
QualType getType() const
Definition: Expr.h:141
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:147
clang::CXXDefaultArgExpr::getParam
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1276
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:46
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6395
clang::FunctionType::getReturnType
QualType getReturnType() const
Definition: Type.h:3809
clang::TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
Definition: SemaTemplateInstantiateDecl.cpp:4104
clang::LocalInstantiationScope
A stack-allocated class that identifies which local variable declaration instantiations are present i...
Definition: Template.h:270
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:313
clang::Sema::SubstNestedNameSpecifierLoc
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition: SemaTemplateInstantiate.cpp:3512
clang::Sema::ActOnStartCXXInClassMemberInitializer
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
Definition: SemaDeclCXX.cpp:3942
clang::NamedDecl::printName
virtual void printName(raw_ostream &os) const
Pretty-print the unqualified name of this declaration.
Definition: Decl.cpp:1578
unsigned
clang::Stmt::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:336
clang::Sema::isSFINAEContext
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Definition: SemaTemplateInstantiate.cpp:832
clang::concepts::ExprRequirement::getNoexceptLoc
SourceLocation getNoexceptLoc() const
Definition: ExprConcepts.h:368
clang::Sema::CodeSynthesisContext::RewritingOperatorAsSpaceship
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:8751
clang::LocalInstantiationScope::InstantiatedLocalPackArg
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
Definition: SemaTemplateInstantiate.cpp:3636
clang::Sema::SubstType
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
Definition: SemaTemplateInstantiate.cpp:2060
clang::TemplateDeclInstantiator::delayed_partial_spec_iterator
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
Definition: Template.h:559
clang::Sema::ConvertParamDefaultArgument
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
Definition: SemaDeclCXX.cpp:258
clang::VarTemplateSpecializationDecl::getSpecializedTemplate
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:1321
clang::Decl::isDefinedOutsideFunctionOrMethod
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
Definition: DeclBase.h:874
clang::FunctionParmPackExpr::end
iterator end() const
Definition: ExprCXX.h:4418
clang::DeclContextLookupResult
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1292
clang::TypeSpecTypeLoc::setNameLoc
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:527
clang::TypeLoc::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:152
clang::ConceptReference::getNestedNameSpecifierLoc
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Definition: ASTConcept.h:138
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6424
clang::Sema::CheckBaseSpecifier
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
Definition: SemaDeclCXX.cpp:2468
clang::InheritingConcreteTypeLoc::getTypePtr
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:502
clang::ETK_Typename
@ ETK_Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition: Type.h:5345
clang::TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
Definition: SemaTemplateInstantiateDecl.cpp:3977
clang::ReferenceType
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2751
clang::Sema::DefaultedFunctionKind::asComparison
DefaultedComparisonKind asComparison() const
Definition: Sema.h:3142
clang::PointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2650
clang::ConceptReference::getConceptNameInfo
const DeclarationNameInfo & getConceptNameInfo() const
Definition: ASTConcept.h:142
clang::FunctionProtoTypeLoc
Definition: TypeLoc.h:1465
clang::DiagnosticsEngine::getTemplateBacktraceLimit
unsigned getTemplateBacktraceLimit() const
Retrieve the maximum number of template instantiation notes to emit along with a given diagnostic.
Definition: Diagnostic.h:624
clang::Decl::setInvalidDecl
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Definition: DeclBase.cpp:132
clang::TemplateArgument::pack_size
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:372
clang::MultiLevelTemplateArgumentList::isRewrite
bool isRewrite() const
Determine whether we are rewriting template parameters rather than substituting for them.
Definition: Template.h:108
clang::Sema::InstantiateClassTemplateSpecialization
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
Definition: SemaTemplateInstantiate.cpp:3193
clang::ASTContext::hasSameType
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2484
clang::TemplateDeclInstantiator::getStartingScope
LocalInstantiationScope * getStartingScope() const
Definition: Template.h:556
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:613
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::SubstNonTypeTemplateParmPackExpr::getArgumentPack
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition: ExprCXX.cpp:1592
clang::Sema::SubstTypeConstraint
bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition: SemaTemplateInstantiate.cpp:2307
clang::NonTypeTemplateParmDecl::getPosition
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
Definition: DeclTemplate.h:1165
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:687
clang::MemberSpecializationInfo::getTemplateSpecializationKind
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:641
clang::NestedNameSpecifierLoc::getBeginLoc
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
Definition: NestedNameSpecifier.h:299
clang::Sema::getPrintingPolicy
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition: Sema.h:2995
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3079
clang::ArrayType::getElementType
QualType getElementType() const
Definition: Type.h:2904
clang::RedeclarableTemplateDecl::isMemberSpecialization
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:889
clang::ParsedAttributesView
Definition: ParsedAttr.h:869
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::Sema::CodeSynthesisContext::Entity
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:8773
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::concepts::ExprRequirement
A requires-expression requirement which queries the validity and properties of an expression ('simple...
Definition: ExprConcepts.h:258
clang::FunctionParmPackExpr::getParameterPackLocation
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
Definition: ExprCXX.h:4412
clang::concepts::NestedRequirement::isSubstitutionFailure
bool isSubstitutionFailure() const
Definition: ExprConcepts.h:437
clang::Sema::DefaultedFunctionKind::asSpecialMember
CXXSpecialMember asSpecialMember() const
Definition: Sema.h:3141
clang::Sema::SubstExceptionSpec
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
Definition: SemaTemplateInstantiate.cpp:2205
clang::TSK_ImplicitInstantiation
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:179
clang::QualType::addConst
void addConst()
Add the const type qualifier to this QualType.
Definition: Type.h:842
clang::Sema::getTemplateInstantiationArgs
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
Definition: SemaTemplateInstantiate.cpp:59
clang::FunctionProtoType::getExtProtoInfo
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:4106
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:606
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:758
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1803
clang::Decl::isInLocalScopeForInstantiation
bool isInLocalScopeForInstantiation() const
Determine whether a substitution into this declaration would occur as part of a substitution into a d...
Definition: DeclBase.cpp:367
clang::Sema::SubstExprs
bool SubstExprs(ArrayRef< Expr * > Exprs, bool IsCall, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< Expr * > &Outputs)
Substitute the given template arguments into a list of expressions, expanding pack expansions if requ...
Definition: SemaTemplateInstantiate.cpp:3498
clang::LocalInstantiationScope::isLocalPackExpansion
bool isLocalPackExpansion(const Decl *D)
Determine whether D is a pack expansion created in this scope.
Definition: SemaTemplateInstantiate.cpp:3659
clang::concepts::ExprRequirement::isExprSubstitutionFailure
bool isExprSubstitutionFailure() const
Definition: ExprConcepts.h:372
clang::DependentSizedExtVectorType
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3189
clang::AttributedType::getModifiedType
QualType getModifiedType() const
Definition: Type.h:4690
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:430
clang::CXXRecordDecl::getTemplateInstantiationPattern
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
Definition: DeclCXX.cpp:1842
clang::Sema::CodeSynthesisContext::Kind
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
clang::concepts::ExprRequirement::isSimple
bool isSimple() const
Definition: ExprConcepts.h:364
clang::DeclRefExpr
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1217
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1856
clang::ASTTemplateArgumentListInfo::RAngleLoc
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:627
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3859
clang::TemplateParameter
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Definition: DeclTemplate.h:63
clang::MemberSpecializationInfo::setPointOfInstantiation
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
Definition: DeclTemplate.h:664
clang::SubstNonTypeTemplateParmExpr::getParameterType
QualType getParameterType(const ASTContext &Ctx) const
Determine the substituted type of the template parameter.
Definition: ExprCXX.cpp:1573
clang::Sema::CodeSynthesisContext::PriorTemplateArgumentSubstitution
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:8702
clang::Sema::CodeSynthesisContext::DefiningSynthesizedFunction
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:8732
SemaConcept.h
clang::TypeConstraint
Definition: ASTConcept.h:169
clang::VarTemplateSpecializationDecl::getSpecializationKind
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Definition: DeclTemplate.h:2766
clang::Sema::CodeSynthesisContext::CodeSynthesisContext
CodeSynthesisContext()
Definition: Sema.h:8808
clang::ActionResult::isUsable
bool isUsable() const
Definition: Ownership.h:166
clang::concepts::Requirement::isDependent
bool isDependent() const
Definition: ExprConcepts.h:191
clang::Sema::CodeSynthesisContext::DeductionInfo
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:8801
clang::AdjustedType::getOriginalType
QualType getOriginalType() const
Definition: Type.h:2682
clang::LocalInstantiationScope::MakeInstantiatedLocalArgPack
void MakeInstantiatedLocalArgPack(const Decl *D)
Definition: SemaTemplateInstantiate.cpp:3643
clang::DeclaratorDecl::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:757
clang::FixItHint::CreateReplacement
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
Definition: Diagnostic.h:133
clang::ParmVarDecl::hasInheritedDefaultArg
bool hasInheritedDefaultArg() const
Definition: Decl.h:1798
clang::Sema::CodeSynthesisContext::MarkingClassDllexported
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition: Sema.h:8757
clang::Sema::SubstBaseSpecifiers
bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Perform substitution on the base class specifiers of the given class template specialization.
Definition: SemaTemplateInstantiate.cpp:2491
clang::ParenType
Sugar for parentheses used when specifying types.
Definition: Type.h:2614
clang::Sema::getTemplateArgumentBindingsText
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
Definition: SemaTemplate.cpp:10892
clang::concepts::ExprRequirement::getReturnTypeRequirement
const ReturnTypeRequirement & getReturnTypeRequirement() const
Definition: ExprConcepts.h:376
Stack.h
clang::Sema::InstantiatingTemplate::ExceptionSpecification
Definition: Sema.h:8939
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::Sema::InstantiateClassMembers
void InstantiateClassMembers(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiates the definitions of all of the member of the given class, which is an instantiation of a ...
Definition: SemaTemplateInstantiate.cpp:3218
clang::TemplateArgument::getAsType
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:269
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1523
clang::TypeSourceInfo::getTypeLoc
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:244
clang::TemplateArgument::Pack
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:101
Initialization.h
clang::Sema::InstantiatingTemplate::Clear
void Clear()
Note that we have finished instantiating this template.
Definition: SemaTemplateInstantiate.cpp:473
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1948
clang::Sema::SubstParmVarDecl
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, Optional< unsigned > NumExpansions, bool ExpectParameterPack)
Definition: SemaTemplateInstantiate.cpp:2330
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:439
clang::Sema::ExpressionEvaluationContext::PotentiallyEvaluated
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
clang::TemplateDeclInstantiator::enableLateAttributeInstantiation
void enableLateAttributeInstantiation(Sema::LateInstantiatedAttrVec *LA)
Definition: Template.h:545
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:276
clang::LocalInstantiationScope::InstantiatedLocal
void InstantiatedLocal(const Decl *D, Decl *Inst)
Definition: SemaTemplateInstantiate.cpp:3615