clang  14.0.0git
Template.h
Go to the documentation of this file.
1 //===- SemaTemplate.h - C++ Templates ---------------------------*- C++ -*-===//
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 provides types used in the semantic analysis of C++ templates.
9 //
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef LLVM_CLANG_SEMA_TEMPLATE_H
13 #define LLVM_CLANG_SEMA_TEMPLATE_H
14 
15 #include "clang/AST/DeclTemplate.h"
16 #include "clang/AST/DeclVisitor.h"
17 #include "clang/AST/TemplateBase.h"
18 #include "clang/AST/Type.h"
19 #include "clang/Basic/LLVM.h"
20 #include "clang/Sema/Sema.h"
21 #include "llvm/ADT/ArrayRef.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/PointerUnion.h"
24 #include "llvm/ADT/SmallVector.h"
25 #include <cassert>
26 #include <utility>
27 
28 namespace clang {
29 
30 class ASTContext;
31 class BindingDecl;
32 class CXXMethodDecl;
33 class Decl;
34 class DeclaratorDecl;
35 class DeclContext;
36 class EnumDecl;
37 class FunctionDecl;
38 class NamedDecl;
39 class ParmVarDecl;
40 class TagDecl;
41 class TypedefNameDecl;
42 class TypeSourceInfo;
43 class VarDecl;
44 
45 /// The kind of template substitution being performed.
46 enum class TemplateSubstitutionKind : char {
47  /// We are substituting template parameters for template arguments in order
48  /// to form a template specialization.
50  /// We are substituting template parameters for (typically) other template
51  /// parameters in order to rewrite a declaration as a different declaration
52  /// (for example, when forming a deduction guide from a constructor).
53  Rewrite,
54 };
55 
56  /// Data structure that captures multiple levels of template argument
57  /// lists for use in template instantiation.
58  ///
59  /// Multiple levels of template arguments occur when instantiating the
60  /// definitions of member templates. For example:
61  ///
62  /// \code
63  /// template<typename T>
64  /// struct X {
65  /// template<T Value>
66  /// struct Y {
67  /// void f();
68  /// };
69  /// };
70  /// \endcode
71  ///
72  /// When instantiating X<int>::Y<17>::f, the multi-level template argument
73  /// list will contain a template argument list (int) at depth 0 and a
74  /// template argument list (17) at depth 1.
76  /// The template argument list at a certain template depth
78 
79  /// The template argument lists, stored from the innermost template
80  /// argument list (first) to the outermost template argument list (last).
81  SmallVector<ArgList, 4> TemplateArgumentLists;
82 
83  /// The number of outer levels of template arguments that are not
84  /// being substituted.
85  unsigned NumRetainedOuterLevels = 0;
86 
87  /// The kind of substitution described by this argument list.
89 
90  public:
91  /// Construct an empty set of template argument lists.
93 
94  /// Construct a single-level template argument list.
95  explicit
97  addOuterTemplateArguments(&TemplateArgs);
98  }
99 
100  void setKind(TemplateSubstitutionKind K) { Kind = K; }
101 
102  /// Determine the kind of template substitution being performed.
103  TemplateSubstitutionKind getKind() const { return Kind; }
104 
105  /// Determine whether we are rewriting template parameters rather than
106  /// substituting for them. If so, we should not leave references to the
107  /// original template parameters behind.
108  bool isRewrite() const {
109  return Kind == TemplateSubstitutionKind::Rewrite;
110  }
111 
112  /// Determine the number of levels in this template argument
113  /// list.
114  unsigned getNumLevels() const {
115  return TemplateArgumentLists.size() + NumRetainedOuterLevels;
116  }
117 
118  /// Determine the number of substituted levels in this template
119  /// argument list.
120  unsigned getNumSubstitutedLevels() const {
121  return TemplateArgumentLists.size();
122  }
123 
124  unsigned getNumRetainedOuterLevels() const {
125  return NumRetainedOuterLevels;
126  }
127 
128  /// Determine how many of the \p OldDepth outermost template parameter
129  /// lists would be removed by substituting these arguments.
130  unsigned getNewDepth(unsigned OldDepth) const {
131  if (OldDepth < NumRetainedOuterLevels)
132  return OldDepth;
133  if (OldDepth < getNumLevels())
134  return NumRetainedOuterLevels;
135  return OldDepth - TemplateArgumentLists.size();
136  }
137 
138  /// Retrieve the template argument at a given depth and index.
139  const TemplateArgument &operator()(unsigned Depth, unsigned Index) const {
140  assert(NumRetainedOuterLevels <= Depth && Depth < getNumLevels());
141  assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].size());
142  return TemplateArgumentLists[getNumLevels() - Depth - 1][Index];
143  }
144 
145  /// Determine whether there is a non-NULL template argument at the
146  /// given depth and index.
147  ///
148  /// There must exist a template argument list at the given depth.
149  bool hasTemplateArgument(unsigned Depth, unsigned Index) const {
150  assert(Depth < getNumLevels());
151 
152  if (Depth < NumRetainedOuterLevels)
153  return false;
154 
155  if (Index >= TemplateArgumentLists[getNumLevels() - Depth - 1].size())
156  return false;
157 
158  return !(*this)(Depth, Index).isNull();
159  }
160 
161  /// Clear out a specific template argument.
162  void setArgument(unsigned Depth, unsigned Index,
163  TemplateArgument Arg) {
164  assert(NumRetainedOuterLevels <= Depth && Depth < getNumLevels());
165  assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].size());
166  const_cast<TemplateArgument&>(
167  TemplateArgumentLists[getNumLevels() - Depth - 1][Index])
168  = Arg;
169  }
170 
171  /// Add a new outermost level to the multi-level template argument
172  /// list.
174  addOuterTemplateArguments(ArgList(TemplateArgs->data(),
175  TemplateArgs->size()));
176  }
177 
178  /// Add a new outmost level to the multi-level template argument
179  /// list.
181  assert(!NumRetainedOuterLevels &&
182  "substituted args outside retained args?");
183  TemplateArgumentLists.push_back(Args);
184  }
185 
186  /// Add an outermost level that we are not substituting. We have no
187  /// arguments at this level, and do not remove it from the depth of inner
188  /// template parameters that we instantiate.
190  ++NumRetainedOuterLevels;
191  }
192  void addOuterRetainedLevels(unsigned Num) {
193  NumRetainedOuterLevels += Num;
194  }
195 
196  /// Retrieve the innermost template argument list.
197  const ArgList &getInnermost() const {
198  return TemplateArgumentLists.front();
199  }
200  };
201 
202  /// The context in which partial ordering of function templates occurs.
203  enum TPOC {
204  /// Partial ordering of function templates for a function call.
206 
207  /// Partial ordering of function templates for a call to a
208  /// conversion function.
210 
211  /// Partial ordering of function templates in other contexts, e.g.,
212  /// taking the address of a function template or matching a function
213  /// template specialization to a function template.
215  };
216 
217  // This is lame but unavoidable in a world without forward
218  // declarations of enums. The alternatives are to either pollute
219  // Sema.h (by including this file) or sacrifice type safety (by
220  // making Sema.h declare things as enums).
222  TPOC Value;
223 
224  public:
226 
227  operator TPOC() const { return Value; }
228  };
229 
230  /// Captures a template argument whose value has been deduced
231  /// via c++ template argument deduction.
233  /// For a non-type template argument, whether the value was
234  /// deduced from an array bound.
235  bool DeducedFromArrayBound = false;
236 
237  public:
238  DeducedTemplateArgument() = default;
239 
241  bool DeducedFromArrayBound = false)
242  : TemplateArgument(Arg), DeducedFromArrayBound(DeducedFromArrayBound) {}
243 
244  /// Construct an integral non-type template argument that
245  /// has been deduced, possibly from an array bound.
247  const llvm::APSInt &Value,
248  QualType ValueType,
249  bool DeducedFromArrayBound)
250  : TemplateArgument(Ctx, Value, ValueType),
251  DeducedFromArrayBound(DeducedFromArrayBound) {}
252 
253  /// For a non-type template argument, determine whether the
254  /// template argument was deduced from an array bound.
255  bool wasDeducedFromArrayBound() const { return DeducedFromArrayBound; }
256 
257  /// Specify whether the given non-type template argument
258  /// was deduced from an array bound.
259  void setDeducedFromArrayBound(bool Deduced) {
260  DeducedFromArrayBound = Deduced;
261  }
262  };
263 
264  /// A stack-allocated class that identifies which local
265  /// variable declaration instantiations are present in this scope.
266  ///
267  /// A new instance of this class type will be created whenever we
268  /// instantiate a new function declaration, which will have its own
269  /// set of parameter declarations.
271  public:
272  /// A set of declarations.
274 
275  private:
276  /// Reference to the semantic analysis that is performing
277  /// this template instantiation.
278  Sema &SemaRef;
279 
280  using LocalDeclsMap =
281  llvm::SmallDenseMap<const Decl *,
282  llvm::PointerUnion<Decl *, DeclArgumentPack *>, 4>;
283 
284  /// A mapping from local declarations that occur
285  /// within a template to their instantiations.
286  ///
287  /// This mapping is used during instantiation to keep track of,
288  /// e.g., function parameter and variable declarations. For example,
289  /// given:
290  ///
291  /// \code
292  /// template<typename T> T add(T x, T y) { return x + y; }
293  /// \endcode
294  ///
295  /// when we instantiate add<int>, we will introduce a mapping from
296  /// the ParmVarDecl for 'x' that occurs in the template to the
297  /// instantiated ParmVarDecl for 'x'.
298  ///
299  /// For a parameter pack, the local instantiation scope may contain a
300  /// set of instantiated parameters. This is stored as a DeclArgumentPack
301  /// pointer.
302  LocalDeclsMap LocalDecls;
303 
304  /// The set of argument packs we've allocated.
306 
307  /// The outer scope, which contains local variable
308  /// definitions from some other instantiation (that may not be
309  /// relevant to this particular scope).
311 
312  /// Whether we have already exited this scope.
313  bool Exited = false;
314 
315  /// Whether to combine this scope with the outer scope, such that
316  /// lookup will search our outer scope.
317  bool CombineWithOuterScope;
318 
319  /// If non-NULL, the template parameter pack that has been
320  /// partially substituted per C++0x [temp.arg.explicit]p9.
321  NamedDecl *PartiallySubstitutedPack = nullptr;
322 
323  /// If \c PartiallySubstitutedPack is non-null, the set of
324  /// explicitly-specified template arguments in that pack.
325  const TemplateArgument *ArgsInPartiallySubstitutedPack;
326 
327  /// If \c PartiallySubstitutedPack, the number of
328  /// explicitly-specified template arguments in
329  /// ArgsInPartiallySubstitutedPack.
330  unsigned NumArgsInPartiallySubstitutedPack;
331 
332  public:
333  LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false)
334  : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope),
335  CombineWithOuterScope(CombineWithOuterScope) {
336  SemaRef.CurrentInstantiationScope = this;
337  }
338 
341  operator=(const LocalInstantiationScope &) = delete;
342 
344  Exit();
345  }
346 
347  const Sema &getSema() const { return SemaRef; }
348 
349  /// Exit this local instantiation scope early.
350  void Exit() {
351  if (Exited)
352  return;
353 
354  for (unsigned I = 0, N = ArgumentPacks.size(); I != N; ++I)
355  delete ArgumentPacks[I];
356 
357  SemaRef.CurrentInstantiationScope = Outer;
358  Exited = true;
359  }
360 
361  /// Clone this scope, and all outer scopes, down to the given
362  /// outermost scope.
364  if (this == Outermost) return this;
365 
366  // Save the current scope from SemaRef since the LocalInstantiationScope
367  // will overwrite it on construction
369 
370  LocalInstantiationScope *newScope =
371  new LocalInstantiationScope(SemaRef, CombineWithOuterScope);
372 
373  newScope->Outer = nullptr;
374  if (Outer)
375  newScope->Outer = Outer->cloneScopes(Outermost);
376 
377  newScope->PartiallySubstitutedPack = PartiallySubstitutedPack;
378  newScope->ArgsInPartiallySubstitutedPack = ArgsInPartiallySubstitutedPack;
379  newScope->NumArgsInPartiallySubstitutedPack =
380  NumArgsInPartiallySubstitutedPack;
381 
382  for (LocalDeclsMap::iterator I = LocalDecls.begin(), E = LocalDecls.end();
383  I != E; ++I) {
384  const Decl *D = I->first;
385  llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored =
386  newScope->LocalDecls[D];
387  if (I->second.is<Decl *>()) {
388  Stored = I->second.get<Decl *>();
389  } else {
390  DeclArgumentPack *OldPack = I->second.get<DeclArgumentPack *>();
391  DeclArgumentPack *NewPack = new DeclArgumentPack(*OldPack);
392  Stored = NewPack;
393  newScope->ArgumentPacks.push_back(NewPack);
394  }
395  }
396  // Restore the saved scope to SemaRef
397  SemaRef.CurrentInstantiationScope = oldScope;
398  return newScope;
399  }
400 
401  /// deletes the given scope, and all otuer scopes, down to the
402  /// given outermost scope.
404  LocalInstantiationScope *Outermost) {
405  while (Scope && Scope != Outermost) {
406  LocalInstantiationScope *Out = Scope->Outer;
407  delete Scope;
408  Scope = Out;
409  }
410  }
411 
412  /// Find the instantiation of the declaration D within the current
413  /// instantiation scope.
414  ///
415  /// \param D The declaration whose instantiation we are searching for.
416  ///
417  /// \returns A pointer to the declaration or argument pack of declarations
418  /// to which the declaration \c D is instantiated, if found. Otherwise,
419  /// returns NULL.
420  llvm::PointerUnion<Decl *, DeclArgumentPack *> *
421  findInstantiationOf(const Decl *D);
422 
423  void InstantiatedLocal(const Decl *D, Decl *Inst);
424  void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst);
425  void MakeInstantiatedLocalArgPack(const Decl *D);
426 
427  /// Note that the given parameter pack has been partially substituted
428  /// via explicit specification of template arguments
429  /// (C++0x [temp.arg.explicit]p9).
430  ///
431  /// \param Pack The parameter pack, which will always be a template
432  /// parameter pack.
433  ///
434  /// \param ExplicitArgs The explicitly-specified template arguments provided
435  /// for this parameter pack.
436  ///
437  /// \param NumExplicitArgs The number of explicitly-specified template
438  /// arguments provided for this parameter pack.
440  const TemplateArgument *ExplicitArgs,
441  unsigned NumExplicitArgs);
442 
443  /// Reset the partially-substituted pack when it is no longer of
444  /// interest.
446  assert(PartiallySubstitutedPack && "No partially-substituted pack");
447  PartiallySubstitutedPack = nullptr;
448  ArgsInPartiallySubstitutedPack = nullptr;
449  NumArgsInPartiallySubstitutedPack = 0;
450  }
451 
452  /// Retrieve the partially-substitued template parameter pack.
453  ///
454  /// If there is no partially-substituted parameter pack, returns NULL.
455  NamedDecl *
456  getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs = nullptr,
457  unsigned *NumExplicitArgs = nullptr) const;
458 
459  /// Determine whether D is a pack expansion created in this scope.
460  bool isLocalPackExpansion(const Decl *D);
461  };
462 
464  : public DeclVisitor<TemplateDeclInstantiator, Decl *>
465  {
466  Sema &SemaRef;
468  DeclContext *Owner;
469  const MultiLevelTemplateArgumentList &TemplateArgs;
470  Sema::LateInstantiatedAttrVec* LateAttrs = nullptr;
471  LocalInstantiationScope *StartingScope = nullptr;
472 
473  /// A list of out-of-line class template partial
474  /// specializations that will need to be instantiated after the
475  /// enclosing class's instantiation is complete.
476  SmallVector<std::pair<ClassTemplateDecl *,
478  OutOfLinePartialSpecs;
479 
480  /// A list of out-of-line variable template partial
481  /// specializations that will need to be instantiated after the
482  /// enclosing variable's instantiation is complete.
483  /// FIXME: Verify that this is needed.
484  SmallVector<
485  std::pair<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>, 4>
486  OutOfLineVarPartialSpecs;
487 
488  public:
490  const MultiLevelTemplateArgumentList &TemplateArgs)
491  : SemaRef(SemaRef),
492  SubstIndex(SemaRef, SemaRef.ArgumentPackSubstitutionIndex),
493  Owner(Owner), TemplateArgs(TemplateArgs) {}
494 
495 // Define all the decl visitors using DeclNodes.inc
496 #define DECL(DERIVED, BASE) \
497  Decl *Visit ## DERIVED ## Decl(DERIVED ## Decl *D);
498 #define ABSTRACT_DECL(DECL)
499 
500 // Decls which never appear inside a class or function.
501 #define OBJCCONTAINER(DERIVED, BASE)
502 #define FILESCOPEASM(DERIVED, BASE)
503 #define IMPORT(DERIVED, BASE)
504 #define EXPORT(DERIVED, BASE)
505 #define LINKAGESPEC(DERIVED, BASE)
506 #define OBJCCOMPATIBLEALIAS(DERIVED, BASE)
507 #define OBJCMETHOD(DERIVED, BASE)
508 #define OBJCTYPEPARAM(DERIVED, BASE)
509 #define OBJCIVAR(DERIVED, BASE)
510 #define OBJCPROPERTY(DERIVED, BASE)
511 #define OBJCPROPERTYIMPL(DERIVED, BASE)
512 #define EMPTY(DERIVED, BASE)
513 #define LIFETIMEEXTENDEDTEMPORARY(DERIVED, BASE)
514 
515  // Decls which use special-case instantiation code.
516 #define BLOCK(DERIVED, BASE)
517 #define CAPTURED(DERIVED, BASE)
518 #define IMPLICITPARAM(DERIVED, BASE)
519 
520 #include "clang/AST/DeclNodes.inc"
521 
523 
525  TypeSourceInfo *&TInfo,
526  DeclarationNameInfo &NameInfo);
527 
528  // A few supplemental visitor functions.
530  TemplateParameterList *TemplateParams,
532  ClassScopeSpecializationArgs = llvm::None,
535  TemplateParameterList *TemplateParams,
537  Decl *VisitDecl(Decl *D);
538  Decl *VisitVarDecl(VarDecl *D, bool InstantiatingVarTemplate,
539  ArrayRef<BindingDecl *> *Bindings = nullptr);
541  LookupResult *Lookup);
542 
543  // Enable late instantiation of attributes. Late instantiated attributes
544  // will be stored in LA.
546  LateAttrs = LA;
547  StartingScope = SemaRef.CurrentInstantiationScope;
548  }
549 
550  // Disable late instantiation of attributes.
552  LateAttrs = nullptr;
553  StartingScope = nullptr;
554  }
555 
556  LocalInstantiationScope *getStartingScope() const { return StartingScope; }
557 
560 
563 
564  /// Return an iterator to the beginning of the set of
565  /// "delayed" partial specializations, which must be passed to
566  /// InstantiateClassTemplatePartialSpecialization once the class
567  /// definition has been completed.
569  return OutOfLinePartialSpecs.begin();
570  }
571 
573  return OutOfLineVarPartialSpecs.begin();
574  }
575 
576  /// Return an iterator to the end of the set of
577  /// "delayed" partial specializations, which must be passed to
578  /// InstantiateClassTemplatePartialSpecialization once the class
579  /// definition has been completed.
581  return OutOfLinePartialSpecs.end();
582  }
583 
585  return OutOfLineVarPartialSpecs.end();
586  }
587 
588  // Helper functions for instantiating methods.
593 
595 
598 
599  bool SubstQualifier(const DeclaratorDecl *OldDecl,
600  DeclaratorDecl *NewDecl);
601  bool SubstQualifier(const TagDecl *OldDecl,
602  TagDecl *NewDecl);
603 
605  VarTemplateDecl *VarTemplate, VarDecl *FromVar,
606  const TemplateArgumentListInfo &TemplateArgsInfo,
607  ArrayRef<TemplateArgument> Converted,
608  VarTemplateSpecializationDecl *PrevDecl = nullptr);
609 
610  Decl *InstantiateTypedefNameDecl(TypedefNameDecl *D, bool IsTypeAlias);
613  ClassTemplateDecl *ClassTemplate,
617  VarTemplateDecl *VarTemplate,
619  void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern);
620 
621  private:
622  template<typename T>
623  Decl *instantiateUnresolvedUsingDecl(T *D,
624  bool InstantiatingPackElement = false);
625  };
626 
627 } // namespace clang
628 
629 #endif // LLVM_CLANG_SEMA_TEMPLATE_H
clang::MultiLevelTemplateArgumentList::setArgument
void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg)
Clear out a specific template argument.
Definition: Template.h:162
clang::TemplateDeclInstantiator::VisitVarTemplateSpecializationDecl
Decl * VisitVarTemplateSpecializationDecl(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentListInfo &TemplateArgsInfo, ArrayRef< TemplateArgument > Converted, VarTemplateSpecializationDecl *PrevDecl=nullptr)
Definition: SemaTemplateInstantiateDecl.cpp:3735
clang::TemplateDeclInstantiator::delayed_var_partial_spec_begin
delayed_var_partial_spec_iterator delayed_var_partial_spec_begin()
Definition: Template.h:572
clang::MultiLevelTemplateArgumentList::addOuterTemplateArguments
void addOuterTemplateArguments(ArgList Args)
Add a new outmost level to the multi-level template argument list.
Definition: Template.h:180
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::TPOC_Conversion
@ TPOC_Conversion
Partial ordering of function templates for a call to a conversion function.
Definition: Template.h:209
llvm::SmallVector
Definition: LLVM.h:38
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::TemplateDeclInstantiator::RewriteKind::None
@ None
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
clang::MultiLevelTemplateArgumentList::getKind
TemplateSubstitutionKind getKind() const
Determine the kind of template substitution being performed.
Definition: Template.h:103
clang::TemplateDeclInstantiator::SubstTemplateParams
TemplateParameterList * SubstTemplateParams(TemplateParameterList *List)
Instantiates a nested template parameter list in the current instantiation context.
Definition: SemaTemplateInstantiateDecl.cpp:3944
clang::TemplateSubstitutionKind::Rewrite
@ Rewrite
We are substituting template parameters for (typically) other template parameters in order to rewrite...
clang::LookupResult
Represents the results of name lookup.
Definition: Lookup.h:46
clang::TemplateDeclInstantiator::delayed_var_partial_spec_iterator
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
Definition: Template.h:562
clang::DeducedTemplateArgument::DeducedTemplateArgument
DeducedTemplateArgument(const TemplateArgument &Arg, bool DeducedFromArrayBound=false)
Definition: Template.h:240
clang::TemplateDeclInstantiator::RewriteKind::RewriteSpaceshipAsEqualEqual
@ RewriteSpaceshipAsEqualEqual
clang::TemplateSubstitutionKind::Specialization
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
clang::DeducedTemplateArgument::DeducedTemplateArgument
DeducedTemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value, QualType ValueType, bool DeducedFromArrayBound)
Construct an integral non-type template argument that has been deduced, possibly from an array bound.
Definition: Template.h:246
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
llvm::Optional
Definition: LLVM.h:40
clang::DeducedTemplateArgument
Captures a template argument whose value has been deduced via c++ template argument deduction.
Definition: Template.h:232
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::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2076
clang::TemplateDeclInstantiator::disableLateAttributeInstantiation
void disableLateAttributeInstantiation()
Definition: Template.h:551
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2665
clang::TPOC_Other
@ TPOC_Other
Partial ordering of function templates in other contexts, e.g., taking the address of a function temp...
Definition: Template.h:214
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3595
clang::TemplateArgumentList::data
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
Definition: DeclTemplate.h:300
clang::MultiLevelTemplateArgumentList::MultiLevelTemplateArgumentList
MultiLevelTemplateArgumentList(const TemplateArgumentList &TemplateArgs)
Construct a single-level template argument list.
Definition: Template.h:96
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
APSInt
llvm::APSInt APSInt
Definition: ByteCodeEmitter.cpp:19
TemplateBase.h
DeclTemplate.h
clang::TemplateDeclInstantiator::SubstDefaultedFunction
bool SubstDefaultedFunction(FunctionDecl *New, FunctionDecl *Tmpl)
Definition: SemaTemplateInstantiateDecl.cpp:4710
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:8925
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
clang::TemplateDeclInstantiator::adjustForRewrite
void adjustForRewrite(RewriteKind RK, FunctionDecl *Orig, QualType &T, TypeSourceInfo *&TInfo, DeclarationNameInfo &NameInfo)
Definition: SemaTemplateInstantiateDecl.cpp:3868
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::TemplateDeclInstantiator::RewriteKind
RewriteKind
Definition: Template.h:522
clang::LocalInstantiationScope::Exit
void Exit()
Exit this local instantiation scope early.
Definition: Template.h:350
Depth
int Depth
Definition: ASTDiff.cpp:191
clang::DeducedTemplateArgument::setDeducedFromArrayBound
void setDeducedFromArrayBound(bool Deduced)
Specify whether the given non-type template argument was deduced from an array bound.
Definition: Template.h:259
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:62
clang::MultiLevelTemplateArgumentList
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition: Template.h:75
Type.h
clang::TemplateDeclInstantiator::VisitFunctionDecl
Decl * VisitFunctionDecl(FunctionDecl *D, TemplateParameterList *TemplateParams, RewriteKind RK=RewriteKind::None)
Normal class members are of more specific types and therefore don't make it here.
Definition: SemaTemplateInstantiateDecl.cpp:1944
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:876
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3333
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::MultiLevelTemplateArgumentList::getNumLevels
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
Definition: Template.h:114
clang::DeducedTemplateArgument::wasDeducedFromArrayBound
bool wasDeducedFromArrayBound() const
For a non-type template argument, determine whether the template argument was deduced from an array b...
Definition: Template.h:255
clang::TemplateDeclInstantiator::VisitBaseUsingDecls
Decl * VisitBaseUsingDecls(BaseUsingDecl *D, BaseUsingDecl *Inst, LookupResult *Lookup)
Definition: SemaTemplateInstantiateDecl.cpp:3052
clang::LocalInstantiationScope::DeclArgumentPack
SmallVector< VarDecl *, 4 > DeclArgumentPack
A set of declarations.
Definition: Template.h:273
Sema.h
clang::MultiLevelTemplateArgumentList::getNumRetainedOuterLevels
unsigned getNumRetainedOuterLevels() const
Definition: Template.h:124
clang::LocalInstantiationScope::~LocalInstantiationScope
~LocalInstantiationScope()
Definition: Template.h:343
clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl
Decl * InstantiateTypedefNameDecl(TypedefNameDecl *D, bool IsTypeAlias)
Definition: SemaTemplateInstantiateDecl.cpp:881
clang::TemplateDeclInstantiator::delayed_var_partial_spec_end
delayed_var_partial_spec_iterator delayed_var_partial_spec_end()
Definition: Template.h:584
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::TemplateDeclInstantiator::VisitCXXMethodDecl
Decl * VisitCXXMethodDecl(CXXMethodDecl *D, TemplateParameterList *TemplateParams, Optional< const ASTTemplateArgumentListInfo * > ClassScopeSpecializationArgs=llvm::None, RewriteKind RK=RewriteKind::None)
Definition: SemaTemplateInstantiateDecl.cpp:2274
clang::TemplateDeclInstantiator::SubstQualifier
bool SubstQualifier(const DeclaratorDecl *OldDecl, DeclaratorDecl *NewDecl)
Definition: SemaTemplateInstantiateDecl.cpp:72
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::LocalInstantiationScope::cloneScopes
LocalInstantiationScope * cloneScopes(LocalInstantiationScope *Outermost)
Clone this scope, and all outer scopes, down to the given outermost scope.
Definition: Template.h:363
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::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2248
clang::LocalInstantiationScope::getSema
const Sema & getSema() const
Definition: Template.h:347
clang::TemplateSubstitutionKind
TemplateSubstitutionKind
The kind of template substitution being performed.
Definition: Template.h:46
clang::VarTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2926
clang::TemplateDeclInstantiator::InstantiateEnumDefinition
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
Definition: SemaTemplateInstantiateDecl.cpp:1436
clang::LocalInstantiationScope::operator=
LocalInstantiationScope & operator=(const LocalInstantiationScope &)=delete
llvm::ArrayRef
Definition: LLVM.h:34
DeclVisitor.h
Value
Value
Definition: UninitializedValues.cpp:102
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::DeclaratorDecl
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:728
clang::MultiLevelTemplateArgumentList::getInnermost
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
Definition: Template.h:197
clang::TemplatePartialOrderingContext
Definition: Template.h:221
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:354
LLVM.h
clang::TemplateDeclInstantiator::VisitDecl
Decl * VisitDecl(Decl *D)
Definition: SemaTemplateInstantiateDecl.cpp:3851
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:237
clang::TemplateDeclInstantiator::InitMethodInstantiation
bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl)
Initializes common fields of an instantiated method declaration (New) from the corresponding fields o...
Definition: SemaTemplateInstantiateDecl.cpp:4694
clang::Sema::CurrentInstantiationScope
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:9233
clang::TemplateDeclInstantiator::InitFunctionInstantiation
bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl)
Initializes the common fields of an instantiation function declaration (New) from the corresponding f...
Definition: SemaTemplateInstantiateDecl.cpp:4604
clang::DeducedTemplateArgument::DeducedTemplateArgument
DeducedTemplateArgument()=default
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::MultiLevelTemplateArgumentList::addOuterRetainedLevels
void addOuterRetainedLevels(unsigned Num)
Definition: Template.h:192
clang::MultiLevelTemplateArgumentList::setKind
void setKind(TemplateSubstitutionKind K)
Definition: Template.h:100
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::MultiLevelTemplateArgumentList::getNumSubstitutedLevels
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
Definition: Template.h:120
clang
Definition: CalledOnceCheck.h:17
clang::TPOC
TPOC
The context in which partial ordering of function templates occurs.
Definition: Template.h:203
clang::MultiLevelTemplateArgumentList::operator()
const TemplateArgument & operator()(unsigned Depth, unsigned Index) const
Retrieve the template argument at a given depth and index.
Definition: Template.h:139
clang::TemplateDeclInstantiator::TemplateDeclInstantiator
TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition: Template.h:489
clang::LocalInstantiationScope::LocalInstantiationScope
LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope=false)
Definition: Template.h:333
clang::DeclVisitor
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:66
clang::TPOC_Call
@ TPOC_Call
Partial ordering of function templates for a function call.
Definition: Template.h:205
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6399
clang::TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
Definition: SemaTemplateInstantiateDecl.cpp:4128
clang::LocalInstantiationScope
A stack-allocated class that identifies which local variable declaration instantiations are present i...
Definition: Template.h:270
clang::LocalInstantiationScope::ResetPartiallySubstitutedPack
void ResetPartiallySubstitutedPack()
Reset the partially-substituted pack when it is no longer of interest.
Definition: Template.h:445
clang::LocalInstantiationScope::InstantiatedLocalPackArg
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
Definition: SemaTemplateInstantiate.cpp:3636
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3185
clang::TemplateDeclInstantiator::delayed_partial_spec_iterator
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
Definition: Template.h:559
clang::TemplatePartialOrderingContext::TemplatePartialOrderingContext
TemplatePartialOrderingContext(TPOC Value)
Definition: Template.h:225
clang::TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
Definition: SemaTemplateInstantiateDecl.cpp:4001
clang::TemplateDeclInstantiator::SubstFunctionType
TypeSourceInfo * SubstFunctionType(FunctionDecl *D, SmallVectorImpl< ParmVarDecl * > &Params)
Definition: SemaTemplateInstantiateDecl.cpp:4254
clang::MultiLevelTemplateArgumentList::MultiLevelTemplateArgumentList
MultiLevelTemplateArgumentList()=default
Construct an empty set of template argument lists.
clang::MultiLevelTemplateArgumentList::isRewrite
bool isRewrite() const
Determine whether we are rewriting template parameters rather than substituting for them.
Definition: Template.h:108
clang::TemplateDeclInstantiator::getStartingScope
LocalInstantiationScope * getStartingScope() const
Definition: Template.h:556
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3080
clang::BaseUsingDecl
Represents a C++ declaration that introduces decls from somewhere else.
Definition: DeclCXX.h:3284
clang::MultiLevelTemplateArgumentList::addOuterRetainedLevel
void addOuterRetainedLevel()
Add an outermost level that we are not substituting.
Definition: Template.h:189
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:758
clang::LocalInstantiationScope::isLocalPackExpansion
bool isLocalPackExpansion(const Decl *D)
Determine whether D is a pack expansion created in this scope.
Definition: SemaTemplateInstantiate.cpp:3659
clang::TemplateArgumentList::size
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:297
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1857
clang::LocalInstantiationScope::MakeInstantiatedLocalArgPack
void MakeInstantiatedLocalArgPack(const Decl *D)
Definition: SemaTemplateInstantiate.cpp:3643
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::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1948
clang::TemplateDeclInstantiator::VisitVarDecl
Decl * VisitVarDecl(VarDecl *D, bool InstantiatingVarTemplate, ArrayRef< BindingDecl * > *Bindings=nullptr)
Definition: SemaTemplateInstantiateDecl.cpp:1042
clang::MultiLevelTemplateArgumentList::addOuterTemplateArguments
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
Definition: Template.h:173
clang::TemplateDeclInstantiator::enableLateAttributeInstantiation
void enableLateAttributeInstantiation(Sema::LateInstantiatedAttrVec *LA)
Definition: Template.h:545
clang::LocalInstantiationScope::InstantiatedLocal
void InstantiatedLocal(const Decl *D, Decl *Inst)
Definition: SemaTemplateInstantiate.cpp:3615