clang  16.0.0git
DeclTemplate.h
Go to the documentation of this file.
1 //===- DeclTemplate.h - Classes for representing 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 //
9 /// \file
10 /// Defines the C++ template declaration subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_DECLTEMPLATE_H
15 #define LLVM_CLANG_AST_DECLTEMPLATE_H
16 
17 #include "clang/AST/ASTConcept.h"
18 #include "clang/AST/ASTContext.h"
19 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclBase.h"
21 #include "clang/AST/DeclCXX.h"
23 #include "clang/AST/Redeclarable.h"
24 #include "clang/AST/TemplateBase.h"
25 #include "clang/AST/Type.h"
26 #include "clang/Basic/LLVM.h"
28 #include "clang/Basic/Specifiers.h"
29 #include "llvm/ADT/ArrayRef.h"
30 #include "llvm/ADT/FoldingSet.h"
31 #include "llvm/ADT/PointerIntPair.h"
32 #include "llvm/ADT/PointerUnion.h"
33 #include "llvm/ADT/iterator.h"
34 #include "llvm/ADT/iterator_range.h"
35 #include "llvm/Support/Casting.h"
36 #include "llvm/Support/Compiler.h"
37 #include "llvm/Support/TrailingObjects.h"
38 #include <cassert>
39 #include <cstddef>
40 #include <cstdint>
41 #include <iterator>
42 #include <utility>
43 
44 namespace clang {
45 
47 class ClassTemplateDecl;
48 class ClassTemplatePartialSpecializationDecl;
49 class Expr;
50 class FunctionTemplateDecl;
51 class IdentifierInfo;
52 class NonTypeTemplateParmDecl;
53 class TemplateDecl;
54 class TemplateTemplateParmDecl;
55 class TemplateTypeParmDecl;
56 class ConceptDecl;
57 class UnresolvedSetImpl;
58 class VarTemplateDecl;
59 class VarTemplatePartialSpecializationDecl;
60 
61 /// Stores a template parameter of any kind.
62 using TemplateParameter =
63  llvm::PointerUnion<TemplateTypeParmDecl *, NonTypeTemplateParmDecl *,
65 
67 
68 /// Stores a list of template parameters for a TemplateDecl and its
69 /// derived classes.
71  : private llvm::TrailingObjects<TemplateParameterList, NamedDecl *,
72  Expr *> {
73  /// The location of the 'template' keyword.
74  SourceLocation TemplateLoc;
75 
76  /// The locations of the '<' and '>' angle brackets.
77  SourceLocation LAngleLoc, RAngleLoc;
78 
79  /// The number of template parameters in this template
80  /// parameter list.
81  unsigned NumParams : 29;
82 
83  /// Whether this template parameter list contains an unexpanded parameter
84  /// pack.
85  unsigned ContainsUnexpandedParameterPack : 1;
86 
87  /// Whether this template parameter list has a requires clause.
88  unsigned HasRequiresClause : 1;
89 
90  /// Whether any of the template parameters has constrained-parameter
91  /// constraint-expression.
92  unsigned HasConstrainedParameters : 1;
93 
94 protected:
95  TemplateParameterList(const ASTContext& C, SourceLocation TemplateLoc,
96  SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
97  SourceLocation RAngleLoc, Expr *RequiresClause);
98 
99  size_t numTrailingObjects(OverloadToken<NamedDecl *>) const {
100  return NumParams;
101  }
102 
103  size_t numTrailingObjects(OverloadToken<Expr *>) const {
104  return HasRequiresClause ? 1 : 0;
105  }
106 
107 public:
108  template <size_t N, bool HasRequiresClause>
111 
112  static TemplateParameterList *Create(const ASTContext &C,
113  SourceLocation TemplateLoc,
114  SourceLocation LAngleLoc,
115  ArrayRef<NamedDecl *> Params,
116  SourceLocation RAngleLoc,
117  Expr *RequiresClause);
118 
119  /// Iterates through the template parameters in this list.
120  using iterator = NamedDecl **;
121 
122  /// Iterates through the template parameters in this list.
123  using const_iterator = NamedDecl * const *;
124 
125  iterator begin() { return getTrailingObjects<NamedDecl *>(); }
126  const_iterator begin() const { return getTrailingObjects<NamedDecl *>(); }
127  iterator end() { return begin() + NumParams; }
128  const_iterator end() const { return begin() + NumParams; }
129 
130  unsigned size() const { return NumParams; }
131 
133  return llvm::makeArrayRef(begin(), end());
134  }
136  return llvm::makeArrayRef(begin(), size());
137  }
138 
139  NamedDecl* getParam(unsigned Idx) {
140  assert(Idx < size() && "Template parameter index out-of-range");
141  return begin()[Idx];
142  }
143  const NamedDecl* getParam(unsigned Idx) const {
144  assert(Idx < size() && "Template parameter index out-of-range");
145  return begin()[Idx];
146  }
147 
148  /// Returns the minimum number of arguments needed to form a
149  /// template specialization.
150  ///
151  /// This may be fewer than the number of template parameters, if some of
152  /// the parameters have default arguments or if there is a parameter pack.
153  unsigned getMinRequiredArguments() const;
154 
155  /// Get the depth of this template parameter list in the set of
156  /// template parameter lists.
157  ///
158  /// The first template parameter list in a declaration will have depth 0,
159  /// the second template parameter list will have depth 1, etc.
160  unsigned getDepth() const;
161 
162  /// Determine whether this template parameter list contains an
163  /// unexpanded parameter pack.
164  bool containsUnexpandedParameterPack() const;
165 
166  /// Determine whether this template parameter list contains a parameter pack.
167  bool hasParameterPack() const {
168  for (const NamedDecl *P : asArray())
169  if (P->isParameterPack())
170  return true;
171  return false;
172  }
173 
174  /// The constraint-expression of the associated requires-clause.
176  return HasRequiresClause ? getTrailingObjects<Expr *>()[0] : nullptr;
177  }
178 
179  /// The constraint-expression of the associated requires-clause.
180  const Expr *getRequiresClause() const {
181  return HasRequiresClause ? getTrailingObjects<Expr *>()[0] : nullptr;
182  }
183 
184  /// \brief All associated constraints derived from this template parameter
185  /// list, including the requires clause and any constraints derived from
186  /// constrained-parameters.
187  ///
188  /// The constraints in the resulting list are to be treated as if in a
189  /// conjunction ("and").
191 
192  bool hasAssociatedConstraints() const;
193 
194  SourceLocation getTemplateLoc() const { return TemplateLoc; }
195  SourceLocation getLAngleLoc() const { return LAngleLoc; }
196  SourceLocation getRAngleLoc() const { return RAngleLoc; }
197 
198  SourceRange getSourceRange() const LLVM_READONLY {
199  return SourceRange(TemplateLoc, RAngleLoc);
200  }
201 
202  void print(raw_ostream &Out, const ASTContext &Context,
203  bool OmitTemplateKW = false) const;
204  void print(raw_ostream &Out, const ASTContext &Context,
205  const PrintingPolicy &Policy, bool OmitTemplateKW = false) const;
206 
208  const TemplateParameterList *TPL,
209  unsigned Idx);
210 };
211 
212 /// Stores a list of template parameters and the associated
213 /// requires-clause (if any) for a TemplateDecl and its derived classes.
214 /// Suitable for creating on the stack.
215 template <size_t N, bool HasRequiresClause>
217  : public TemplateParameterList::FixedSizeStorageOwner {
218  typename TemplateParameterList::FixedSizeStorage<
219  NamedDecl *, Expr *>::with_counts<
220  N, HasRequiresClause ? 1u : 0u
221  >::type storage;
222 
223 public:
225  SourceLocation TemplateLoc,
226  SourceLocation LAngleLoc,
227  ArrayRef<NamedDecl *> Params,
228  SourceLocation RAngleLoc,
229  Expr *RequiresClause)
230  : FixedSizeStorageOwner(
231  (assert(N == Params.size()),
232  assert(HasRequiresClause == (RequiresClause != nullptr)),
233  new (static_cast<void *>(&storage)) TemplateParameterList(C,
234  TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {}
235 };
236 
237 /// A template argument list.
239  : private llvm::TrailingObjects<TemplateArgumentList, TemplateArgument> {
240  /// The template argument list.
241  const TemplateArgument *Arguments;
242 
243  /// The number of template arguments in this template
244  /// argument list.
245  unsigned NumArguments;
246 
247  // Constructs an instance with an internal Argument list, containing
248  // a copy of the Args array. (Called by CreateCopy)
250 
251 public:
253 
254  TemplateArgumentList(const TemplateArgumentList &) = delete;
256 
257  /// Type used to indicate that the template argument list itself is a
258  /// stack object. It does not own its template arguments.
260 
261  /// Create a new template argument list that copies the given set of
262  /// template arguments.
263  static TemplateArgumentList *CreateCopy(ASTContext &Context,
265 
266  /// Construct a new, temporary template argument list on the stack.
267  ///
268  /// The template argument list does not own the template arguments
269  /// provided.
271  : Arguments(Args.data()), NumArguments(Args.size()) {}
272 
273  /// Produces a shallow copy of the given template argument list.
274  ///
275  /// This operation assumes that the input argument list outlives it.
276  /// This takes the list as a pointer to avoid looking like a copy
277  /// constructor, since this really really isn't safe to use that
278  /// way.
280  : Arguments(Other->data()), NumArguments(Other->size()) {}
281 
282  /// Retrieve the template argument at a given index.
283  const TemplateArgument &get(unsigned Idx) const {
284  assert(Idx < NumArguments && "Invalid template argument index");
285  return data()[Idx];
286  }
287 
288  /// Retrieve the template argument at a given index.
289  const TemplateArgument &operator[](unsigned Idx) const { return get(Idx); }
290 
291  /// Produce this as an array ref.
293  return llvm::makeArrayRef(data(), size());
294  }
295 
296  /// Retrieve the number of template arguments in this
297  /// template argument list.
298  unsigned size() const { return NumArguments; }
299 
300  /// Retrieve a pointer to the template argument list.
301  const TemplateArgument *data() const { return Arguments; }
302 };
303 
304 void *allocateDefaultArgStorageChain(const ASTContext &C);
305 
306 /// Storage for a default argument. This is conceptually either empty, or an
307 /// argument value, or a pointer to a previous declaration that had a default
308 /// argument.
309 ///
310 /// However, this is complicated by modules: while we require all the default
311 /// arguments for a template to be equivalent, there may be more than one, and
312 /// we need to track all the originating parameters to determine if the default
313 /// argument is visible.
314 template<typename ParmDecl, typename ArgType>
316  /// Storage for both the value *and* another parameter from which we inherit
317  /// the default argument. This is used when multiple default arguments for a
318  /// parameter are merged together from different modules.
319  struct Chain {
320  ParmDecl *PrevDeclWithDefaultArg;
321  ArgType Value;
322  };
323  static_assert(sizeof(Chain) == sizeof(void *) * 2,
324  "non-pointer argument type?");
325 
326  llvm::PointerUnion<ArgType, ParmDecl*, Chain*> ValueOrInherited;
327 
328  static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
329  const DefaultArgStorage &Storage = Parm->getDefaultArgStorage();
330  if (auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
331  Parm = Prev;
332  assert(!Parm->getDefaultArgStorage()
333  .ValueOrInherited.template is<ParmDecl *>() &&
334  "should only be one level of indirection");
335  return Parm;
336  }
337 
338 public:
339  DefaultArgStorage() : ValueOrInherited(ArgType()) {}
340 
341  /// Determine whether there is a default argument for this parameter.
342  bool isSet() const { return !ValueOrInherited.isNull(); }
343 
344  /// Determine whether the default argument for this parameter was inherited
345  /// from a previous declaration of the same entity.
346  bool isInherited() const { return ValueOrInherited.template is<ParmDecl*>(); }
347 
348  /// Get the default argument's value. This does not consider whether the
349  /// default argument is visible.
350  ArgType get() const {
351  const DefaultArgStorage *Storage = this;
352  if (const auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl *>())
353  Storage = &Prev->getDefaultArgStorage();
354  if (const auto *C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
355  return C->Value;
356  return Storage->ValueOrInherited.template get<ArgType>();
357  }
358 
359  /// Get the parameter from which we inherit the default argument, if any.
360  /// This is the parameter on which the default argument was actually written.
361  const ParmDecl *getInheritedFrom() const {
362  if (const auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>())
363  return D;
364  if (const auto *C = ValueOrInherited.template dyn_cast<Chain *>())
365  return C->PrevDeclWithDefaultArg;
366  return nullptr;
367  }
368 
369  /// Set the default argument.
370  void set(ArgType Arg) {
371  assert(!isSet() && "default argument already set");
372  ValueOrInherited = Arg;
373  }
374 
375  /// Set that the default argument was inherited from another parameter.
376  void setInherited(const ASTContext &C, ParmDecl *InheritedFrom) {
377  InheritedFrom = getParmOwningDefaultArg(InheritedFrom);
378  if (!isSet())
379  ValueOrInherited = InheritedFrom;
380  else if (auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>()) {
381  assert(C.isSameDefaultTemplateArgument(D, InheritedFrom));
382  ValueOrInherited =
383  new (allocateDefaultArgStorageChain(C)) Chain{InheritedFrom, get()};
384  } else if (auto *Inherited =
385  ValueOrInherited.template dyn_cast<Chain *>()) {
386  assert(C.isSameDefaultTemplateArgument(Inherited->PrevDeclWithDefaultArg,
387  InheritedFrom));
388  Inherited->PrevDeclWithDefaultArg = InheritedFrom;
389  } else
390  ValueOrInherited = new (allocateDefaultArgStorageChain(C))
391  Chain{InheritedFrom, ValueOrInherited.template get<ArgType>()};
392  }
393 
394  /// Remove the default argument, even if it was inherited.
395  void clear() {
396  ValueOrInherited = ArgType();
397  }
398 };
399 
400 //===----------------------------------------------------------------------===//
401 // Kinds of Templates
402 //===----------------------------------------------------------------------===//
403 
404 /// \brief The base class of all kinds of template declarations (e.g.,
405 /// class, function, etc.).
406 ///
407 /// The TemplateDecl class stores the list of template parameters and a
408 /// reference to the templated scoped declaration: the underlying AST node.
409 class TemplateDecl : public NamedDecl {
410  void anchor() override;
411 
412 protected:
413  // Construct a template decl with name, parameters, and templated element.
416 
417  // Construct a template decl with the given name and parameters.
418  // Used when there is no templated element (e.g., for tt-params).
420  TemplateParameterList *Params)
421  : TemplateDecl(DK, DC, L, Name, Params, nullptr) {}
422 
423 public:
424  friend class ASTDeclReader;
425  friend class ASTDeclWriter;
426 
427  /// Get the list of template parameters
429  return TemplateParams;
430  }
431 
432  /// \brief Get the total constraint-expression associated with this template,
433  /// including constraint-expressions derived from the requires-clause,
434  /// trailing requires-clause (for functions and methods) and constrained
435  /// template parameters.
437 
438  bool hasAssociatedConstraints() const;
439 
440  /// Get the underlying, templated declaration.
442 
443  // Should a specialization behave like an alias for another type.
444  bool isTypeAlias() const;
445 
446  // Implement isa/cast/dyncast/etc.
447  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
448 
449  static bool classofKind(Kind K) {
450  return K >= firstTemplate && K <= lastTemplate;
451  }
452 
453  SourceRange getSourceRange() const override LLVM_READONLY {
454  return SourceRange(getTemplateParameters()->getTemplateLoc(),
456  }
457 
458 protected:
461 
463  TemplateParams = TParams;
464  }
465 
466 public:
467  /// Initialize the underlying templated declaration and
468  /// template parameters.
469  void init(NamedDecl *templatedDecl, TemplateParameterList* templateParams) {
470  assert(!TemplatedDecl && "TemplatedDecl already set!");
471  assert(!TemplateParams && "TemplateParams already set!");
472  TemplatedDecl = templatedDecl;
473  TemplateParams = templateParams;
474  }
475 };
476 
477 /// Provides information about a function template specialization,
478 /// which is a FunctionDecl that has been explicitly specialization or
479 /// instantiated from a function template.
481  : public llvm::FoldingSetNode,
482  private llvm::TrailingObjects<FunctionTemplateSpecializationInfo,
483  MemberSpecializationInfo *> {
484  /// The function template specialization that this structure describes and a
485  /// flag indicating if the function is a member specialization.
486  llvm::PointerIntPair<FunctionDecl *, 1, bool> Function;
487 
488  /// The function template from which this function template
489  /// specialization was generated.
490  ///
491  /// The two bits contain the top 4 values of TemplateSpecializationKind.
492  llvm::PointerIntPair<FunctionTemplateDecl *, 2> Template;
493 
494 public:
495  /// The template arguments used to produce the function template
496  /// specialization from the function template.
498 
499  /// The template arguments as written in the sources, if provided.
500  /// FIXME: Normally null; tail-allocate this.
502 
503  /// The point at which this function template specialization was
504  /// first instantiated.
506 
507 private:
509  FunctionDecl *FD, FunctionTemplateDecl *Template,
510  TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs,
511  const ASTTemplateArgumentListInfo *TemplateArgsAsWritten,
513  : Function(FD, MSInfo ? true : false), Template(Template, TSK - 1),
514  TemplateArguments(TemplateArgs),
515  TemplateArgumentsAsWritten(TemplateArgsAsWritten),
516  PointOfInstantiation(POI) {
517  if (MSInfo)
518  getTrailingObjects<MemberSpecializationInfo *>()[0] = MSInfo;
519  }
520 
521  size_t numTrailingObjects(OverloadToken<MemberSpecializationInfo*>) const {
522  return Function.getInt();
523  }
524 
525 public:
527 
531  const TemplateArgumentList *TemplateArgs,
532  const TemplateArgumentListInfo *TemplateArgsAsWritten,
534 
535  /// Retrieve the declaration of the function template specialization.
536  FunctionDecl *getFunction() const { return Function.getPointer(); }
537 
538  /// Retrieve the template from which this function was specialized.
539  FunctionTemplateDecl *getTemplate() const { return Template.getPointer(); }
540 
541  /// Determine what kind of template specialization this is.
543  return (TemplateSpecializationKind)(Template.getInt() + 1);
544  }
545 
548  }
549 
550  /// True if this declaration is an explicit specialization,
551  /// explicit instantiation declaration, or explicit instantiation
552  /// definition.
556  }
557 
558  /// Set the template specialization kind.
560  assert(TSK != TSK_Undeclared &&
561  "Cannot encode TSK_Undeclared for a function template specialization");
562  Template.setInt(TSK - 1);
563  }
564 
565  /// Retrieve the first point of instantiation of this function
566  /// template specialization.
567  ///
568  /// The point of instantiation may be an invalid source location if this
569  /// function has yet to be instantiated.
571  return PointOfInstantiation;
572  }
573 
574  /// Set the (first) point of instantiation of this function template
575  /// specialization.
577  PointOfInstantiation = POI;
578  }
579 
580  /// Get the specialization info if this function template specialization is
581  /// also a member specialization:
582  ///
583  /// \code
584  /// template<typename> struct A {
585  /// template<typename> void f();
586  /// template<> void f<int>(); // ClassScopeFunctionSpecializationDecl
587  /// };
588  /// \endcode
589  ///
590  /// Here, A<int>::f<int> is a function template specialization that is
591  /// an explicit specialization of A<int>::f, but it's also a member
592  /// specialization (an implicit instantiation in this case) of A::f<int>.
593  /// Further:
594  ///
595  /// \code
596  /// template<> template<> void A<int>::f<int>() {}
597  /// \endcode
598  ///
599  /// ... declares a function template specialization that is an explicit
600  /// specialization of A<int>::f, and is also an explicit member
601  /// specialization of A::f<int>.
602  ///
603  /// Note that the TemplateSpecializationKind of the MemberSpecializationInfo
604  /// need not be the same as that returned by getTemplateSpecializationKind(),
605  /// and represents the relationship between the function and the class-scope
606  /// explicit specialization in the original templated class -- whereas our
607  /// TemplateSpecializationKind represents the relationship between the
608  /// function and the function template, and should always be
609  /// TSK_ExplicitSpecialization whenever we have MemberSpecializationInfo.
611  return numTrailingObjects(OverloadToken<MemberSpecializationInfo *>())
612  ? getTrailingObjects<MemberSpecializationInfo *>()[0]
613  : nullptr;
614  }
615 
616  void Profile(llvm::FoldingSetNodeID &ID) {
617  Profile(ID, TemplateArguments->asArray(), getFunction()->getASTContext());
618  }
619 
620  static void
621  Profile(llvm::FoldingSetNodeID &ID, ArrayRef<TemplateArgument> TemplateArgs,
622  ASTContext &Context) {
623  ID.AddInteger(TemplateArgs.size());
624  for (const TemplateArgument &TemplateArg : TemplateArgs)
625  TemplateArg.Profile(ID, Context);
626  }
627 };
628 
629 /// Provides information a specialization of a member of a class
630 /// template, which may be a member function, static data member,
631 /// member class or member enumeration.
633  // The member declaration from which this member was instantiated, and the
634  // manner in which the instantiation occurred (in the lower two bits).
635  llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
636 
637  // The point at which this member was first instantiated.
638  SourceLocation PointOfInstantiation;
639 
640 public:
641  explicit
644  : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
645  assert(TSK != TSK_Undeclared &&
646  "Cannot encode undeclared template specializations for members");
647  }
648 
649  /// Retrieve the member declaration from which this member was
650  /// instantiated.
651  NamedDecl *getInstantiatedFrom() const { return MemberAndTSK.getPointer(); }
652 
653  /// Determine what kind of template specialization this is.
655  return (TemplateSpecializationKind)(MemberAndTSK.getInt() + 1);
656  }
657 
660  }
661 
662  /// Set the template specialization kind.
664  assert(TSK != TSK_Undeclared &&
665  "Cannot encode undeclared template specializations for members");
666  MemberAndTSK.setInt(TSK - 1);
667  }
668 
669  /// Retrieve the first point of instantiation of this member.
670  /// If the point of instantiation is an invalid location, then this member
671  /// has not yet been instantiated.
673  return PointOfInstantiation;
674  }
675 
676  /// Set the first point of instantiation.
678  PointOfInstantiation = POI;
679  }
680 };
681 
682 /// Provides information about a dependent function-template
683 /// specialization declaration.
684 ///
685 /// Since explicit function template specialization and instantiation
686 /// declarations can only appear in namespace scope, and you can only
687 /// specialize a member of a fully-specialized class, the only way to
688 /// get one of these is in a friend declaration like the following:
689 ///
690 /// \code
691 /// template <class T> void foo(T);
692 /// template <class T> class A {
693 /// friend void foo<>(T);
694 /// };
695 /// \endcode
697  : private llvm::TrailingObjects<DependentFunctionTemplateSpecializationInfo,
698  TemplateArgumentLoc,
699  FunctionTemplateDecl *> {
700  /// The number of potential template candidates.
701  unsigned NumTemplates;
702 
703  /// The number of template arguments.
704  unsigned NumArgs;
705 
706  /// The locations of the left and right angle brackets.
707  SourceRange AngleLocs;
708 
709  size_t numTrailingObjects(OverloadToken<TemplateArgumentLoc>) const {
710  return NumArgs;
711  }
712  size_t numTrailingObjects(OverloadToken<FunctionTemplateDecl *>) const {
713  return NumTemplates;
714  }
715 
717  const UnresolvedSetImpl &Templates,
718  const TemplateArgumentListInfo &TemplateArgs);
719 
720 public:
722 
724  Create(ASTContext &Context, const UnresolvedSetImpl &Templates,
725  const TemplateArgumentListInfo &TemplateArgs);
726 
727  /// Returns the number of function templates that this might
728  /// be a specialization of.
729  unsigned getNumTemplates() const { return NumTemplates; }
730 
731  /// Returns the i'th template candidate.
732  FunctionTemplateDecl *getTemplate(unsigned I) const {
733  assert(I < getNumTemplates() && "template index out of range");
734  return getTrailingObjects<FunctionTemplateDecl *>()[I];
735  }
736 
737  /// Returns the explicit template arguments that were given.
739  return getTrailingObjects<TemplateArgumentLoc>();
740  }
741 
742  /// Returns the number of explicit template arguments that were given.
743  unsigned getNumTemplateArgs() const { return NumArgs; }
744 
746  return llvm::makeArrayRef(getTemplateArgs(), getNumTemplateArgs());
747  }
748 
749  /// Returns the nth template argument.
750  const TemplateArgumentLoc &getTemplateArg(unsigned I) const {
751  assert(I < getNumTemplateArgs() && "template arg index out of range");
752  return getTemplateArgs()[I];
753  }
754 
756  return AngleLocs.getBegin();
757  }
758 
760  return AngleLocs.getEnd();
761  }
762 };
763 
764 /// Declaration of a redeclarable template.
766  public Redeclarable<RedeclarableTemplateDecl>
767 {
769 
770  RedeclarableTemplateDecl *getNextRedeclarationImpl() override {
771  return getNextRedeclaration();
772  }
773 
774  RedeclarableTemplateDecl *getPreviousDeclImpl() override {
775  return getPreviousDecl();
776  }
777 
778  RedeclarableTemplateDecl *getMostRecentDeclImpl() override {
779  return getMostRecentDecl();
780  }
781 
782  void anchor() override;
783 protected:
784  template <typename EntryType> struct SpecEntryTraits {
785  using DeclType = EntryType;
786 
787  static DeclType *getDecl(EntryType *D) {
788  return D;
789  }
790 
792  return D->getTemplateArgs().asArray();
793  }
794  };
795 
796  template <typename EntryType, typename SETraits = SpecEntryTraits<EntryType>,
797  typename DeclType = typename SETraits::DeclType>
799  : llvm::iterator_adaptor_base<
800  SpecIterator<EntryType, SETraits, DeclType>,
801  typename llvm::FoldingSetVector<EntryType>::iterator,
802  typename std::iterator_traits<typename llvm::FoldingSetVector<
803  EntryType>::iterator>::iterator_category,
804  DeclType *, ptrdiff_t, DeclType *, DeclType *> {
805  SpecIterator() = default;
806  explicit SpecIterator(
807  typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
808  : SpecIterator::iterator_adaptor_base(std::move(SetIter)) {}
809 
810  DeclType *operator*() const {
811  return SETraits::getDecl(&*this->I)->getMostRecentDecl();
812  }
813 
814  DeclType *operator->() const { return **this; }
815  };
816 
817  template <typename EntryType>
818  static SpecIterator<EntryType>
819  makeSpecIterator(llvm::FoldingSetVector<EntryType> &Specs, bool isEnd) {
820  return SpecIterator<EntryType>(isEnd ? Specs.end() : Specs.begin());
821  }
822 
823  void loadLazySpecializationsImpl() const;
824 
825  template <class EntryType, typename ...ProfileArguments>
827  findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
828  void *&InsertPos, ProfileArguments &&...ProfileArgs);
829 
830  template <class Derived, class EntryType>
831  void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
832  EntryType *Entry, void *InsertPos);
833 
834  struct CommonBase {
836 
837  /// The template from which this was most
838  /// directly instantiated (or null).
839  ///
840  /// The boolean value indicates whether this template
841  /// was explicitly specialized.
842  llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
844 
845  /// If non-null, points to an array of specializations (including
846  /// partial specializations) known only by their external declaration IDs.
847  ///
848  /// The first value in the array is the number of specializations/partial
849  /// specializations that follow.
850  uint32_t *LazySpecializations = nullptr;
851  };
852 
853  /// Pointer to the common data shared by all declarations of this
854  /// template.
855  mutable CommonBase *Common = nullptr;
856 
857  /// Retrieves the "common" pointer shared by all (re-)declarations of
858  /// the same template. Calling this routine may implicitly allocate memory
859  /// for the common pointer.
860  CommonBase *getCommonPtr() const;
861 
862  virtual CommonBase *newCommon(ASTContext &C) const = 0;
863 
864  // Construct a template decl with name, parameters, and templated element.
868  : TemplateDecl(DK, DC, L, Name, Params, Decl), redeclarable_base(C) {}
869 
870 public:
871  friend class ASTDeclReader;
872  friend class ASTDeclWriter;
873  friend class ASTReader;
874  template <class decl_type> friend class RedeclarableTemplate;
875 
876  /// Retrieves the canonical declaration of this template.
878  return getFirstDecl();
879  }
881  return getFirstDecl();
882  }
883 
884  /// Determines whether this template was a specialization of a
885  /// member template.
886  ///
887  /// In the following example, the function template \c X<int>::f and the
888  /// member template \c X<int>::Inner are member specializations.
889  ///
890  /// \code
891  /// template<typename T>
892  /// struct X {
893  /// template<typename U> void f(T, U);
894  /// template<typename U> struct Inner;
895  /// };
896  ///
897  /// template<> template<typename T>
898  /// void X<int>::f(int, T);
899  /// template<> template<typename T>
900  /// struct X<int>::Inner { /* ... */ };
901  /// \endcode
902  bool isMemberSpecialization() const {
903  return getCommonPtr()->InstantiatedFromMember.getInt();
904  }
905 
906  /// Note that this member template is a specialization.
908  assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
909  "Only member templates can be member template specializations");
910  getCommonPtr()->InstantiatedFromMember.setInt(true);
911  }
912 
913  /// Retrieve the member template from which this template was
914  /// instantiated, or nullptr if this template was not instantiated from a
915  /// member template.
916  ///
917  /// A template is instantiated from a member template when the member
918  /// template itself is part of a class template (or member thereof). For
919  /// example, given
920  ///
921  /// \code
922  /// template<typename T>
923  /// struct X {
924  /// template<typename U> void f(T, U);
925  /// };
926  ///
927  /// void test(X<int> x) {
928  /// x.f(1, 'a');
929  /// };
930  /// \endcode
931  ///
932  /// \c X<int>::f is a FunctionTemplateDecl that describes the function
933  /// template
934  ///
935  /// \code
936  /// template<typename U> void X<int>::f(int, U);
937  /// \endcode
938  ///
939  /// which was itself created during the instantiation of \c X<int>. Calling
940  /// getInstantiatedFromMemberTemplate() on this FunctionTemplateDecl will
941  /// retrieve the FunctionTemplateDecl for the original template \c f within
942  /// the class template \c X<T>, i.e.,
943  ///
944  /// \code
945  /// template<typename T>
946  /// template<typename U>
947  /// void X<T>::f(T, U);
948  /// \endcode
950  return getCommonPtr()->InstantiatedFromMember.getPointer();
951  }
952 
954  assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
955  getCommonPtr()->InstantiatedFromMember.setPointer(TD);
956  }
957 
959  using redecl_iterator = redeclarable_base::redecl_iterator;
960 
967 
968  // Implement isa/cast/dyncast/etc.
969  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
970 
971  static bool classofKind(Kind K) {
972  return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate;
973  }
974 };
975 
976 template <> struct RedeclarableTemplateDecl::
977 SpecEntryTraits<FunctionTemplateSpecializationInfo> {
979 
981  return I->getFunction();
982  }
983 
986  return I->TemplateArguments->asArray();
987  }
988 };
989 
990 /// Declaration of a template function.
992 protected:
993  friend class FunctionDecl;
994 
995  /// Data that is common to all of the declarations of a given
996  /// function template.
997  struct Common : CommonBase {
998  /// The function template specializations for this function
999  /// template, including explicit specializations and instantiations.
1000  llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> Specializations;
1001 
1002  /// The set of "injected" template arguments used within this
1003  /// function template.
1004  ///
1005  /// This pointer refers to the template arguments (there are as
1006  /// many template arguments as template parameaters) for the function
1007  /// template, and is allocated lazily, since most function templates do not
1008  /// require the use of this information.
1010 
1011  Common() = default;
1012  };
1013 
1015  DeclarationName Name, TemplateParameterList *Params,
1016  NamedDecl *Decl)
1017  : RedeclarableTemplateDecl(FunctionTemplate, C, DC, L, Name, Params,
1018  Decl) {}
1019 
1020  CommonBase *newCommon(ASTContext &C) const override;
1021 
1023  return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
1024  }
1025 
1026  /// Retrieve the set of function template specializations of this
1027  /// function template.
1028  llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
1029  getSpecializations() const;
1030 
1031  /// Add a specialization of this function template.
1032  ///
1033  /// \param InsertPos Insert position in the FoldingSetVector, must have been
1034  /// retrieved by an earlier call to findSpecialization().
1036  void *InsertPos);
1037 
1038 public:
1039  friend class ASTDeclReader;
1040  friend class ASTDeclWriter;
1041 
1042  /// Load any lazily-loaded specializations from the external source.
1043  void LoadLazySpecializations() const;
1044 
1045  /// Get the underlying function declaration of the template.
1047  return static_cast<FunctionDecl *>(TemplatedDecl);
1048  }
1049 
1050  /// Returns whether this template declaration defines the primary
1051  /// pattern.
1054  }
1055 
1056  /// Return the specialization with the provided arguments if it exists,
1057  /// otherwise return the insertion point.
1059  void *&InsertPos);
1060 
1062  return cast<FunctionTemplateDecl>(
1064  }
1066  return cast<FunctionTemplateDecl>(
1068  }
1069 
1070  /// Retrieve the previous declaration of this function template, or
1071  /// nullptr if no such declaration exists.
1073  return cast_or_null<FunctionTemplateDecl>(
1074  static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl());
1075  }
1077  return cast_or_null<FunctionTemplateDecl>(
1078  static_cast<const RedeclarableTemplateDecl *>(this)->getPreviousDecl());
1079  }
1080 
1082  return cast<FunctionTemplateDecl>(
1083  static_cast<RedeclarableTemplateDecl *>(this)
1084  ->getMostRecentDecl());
1085  }
1087  return const_cast<FunctionTemplateDecl*>(this)->getMostRecentDecl();
1088  }
1089 
1091  return cast_or_null<FunctionTemplateDecl>(
1093  }
1094 
1096  using spec_range = llvm::iterator_range<spec_iterator>;
1097 
1099  return spec_range(spec_begin(), spec_end());
1100  }
1101 
1103  return makeSpecIterator(getSpecializations(), false);
1104  }
1105 
1107  return makeSpecIterator(getSpecializations(), true);
1108  }
1109 
1110  /// Retrieve the "injected" template arguments that correspond to the
1111  /// template parameters of this function template.
1112  ///
1113  /// Although the C++ standard has no notion of the "injected" template
1114  /// arguments for a function template, the notion is convenient when
1115  /// we need to perform substitutions inside the definition of a function
1116  /// template.
1118 
1119  /// Return whether this function template is an abbreviated function template,
1120  /// e.g. `void foo(auto x)` or `template<typename T> void foo(auto x)`
1121  bool isAbbreviated() const {
1122  // Since the invented template parameters generated from 'auto' parameters
1123  // are either appended to the end of the explicit template parameter list or
1124  // form a new template parameter list, we can simply observe the last
1125  // parameter to determine if such a thing happened.
1127  return TPL->getParam(TPL->size() - 1)->isImplicit();
1128  }
1129 
1130  /// Merge \p Prev with our RedeclarableTemplateDecl::Common.
1131  void mergePrevDecl(FunctionTemplateDecl *Prev);
1132 
1133  /// Create a function template node.
1135  SourceLocation L,
1136  DeclarationName Name,
1137  TemplateParameterList *Params,
1138  NamedDecl *Decl);
1139 
1140  /// Create an empty function template node.
1142 
1143  // Implement isa/cast/dyncast support
1144  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1145  static bool classofKind(Kind K) { return K == FunctionTemplate; }
1146 };
1147 
1148 //===----------------------------------------------------------------------===//
1149 // Kinds of Template Parameters
1150 //===----------------------------------------------------------------------===//
1151 
1152 /// Defines the position of a template parameter within a template
1153 /// parameter list.
1154 ///
1155 /// Because template parameter can be listed
1156 /// sequentially for out-of-line template members, each template parameter is
1157 /// given a Depth - the nesting of template parameter scopes - and a Position -
1158 /// the occurrence within the parameter list.
1159 /// This class is inheritedly privately by different kinds of template
1160 /// parameters and is not part of the Decl hierarchy. Just a facility.
1162 protected:
1163  enum { DepthWidth = 20, PositionWidth = 12 };
1164  unsigned Depth : DepthWidth;
1166 
1167  static constexpr unsigned MaxDepth = (1U << DepthWidth) - 1;
1168  static constexpr unsigned MaxPosition = (1U << PositionWidth) - 1;
1169 
1170  TemplateParmPosition(unsigned D, unsigned P) : Depth(D), Position(P) {
1171  // The input may fill maximum values to show that it is invalid.
1172  // Add one here to convert it to zero.
1173  assert((D + 1) <= MaxDepth &&
1174  "The depth of template parmeter position is more than 2^20!");
1175  assert((P + 1) <= MaxPosition &&
1176  "The position of template parmeter position is more than 2^12!");
1177  }
1178 
1179 public:
1180  TemplateParmPosition() = delete;
1181 
1182  /// Get the nesting depth of the template parameter.
1183  unsigned getDepth() const { return Depth; }
1184  void setDepth(unsigned D) {
1185  assert((D + 1) <= MaxDepth &&
1186  "The depth of template parmeter position is more than 2^20!");
1187  Depth = D;
1188  }
1189 
1190  /// Get the position of the template parameter within its parameter list.
1191  unsigned getPosition() const { return Position; }
1192  void setPosition(unsigned P) {
1193  assert((P + 1) <= MaxPosition &&
1194  "The position of template parmeter position is more than 2^12!");
1195  Position = P;
1196  }
1197 
1198  /// Get the index of the template parameter within its parameter list.
1199  unsigned getIndex() const { return Position; }
1200 };
1201 
1202 /// Declaration of a template type parameter.
1203 ///
1204 /// For example, "T" in
1205 /// \code
1206 /// template<typename T> class vector;
1207 /// \endcode
1208 class TemplateTypeParmDecl final : public TypeDecl,
1209  private llvm::TrailingObjects<TemplateTypeParmDecl, TypeConstraint> {
1210  /// Sema creates these on the stack during auto type deduction.
1211  friend class Sema;
1212  friend TrailingObjects;
1213  friend class ASTDeclReader;
1214 
1215  /// Whether this template type parameter was declaration with
1216  /// the 'typename' keyword.
1217  ///
1218  /// If false, it was declared with the 'class' keyword.
1219  bool Typename : 1;
1220 
1221  /// Whether this template type parameter has a type-constraint construct.
1222  bool HasTypeConstraint : 1;
1223 
1224  /// Whether the type constraint has been initialized. This can be false if the
1225  /// constraint was not initialized yet or if there was an error forming the
1226  /// type constraint.
1227  bool TypeConstraintInitialized : 1;
1228 
1229  /// Whether this type template parameter is an "expanded"
1230  /// parameter pack, meaning that its type is a pack expansion and we
1231  /// already know the set of types that expansion expands to.
1232  bool ExpandedParameterPack : 1;
1233 
1234  /// The number of type parameters in an expanded parameter pack.
1235  unsigned NumExpanded = 0;
1236 
1237  /// The default template argument, if any.
1238  using DefArgStorage =
1240  DefArgStorage DefaultArgument;
1241 
1243  SourceLocation IdLoc, IdentifierInfo *Id, bool Typename,
1244  bool HasTypeConstraint, Optional<unsigned> NumExpanded)
1245  : TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename),
1246  HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(false),
1247  ExpandedParameterPack(NumExpanded),
1248  NumExpanded(NumExpanded.value_or(0)) {}
1249 
1250 public:
1251  static TemplateTypeParmDecl *Create(const ASTContext &C, DeclContext *DC,
1252  SourceLocation KeyLoc,
1253  SourceLocation NameLoc,
1254  unsigned D, unsigned P,
1255  IdentifierInfo *Id, bool Typename,
1256  bool ParameterPack,
1257  bool HasTypeConstraint = false,
1258  Optional<unsigned> NumExpanded = None);
1260  unsigned ID);
1262  unsigned ID,
1263  bool HasTypeConstraint);
1264 
1265  /// Whether this template type parameter was declared with
1266  /// the 'typename' keyword.
1267  ///
1268  /// If not, it was either declared with the 'class' keyword or with a
1269  /// type-constraint (see hasTypeConstraint()).
1271  return Typename && !HasTypeConstraint;
1272  }
1273 
1274  const DefArgStorage &getDefaultArgStorage() const { return DefaultArgument; }
1275 
1276  /// Determine whether this template parameter has a default
1277  /// argument.
1278  bool hasDefaultArgument() const { return DefaultArgument.isSet(); }
1279 
1280  /// Retrieve the default argument, if any.
1282  return DefaultArgument.get()->getType();
1283  }
1284 
1285  /// Retrieves the default argument's source information, if any.
1287  return DefaultArgument.get();
1288  }
1289 
1290  /// Retrieves the location of the default argument declaration.
1292 
1293  /// Determines whether the default argument was inherited
1294  /// from a previous declaration of this template.
1296  return DefaultArgument.isInherited();
1297  }
1298 
1299  /// Set the default argument for this template parameter.
1301  DefaultArgument.set(DefArg);
1302  }
1303 
1304  /// Set that this default argument was inherited from another
1305  /// parameter.
1307  TemplateTypeParmDecl *Prev) {
1308  DefaultArgument.setInherited(C, Prev);
1309  }
1310 
1311  /// Removes the default argument of this template parameter.
1313  DefaultArgument.clear();
1314  }
1315 
1316  /// Set whether this template type parameter was declared with
1317  /// the 'typename' or 'class' keyword.
1318  void setDeclaredWithTypename(bool withTypename) { Typename = withTypename; }
1319 
1320  /// Retrieve the depth of the template parameter.
1321  unsigned getDepth() const;
1322 
1323  /// Retrieve the index of the template parameter.
1324  unsigned getIndex() const;
1325 
1326  /// Returns whether this is a parameter pack.
1327  bool isParameterPack() const;
1328 
1329  /// Whether this parameter pack is a pack expansion.
1330  ///
1331  /// A template type template parameter pack can be a pack expansion if its
1332  /// type-constraint contains an unexpanded parameter pack.
1333  bool isPackExpansion() const {
1334  if (!isParameterPack())
1335  return false;
1336  if (const TypeConstraint *TC = getTypeConstraint())
1337  if (TC->hasExplicitTemplateArgs())
1338  for (const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
1339  if (ArgLoc.getArgument().containsUnexpandedParameterPack())
1340  return true;
1341  return false;
1342  }
1343 
1344  /// Whether this parameter is a template type parameter pack that has a known
1345  /// list of different type-constraints at different positions.
1346  ///
1347  /// A parameter pack is an expanded parameter pack when the original
1348  /// parameter pack's type-constraint was itself a pack expansion, and that
1349  /// expansion has already been expanded. For example, given:
1350  ///
1351  /// \code
1352  /// template<typename ...Types>
1353  /// struct X {
1354  /// template<convertible_to<Types> ...Convertibles>
1355  /// struct Y { /* ... */ };
1356  /// };
1357  /// \endcode
1358  ///
1359  /// The parameter pack \c Convertibles has (convertible_to<Types> && ...) as
1360  /// its type-constraint. When \c Types is supplied with template arguments by
1361  /// instantiating \c X, the instantiation of \c Convertibles becomes an
1362  /// expanded parameter pack. For example, instantiating
1363  /// \c X<int, unsigned int> results in \c Convertibles being an expanded
1364  /// parameter pack of size 2 (use getNumExpansionTypes() to get this number).
1365  bool isExpandedParameterPack() const { return ExpandedParameterPack; }
1366 
1367  /// Retrieves the number of parameters in an expanded parameter pack.
1368  unsigned getNumExpansionParameters() const {
1369  assert(ExpandedParameterPack && "Not an expansion parameter pack");
1370  return NumExpanded;
1371  }
1372 
1373  /// Returns the type constraint associated with this template parameter (if
1374  /// any).
1376  return TypeConstraintInitialized ? getTrailingObjects<TypeConstraint>() :
1377  nullptr;
1378  }
1379 
1381  DeclarationNameInfo NameInfo, NamedDecl *FoundDecl,
1382  ConceptDecl *CD,
1383  const ASTTemplateArgumentListInfo *ArgsAsWritten,
1384  Expr *ImmediatelyDeclaredConstraint);
1385 
1386  /// Determine whether this template parameter has a type-constraint.
1387  bool hasTypeConstraint() const {
1388  return HasTypeConstraint;
1389  }
1390 
1391  /// \brief Get the associated-constraints of this template parameter.
1392  /// This will either be the immediately-introduced constraint or empty.
1393  ///
1394  /// Use this instead of getTypeConstraint for concepts APIs that
1395  /// accept an ArrayRef of constraint expressions.
1397  if (HasTypeConstraint)
1398  AC.push_back(getTypeConstraint()->getImmediatelyDeclaredConstraint());
1399  }
1400 
1401  SourceRange getSourceRange() const override LLVM_READONLY;
1402 
1403  // Implement isa/cast/dyncast/etc.
1404  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1405  static bool classofKind(Kind K) { return K == TemplateTypeParm; }
1406 };
1407 
1408 /// NonTypeTemplateParmDecl - Declares a non-type template parameter,
1409 /// e.g., "Size" in
1410 /// @code
1411 /// template<int Size> class array { };
1412 /// @endcode
1414  : public DeclaratorDecl,
1415  protected TemplateParmPosition,
1416  private llvm::TrailingObjects<NonTypeTemplateParmDecl,
1417  std::pair<QualType, TypeSourceInfo *>,
1418  Expr *> {
1419  friend class ASTDeclReader;
1420  friend TrailingObjects;
1421 
1422  /// The default template argument, if any, and whether or not
1423  /// it was inherited.
1425  DefArgStorage DefaultArgument;
1426 
1427  // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index
1428  // down here to save memory.
1429 
1430  /// Whether this non-type template parameter is a parameter pack.
1431  bool ParameterPack;
1432 
1433  /// Whether this non-type template parameter is an "expanded"
1434  /// parameter pack, meaning that its type is a pack expansion and we
1435  /// already know the set of types that expansion expands to.
1436  bool ExpandedParameterPack = false;
1437 
1438  /// The number of types in an expanded parameter pack.
1439  unsigned NumExpandedTypes = 0;
1440 
1441  size_t numTrailingObjects(
1442  OverloadToken<std::pair<QualType, TypeSourceInfo *>>) const {
1443  return NumExpandedTypes;
1444  }
1445 
1447  SourceLocation IdLoc, unsigned D, unsigned P,
1449  bool ParameterPack, TypeSourceInfo *TInfo)
1450  : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
1451  TemplateParmPosition(D, P), ParameterPack(ParameterPack) {}
1452 
1453  NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc,
1454  SourceLocation IdLoc, unsigned D, unsigned P,
1455  IdentifierInfo *Id, QualType T,
1456  TypeSourceInfo *TInfo,
1457  ArrayRef<QualType> ExpandedTypes,
1458  ArrayRef<TypeSourceInfo *> ExpandedTInfos);
1459 
1460 public:
1461  static NonTypeTemplateParmDecl *
1462  Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
1463  SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
1464  QualType T, bool ParameterPack, TypeSourceInfo *TInfo);
1465 
1466  static NonTypeTemplateParmDecl *
1467  Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
1468  SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id,
1469  QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
1470  ArrayRef<TypeSourceInfo *> ExpandedTInfos);
1471 
1472  static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C,
1473  unsigned ID,
1474  bool HasTypeConstraint);
1475  static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C,
1476  unsigned ID,
1477  unsigned NumExpandedTypes,
1478  bool HasTypeConstraint);
1479 
1485 
1486  SourceRange getSourceRange() const override LLVM_READONLY;
1487 
1488  const DefArgStorage &getDefaultArgStorage() const { return DefaultArgument; }
1489 
1490  /// Determine whether this template parameter has a default
1491  /// argument.
1492  bool hasDefaultArgument() const { return DefaultArgument.isSet(); }
1493 
1494  /// Retrieve the default argument, if any.
1495  Expr *getDefaultArgument() const { return DefaultArgument.get(); }
1496 
1497  /// Retrieve the location of the default argument, if any.
1499 
1500  /// Determines whether the default argument was inherited
1501  /// from a previous declaration of this template.
1503  return DefaultArgument.isInherited();
1504  }
1505 
1506  /// Set the default argument for this template parameter, and
1507  /// whether that default argument was inherited from another
1508  /// declaration.
1509  void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); }
1511  NonTypeTemplateParmDecl *Parm) {
1512  DefaultArgument.setInherited(C, Parm);
1513  }
1514 
1515  /// Removes the default argument of this template parameter.
1516  void removeDefaultArgument() { DefaultArgument.clear(); }
1517 
1518  /// Whether this parameter is a non-type template parameter pack.
1519  ///
1520  /// If the parameter is a parameter pack, the type may be a
1521  /// \c PackExpansionType. In the following example, the \c Dims parameter
1522  /// is a parameter pack (whose type is 'unsigned').
1523  ///
1524  /// \code
1525  /// template<typename T, unsigned ...Dims> struct multi_array;
1526  /// \endcode
1527  bool isParameterPack() const { return ParameterPack; }
1528 
1529  /// Whether this parameter pack is a pack expansion.
1530  ///
1531  /// A non-type template parameter pack is a pack expansion if its type
1532  /// contains an unexpanded parameter pack. In this case, we will have
1533  /// built a PackExpansionType wrapping the type.
1534  bool isPackExpansion() const {
1535  return ParameterPack && getType()->getAs<PackExpansionType>();
1536  }
1537 
1538  /// Whether this parameter is a non-type template parameter pack
1539  /// that has a known list of different types at different positions.
1540  ///
1541  /// A parameter pack is an expanded parameter pack when the original
1542  /// parameter pack's type was itself a pack expansion, and that expansion
1543  /// has already been expanded. For example, given:
1544  ///
1545  /// \code
1546  /// template<typename ...Types>
1547  /// struct X {
1548  /// template<Types ...Values>
1549  /// struct Y { /* ... */ };
1550  /// };
1551  /// \endcode
1552  ///
1553  /// The parameter pack \c Values has a \c PackExpansionType as its type,
1554  /// which expands \c Types. When \c Types is supplied with template arguments
1555  /// by instantiating \c X, the instantiation of \c Values becomes an
1556  /// expanded parameter pack. For example, instantiating
1557  /// \c X<int, unsigned int> results in \c Values being an expanded parameter
1558  /// pack with expansion types \c int and \c unsigned int.
1559  ///
1560  /// The \c getExpansionType() and \c getExpansionTypeSourceInfo() functions
1561  /// return the expansion types.
1562  bool isExpandedParameterPack() const { return ExpandedParameterPack; }
1563 
1564  /// Retrieves the number of expansion types in an expanded parameter
1565  /// pack.
1566  unsigned getNumExpansionTypes() const {
1567  assert(ExpandedParameterPack && "Not an expansion parameter pack");
1568  return NumExpandedTypes;
1569  }
1570 
1571  /// Retrieve a particular expansion type within an expanded parameter
1572  /// pack.
1573  QualType getExpansionType(unsigned I) const {
1574  assert(I < NumExpandedTypes && "Out-of-range expansion type index");
1575  auto TypesAndInfos =
1576  getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1577  return TypesAndInfos[I].first;
1578  }
1579 
1580  /// Retrieve a particular expansion type source info within an
1581  /// expanded parameter pack.
1583  assert(I < NumExpandedTypes && "Out-of-range expansion type index");
1584  auto TypesAndInfos =
1585  getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
1586  return TypesAndInfos[I].second;
1587  }
1588 
1589  /// Return the constraint introduced by the placeholder type of this non-type
1590  /// template parameter (if any).
1592  return hasPlaceholderTypeConstraint() ? *getTrailingObjects<Expr *>() :
1593  nullptr;
1594  }
1595 
1597  *getTrailingObjects<Expr *>() = E;
1598  }
1599 
1600  /// Determine whether this non-type template parameter's type has a
1601  /// placeholder with a type-constraint.
1603  auto *AT = getType()->getContainedAutoType();
1604  return AT && AT->isConstrained();
1605  }
1606 
1607  /// \brief Get the associated-constraints of this template parameter.
1608  /// This will either be a vector of size 1 containing the immediately-declared
1609  /// constraint introduced by the placeholder type, or an empty vector.
1610  ///
1611  /// Use this instead of getPlaceholderImmediatelyDeclaredConstraint for
1612  /// concepts APIs that accept an ArrayRef of constraint expressions.
1615  AC.push_back(E);
1616  }
1617 
1618  // Implement isa/cast/dyncast/etc.
1619  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1620  static bool classofKind(Kind K) { return K == NonTypeTemplateParm; }
1621 };
1622 
1623 /// TemplateTemplateParmDecl - Declares a template template parameter,
1624 /// e.g., "T" in
1625 /// @code
1626 /// template <template <typename> class T> class container { };
1627 /// @endcode
1628 /// A template template parameter is a TemplateDecl because it defines the
1629 /// name of a template and the template parameters allowable for substitution.
1631  : public TemplateDecl,
1632  protected TemplateParmPosition,
1633  private llvm::TrailingObjects<TemplateTemplateParmDecl,
1634  TemplateParameterList *> {
1635  /// The default template argument, if any.
1636  using DefArgStorage =
1638  DefArgStorage DefaultArgument;
1639 
1640  /// Whether this parameter is a parameter pack.
1641  bool ParameterPack;
1642 
1643  /// Whether this template template parameter is an "expanded"
1644  /// parameter pack, meaning that it is a pack expansion and we
1645  /// already know the set of template parameters that expansion expands to.
1646  bool ExpandedParameterPack = false;
1647 
1648  /// The number of parameters in an expanded parameter pack.
1649  unsigned NumExpandedParams = 0;
1650 
1652  unsigned D, unsigned P, bool ParameterPack,
1654  : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
1655  TemplateParmPosition(D, P), ParameterPack(ParameterPack) {}
1656 
1658  unsigned D, unsigned P,
1661 
1662  void anchor() override;
1663 
1664 public:
1665  friend class ASTDeclReader;
1666  friend class ASTDeclWriter;
1668 
1670  SourceLocation L, unsigned D,
1671  unsigned P, bool ParameterPack,
1672  IdentifierInfo *Id,
1673  TemplateParameterList *Params);
1675  SourceLocation L, unsigned D,
1676  unsigned P,
1677  IdentifierInfo *Id,
1678  TemplateParameterList *Params,
1680 
1682  unsigned ID);
1684  unsigned ID,
1685  unsigned NumExpansions);
1686 
1692 
1693  /// Whether this template template parameter is a template
1694  /// parameter pack.
1695  ///
1696  /// \code
1697  /// template<template <class T> ...MetaFunctions> struct Apply;
1698  /// \endcode
1699  bool isParameterPack() const { return ParameterPack; }
1700 
1701  /// Whether this parameter pack is a pack expansion.
1702  ///
1703  /// A template template parameter pack is a pack expansion if its template
1704  /// parameter list contains an unexpanded parameter pack.
1705  bool isPackExpansion() const {
1706  return ParameterPack &&
1708  }
1709 
1710  /// Whether this parameter is a template template parameter pack that
1711  /// has a known list of different template parameter lists at different
1712  /// positions.
1713  ///
1714  /// A parameter pack is an expanded parameter pack when the original parameter
1715  /// pack's template parameter list was itself a pack expansion, and that
1716  /// expansion has already been expanded. For exampe, given:
1717  ///
1718  /// \code
1719  /// template<typename...Types> struct Outer {
1720  /// template<template<Types> class...Templates> struct Inner;
1721  /// };
1722  /// \endcode
1723  ///
1724  /// The parameter pack \c Templates is a pack expansion, which expands the
1725  /// pack \c Types. When \c Types is supplied with template arguments by
1726  /// instantiating \c Outer, the instantiation of \c Templates is an expanded
1727  /// parameter pack.
1728  bool isExpandedParameterPack() const { return ExpandedParameterPack; }
1729 
1730  /// Retrieves the number of expansion template parameters in
1731  /// an expanded parameter pack.
1733  assert(ExpandedParameterPack && "Not an expansion parameter pack");
1734  return NumExpandedParams;
1735  }
1736 
1737  /// Retrieve a particular expansion type within an expanded parameter
1738  /// pack.
1740  assert(I < NumExpandedParams && "Out-of-range expansion type index");
1741  return getTrailingObjects<TemplateParameterList *>()[I];
1742  }
1743 
1744  const DefArgStorage &getDefaultArgStorage() const { return DefaultArgument; }
1745 
1746  /// Determine whether this template parameter has a default
1747  /// argument.
1748  bool hasDefaultArgument() const { return DefaultArgument.isSet(); }
1749 
1750  /// Retrieve the default argument, if any.
1752  static const TemplateArgumentLoc NoneLoc;
1753  return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc;
1754  }
1755 
1756  /// Retrieve the location of the default argument, if any.
1758 
1759  /// Determines whether the default argument was inherited
1760  /// from a previous declaration of this template.
1762  return DefaultArgument.isInherited();
1763  }
1764 
1765  /// Set the default argument for this template parameter, and
1766  /// whether that default argument was inherited from another
1767  /// declaration.
1768  void setDefaultArgument(const ASTContext &C,
1769  const TemplateArgumentLoc &DefArg);
1771  TemplateTemplateParmDecl *Prev) {
1772  DefaultArgument.setInherited(C, Prev);
1773  }
1774 
1775  /// Removes the default argument of this template parameter.
1776  void removeDefaultArgument() { DefaultArgument.clear(); }
1777 
1778  SourceRange getSourceRange() const override LLVM_READONLY {
1782  return SourceRange(getTemplateParameters()->getTemplateLoc(), End);
1783  }
1784 
1785  // Implement isa/cast/dyncast/etc.
1786  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1787  static bool classofKind(Kind K) { return K == TemplateTemplateParm; }
1788 };
1789 
1790 /// Represents the builtin template declaration which is used to
1791 /// implement __make_integer_seq and other builtin templates. It serves
1792 /// no real purpose beyond existing as a place to hold template parameters.
1794  BuiltinTemplateKind BTK;
1795 
1798 
1799  void anchor() override;
1800 
1801 public:
1802  // Implement isa/cast/dyncast support
1803  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1804  static bool classofKind(Kind K) { return K == BuiltinTemplate; }
1805 
1807  DeclarationName Name,
1808  BuiltinTemplateKind BTK) {
1809  return new (C, DC) BuiltinTemplateDecl(C, DC, Name, BTK);
1810  }
1811 
1812  SourceRange getSourceRange() const override LLVM_READONLY {
1813  return {};
1814  }
1815 
1817 };
1818 
1819 /// Represents a class template specialization, which refers to
1820 /// a class template with a given set of template arguments.
1821 ///
1822 /// Class template specializations represent both explicit
1823 /// specialization of class templates, as in the example below, and
1824 /// implicit instantiations of class templates.
1825 ///
1826 /// \code
1827 /// template<typename T> class array;
1828 ///
1829 /// template<>
1830 /// class array<bool> { }; // class template specialization array<bool>
1831 /// \endcode
1833  : public CXXRecordDecl, public llvm::FoldingSetNode {
1834  /// Structure that stores information about a class template
1835  /// specialization that was instantiated from a class template partial
1836  /// specialization.
1837  struct SpecializedPartialSpecialization {
1838  /// The class template partial specialization from which this
1839  /// class template specialization was instantiated.
1840  ClassTemplatePartialSpecializationDecl *PartialSpecialization;
1841 
1842  /// The template argument list deduced for the class template
1843  /// partial specialization itself.
1844  const TemplateArgumentList *TemplateArgs;
1845  };
1846 
1847  /// The template that this specialization specializes
1848  llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
1849  SpecializedTemplate;
1850 
1851  /// Further info for explicit template specialization/instantiation.
1852  struct ExplicitSpecializationInfo {
1853  /// The type-as-written.
1854  TypeSourceInfo *TypeAsWritten = nullptr;
1855 
1856  /// The location of the extern keyword.
1857  SourceLocation ExternLoc;
1858 
1859  /// The location of the template keyword.
1860  SourceLocation TemplateKeywordLoc;
1861 
1862  ExplicitSpecializationInfo() = default;
1863  };
1864 
1865  /// Further info for explicit template specialization/instantiation.
1866  /// Does not apply to implicit specializations.
1867  ExplicitSpecializationInfo *ExplicitInfo = nullptr;
1868 
1869  /// The template arguments used to describe this specialization.
1870  const TemplateArgumentList *TemplateArgs;
1871 
1872  /// The point where this template was instantiated (if any)
1873  SourceLocation PointOfInstantiation;
1874 
1875  /// The kind of specialization this declaration refers to.
1876  /// Really a value of type TemplateSpecializationKind.
1877  unsigned SpecializationKind : 3;
1878 
1879 protected:
1881  DeclContext *DC, SourceLocation StartLoc,
1882  SourceLocation IdLoc,
1883  ClassTemplateDecl *SpecializedTemplate,
1886 
1888 
1889 public:
1890  friend class ASTDeclReader;
1891  friend class ASTDeclWriter;
1892 
1894  Create(ASTContext &Context, TagKind TK, DeclContext *DC,
1895  SourceLocation StartLoc, SourceLocation IdLoc,
1896  ClassTemplateDecl *SpecializedTemplate,
1900  CreateDeserialized(ASTContext &C, unsigned ID);
1901 
1902  void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy,
1903  bool Qualified) const override;
1904 
1905  // FIXME: This is broken. CXXRecordDecl::getMostRecentDecl() returns a
1906  // different "most recent" declaration from this function for the same
1907  // declaration, because we don't override getMostRecentDeclImpl(). But
1908  // it's not clear that we should override that, because the most recent
1909  // declaration as a CXXRecordDecl sometimes is the injected-class-name.
1911  return cast<ClassTemplateSpecializationDecl>(
1913  }
1914 
1915  /// Retrieve the template that this specialization specializes.
1917 
1918  /// Retrieve the template arguments of the class template
1919  /// specialization.
1921  return *TemplateArgs;
1922  }
1923 
1925  TemplateArgs = Args;
1926  }
1927 
1928  /// Determine the kind of specialization that this
1929  /// declaration represents.
1931  return static_cast<TemplateSpecializationKind>(SpecializationKind);
1932  }
1933 
1936  }
1937 
1938  /// Is this an explicit specialization at class scope (within the class that
1939  /// owns the primary template)? For example:
1940  ///
1941  /// \code
1942  /// template<typename T> struct Outer {
1943  /// template<typename U> struct Inner;
1944  /// template<> struct Inner; // class-scope explicit specialization
1945  /// };
1946  /// \endcode
1948  return isExplicitSpecialization() &&
1949  isa<CXXRecordDecl>(getLexicalDeclContext());
1950  }
1951 
1952  /// True if this declaration is an explicit specialization,
1953  /// explicit instantiation declaration, or explicit instantiation
1954  /// definition.
1958  }
1959 
1961  SpecializedTemplate = Specialized;
1962  }
1963 
1965  SpecializationKind = TSK;
1966  }
1967 
1968  /// Get the point of instantiation (if any), or null if none.
1970  return PointOfInstantiation;
1971  }
1972 
1974  assert(Loc.isValid() && "point of instantiation must be valid!");
1975  PointOfInstantiation = Loc;
1976  }
1977 
1978  /// If this class template specialization is an instantiation of
1979  /// a template (rather than an explicit specialization), return the
1980  /// class template or class template partial specialization from which it
1981  /// was instantiated.
1982  llvm::PointerUnion<ClassTemplateDecl *,
1986  return llvm::PointerUnion<ClassTemplateDecl *,
1988 
1990  }
1991 
1992  /// Retrieve the class template or class template partial
1993  /// specialization which was specialized by this.
1994  llvm::PointerUnion<ClassTemplateDecl *,
1997  if (const auto *PartialSpec =
1998  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1999  return PartialSpec->PartialSpecialization;
2000 
2001  return SpecializedTemplate.get<ClassTemplateDecl*>();
2002  }
2003 
2004  /// Retrieve the set of template arguments that should be used
2005  /// to instantiate members of the class template or class template partial
2006  /// specialization from which this class template specialization was
2007  /// instantiated.
2008  ///
2009  /// \returns For a class template specialization instantiated from the primary
2010  /// template, this function will return the same template arguments as
2011  /// getTemplateArgs(). For a class template specialization instantiated from
2012  /// a class template partial specialization, this function will return the
2013  /// deduced template arguments for the class template partial specialization
2014  /// itself.
2016  if (const auto *PartialSpec =
2017  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2018  return *PartialSpec->TemplateArgs;
2019 
2020  return getTemplateArgs();
2021  }
2022 
2023  /// Note that this class template specialization is actually an
2024  /// instantiation of the given class template partial specialization whose
2025  /// template arguments have been deduced.
2027  const TemplateArgumentList *TemplateArgs) {
2028  assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
2029  "Already set to a class template partial specialization!");
2030  auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
2031  PS->PartialSpecialization = PartialSpec;
2032  PS->TemplateArgs = TemplateArgs;
2033  SpecializedTemplate = PS;
2034  }
2035 
2036  /// Note that this class template specialization is an instantiation
2037  /// of the given class template.
2039  assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
2040  "Previously set to a class template partial specialization!");
2041  SpecializedTemplate = TemplDecl;
2042  }
2043 
2044  /// Sets the type of this specialization as it was written by
2045  /// the user. This will be a class template specialization type.
2047  if (!ExplicitInfo)
2048  ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
2049  ExplicitInfo->TypeAsWritten = T;
2050  }
2051 
2052  /// Gets the type of this specialization as it was written by
2053  /// the user, if it was so written.
2055  return ExplicitInfo ? ExplicitInfo->TypeAsWritten : nullptr;
2056  }
2057 
2058  /// Gets the location of the extern keyword, if present.
2060  return ExplicitInfo ? ExplicitInfo->ExternLoc : SourceLocation();
2061  }
2062 
2063  /// Sets the location of the extern keyword.
2065  if (!ExplicitInfo)
2066  ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
2067  ExplicitInfo->ExternLoc = Loc;
2068  }
2069 
2070  /// Sets the location of the template keyword.
2072  if (!ExplicitInfo)
2073  ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
2074  ExplicitInfo->TemplateKeywordLoc = Loc;
2075  }
2076 
2077  /// Gets the location of the template keyword, if present.
2079  return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
2080  }
2081 
2082  SourceRange getSourceRange() const override LLVM_READONLY;
2083 
2084  void Profile(llvm::FoldingSetNodeID &ID) const {
2085  Profile(ID, TemplateArgs->asArray(), getASTContext());
2086  }
2087 
2088  static void
2089  Profile(llvm::FoldingSetNodeID &ID, ArrayRef<TemplateArgument> TemplateArgs,
2090  ASTContext &Context) {
2091  ID.AddInteger(TemplateArgs.size());
2092  for (const TemplateArgument &TemplateArg : TemplateArgs)
2093  TemplateArg.Profile(ID, Context);
2094  }
2095 
2096  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2097 
2098  static bool classofKind(Kind K) {
2099  return K >= firstClassTemplateSpecialization &&
2100  K <= lastClassTemplateSpecialization;
2101  }
2102 };
2103 
2106  /// The list of template parameters
2107  TemplateParameterList* TemplateParams = nullptr;
2108 
2109  /// The source info for the template arguments as written.
2110  /// FIXME: redundant with TypeAsWritten?
2111  const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr;
2112 
2113  /// The class template partial specialization from which this
2114  /// class template partial specialization was instantiated.
2115  ///
2116  /// The boolean value will be true to indicate that this class template
2117  /// partial specialization was specialized at this level.
2118  llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
2119  InstantiatedFromMember;
2120 
2122  DeclContext *DC,
2123  SourceLocation StartLoc,
2124  SourceLocation IdLoc,
2125  TemplateParameterList *Params,
2126  ClassTemplateDecl *SpecializedTemplate,
2128  const ASTTemplateArgumentListInfo *ArgsAsWritten,
2130 
2132  : ClassTemplateSpecializationDecl(C, ClassTemplatePartialSpecialization),
2133  InstantiatedFromMember(nullptr, false) {}
2134 
2135  void anchor() override;
2136 
2137 public:
2138  friend class ASTDeclReader;
2139  friend class ASTDeclWriter;
2140 
2142  Create(ASTContext &Context, TagKind TK, DeclContext *DC,
2143  SourceLocation StartLoc, SourceLocation IdLoc,
2144  TemplateParameterList *Params,
2145  ClassTemplateDecl *SpecializedTemplate,
2147  const TemplateArgumentListInfo &ArgInfos,
2148  QualType CanonInjectedType,
2150 
2152  CreateDeserialized(ASTContext &C, unsigned ID);
2153 
2155  return cast<ClassTemplatePartialSpecializationDecl>(
2156  static_cast<ClassTemplateSpecializationDecl *>(
2157  this)->getMostRecentDecl());
2158  }
2159 
2160  /// Get the list of template parameters
2162  return TemplateParams;
2163  }
2164 
2165  /// \brief All associated constraints of this partial specialization,
2166  /// including the requires clause and any constraints derived from
2167  /// constrained-parameters.
2168  ///
2169  /// The constraints in the resulting list are to be treated as if in a
2170  /// conjunction ("and").
2172  TemplateParams->getAssociatedConstraints(AC);
2173  }
2174 
2176  return TemplateParams->hasAssociatedConstraints();
2177  }
2178 
2179  /// Get the template arguments as written.
2181  return ArgsAsWritten;
2182  }
2183 
2184  /// Retrieve the member class template partial specialization from
2185  /// which this particular class template partial specialization was
2186  /// instantiated.
2187  ///
2188  /// \code
2189  /// template<typename T>
2190  /// struct Outer {
2191  /// template<typename U> struct Inner;
2192  /// template<typename U> struct Inner<U*> { }; // #1
2193  /// };
2194  ///
2195  /// Outer<float>::Inner<int*> ii;
2196  /// \endcode
2197  ///
2198  /// In this example, the instantiation of \c Outer<float>::Inner<int*> will
2199  /// end up instantiating the partial specialization
2200  /// \c Outer<float>::Inner<U*>, which itself was instantiated from the class
2201  /// template partial specialization \c Outer<T>::Inner<U*>. Given
2202  /// \c Outer<float>::Inner<U*>, this function would return
2203  /// \c Outer<T>::Inner<U*>.
2205  const auto *First =
2206  cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2207  return First->InstantiatedFromMember.getPointer();
2208  }
2211  return getInstantiatedFromMember();
2212  }
2213 
2216  auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2217  First->InstantiatedFromMember.setPointer(PartialSpec);
2218  }
2219 
2220  /// Determines whether this class template partial specialization
2221  /// template was a specialization of a member partial specialization.
2222  ///
2223  /// In the following example, the member template partial specialization
2224  /// \c X<int>::Inner<T*> is a member specialization.
2225  ///
2226  /// \code
2227  /// template<typename T>
2228  /// struct X {
2229  /// template<typename U> struct Inner;
2230  /// template<typename U> struct Inner<U*>;
2231  /// };
2232  ///
2233  /// template<> template<typename T>
2234  /// struct X<int>::Inner<T*> { /* ... */ };
2235  /// \endcode
2237  const auto *First =
2238  cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2239  return First->InstantiatedFromMember.getInt();
2240  }
2241 
2242  /// Note that this member template is a specialization.
2244  auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2245  assert(First->InstantiatedFromMember.getPointer() &&
2246  "Only member templates can be member template specializations");
2247  return First->InstantiatedFromMember.setInt(true);
2248  }
2249 
2250  /// Retrieves the injected specialization type for this partial
2251  /// specialization. This is not the same as the type-decl-type for
2252  /// this partial specialization, which is an InjectedClassNameType.
2254  assert(getTypeForDecl() && "partial specialization has no type set!");
2255  return cast<InjectedClassNameType>(getTypeForDecl())
2256  ->getInjectedSpecializationType();
2257  }
2258 
2259  void Profile(llvm::FoldingSetNodeID &ID) const {
2261  getASTContext());
2262  }
2263 
2264  static void
2265  Profile(llvm::FoldingSetNodeID &ID, ArrayRef<TemplateArgument> TemplateArgs,
2266  TemplateParameterList *TPL, ASTContext &Context);
2267 
2268  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2269 
2270  static bool classofKind(Kind K) {
2271  return K == ClassTemplatePartialSpecialization;
2272  }
2273 };
2274 
2275 /// Declaration of a class template.
2277 protected:
2278  /// Data that is common to all of the declarations of a given
2279  /// class template.
2280  struct Common : CommonBase {
2281  /// The class template specializations for this class
2282  /// template, including explicit specializations and instantiations.
2283  llvm::FoldingSetVector<ClassTemplateSpecializationDecl> Specializations;
2284 
2285  /// The class template partial specializations for this class
2286  /// template.
2287  llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl>
2289 
2290  /// The injected-class-name type for this class template.
2292 
2293  Common() = default;
2294  };
2295 
2296  /// Retrieve the set of specializations of this class template.
2297  llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
2298  getSpecializations() const;
2299 
2300  /// Retrieve the set of partial specializations of this class
2301  /// template.
2302  llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
2303  getPartialSpecializations() const;
2304 
2306  DeclarationName Name, TemplateParameterList *Params,
2307  NamedDecl *Decl)
2308  : RedeclarableTemplateDecl(ClassTemplate, C, DC, L, Name, Params, Decl) {}
2309 
2310  CommonBase *newCommon(ASTContext &C) const override;
2311 
2313  return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
2314  }
2315 
2316 public:
2317  friend class ASTDeclReader;
2318  friend class ASTDeclWriter;
2319 
2320  /// Load any lazily-loaded specializations from the external source.
2321  void LoadLazySpecializations() const;
2322 
2323  /// Get the underlying class declarations of the template.
2325  return static_cast<CXXRecordDecl *>(TemplatedDecl);
2326  }
2327 
2328  /// Returns whether this template declaration defines the primary
2329  /// class pattern.
2332  }
2333 
2334  /// \brief Create a class template node.
2336  SourceLocation L,
2337  DeclarationName Name,
2338  TemplateParameterList *Params,
2339  NamedDecl *Decl);
2340 
2341  /// Create an empty class template node.
2342  static ClassTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2343 
2344  /// Return the specialization with the provided arguments if it exists,
2345  /// otherwise return the insertion point.
2347  findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos);
2348 
2349  /// Insert the specified specialization knowing that it is not already
2350  /// in. InsertPos must be obtained from findSpecialization.
2351  void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos);
2352 
2354  return cast<ClassTemplateDecl>(
2356  }
2358  return cast<ClassTemplateDecl>(
2360  }
2361 
2362  /// Retrieve the previous declaration of this class template, or
2363  /// nullptr if no such declaration exists.
2365  return cast_or_null<ClassTemplateDecl>(
2366  static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl());
2367  }
2369  return cast_or_null<ClassTemplateDecl>(
2370  static_cast<const RedeclarableTemplateDecl *>(
2371  this)->getPreviousDecl());
2372  }
2373 
2375  return cast<ClassTemplateDecl>(
2376  static_cast<RedeclarableTemplateDecl *>(this)->getMostRecentDecl());
2377  }
2379  return const_cast<ClassTemplateDecl*>(this)->getMostRecentDecl();
2380  }
2381 
2383  return cast_or_null<ClassTemplateDecl>(
2385  }
2386 
2387  /// Return the partial specialization with the provided arguments if it
2388  /// exists, otherwise return the insertion point.
2391  TemplateParameterList *TPL, void *&InsertPos);
2392 
2393  /// Insert the specified partial specialization knowing that it is not
2394  /// already in. InsertPos must be obtained from findPartialSpecialization.
2396  void *InsertPos);
2397 
2398  /// Retrieve the partial specializations as an ordered list.
2401 
2402  /// Find a class template partial specialization with the given
2403  /// type T.
2404  ///
2405  /// \param T a dependent type that names a specialization of this class
2406  /// template.
2407  ///
2408  /// \returns the class template partial specialization that exactly matches
2409  /// the type \p T, or nullptr if no such partial specialization exists.
2411 
2412  /// Find a class template partial specialization which was instantiated
2413  /// from the given member partial specialization.
2414  ///
2415  /// \param D a member class template partial specialization.
2416  ///
2417  /// \returns the class template partial specialization which was instantiated
2418  /// from the given member partial specialization, or nullptr if no such
2419  /// partial specialization exists.
2423 
2424  /// Retrieve the template specialization type of the
2425  /// injected-class-name for this class template.
2426  ///
2427  /// The injected-class-name for a class template \c X is \c
2428  /// X<template-args>, where \c template-args is formed from the
2429  /// template arguments that correspond to the template parameters of
2430  /// \c X. For example:
2431  ///
2432  /// \code
2433  /// template<typename T, int N>
2434  /// struct array {
2435  /// typedef array this_type; // "array" is equivalent to "array<T, N>"
2436  /// };
2437  /// \endcode
2439 
2441  using spec_range = llvm::iterator_range<spec_iterator>;
2442 
2444  return spec_range(spec_begin(), spec_end());
2445  }
2446 
2448  return makeSpecIterator(getSpecializations(), false);
2449  }
2450 
2452  return makeSpecIterator(getSpecializations(), true);
2453  }
2454 
2455  // Implement isa/cast/dyncast support
2456  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2457  static bool classofKind(Kind K) { return K == ClassTemplate; }
2458 };
2459 
2460 /// Declaration of a friend template.
2461 ///
2462 /// For example:
2463 /// \code
2464 /// template <typename T> class A {
2465 /// friend class MyVector<T>; // not a friend template
2466 /// template <typename U> friend class B; // not a friend template
2467 /// template <typename U> friend class Foo<T>::Nested; // friend template
2468 /// };
2469 /// \endcode
2470 ///
2471 /// \note This class is not currently in use. All of the above
2472 /// will yield a FriendDecl, not a FriendTemplateDecl.
2473 class FriendTemplateDecl : public Decl {
2474  virtual void anchor();
2475 
2476 public:
2477  using FriendUnion = llvm::PointerUnion<NamedDecl *,TypeSourceInfo *>;
2478 
2479 private:
2480  // The number of template parameters; always non-zero.
2481  unsigned NumParams = 0;
2482 
2483  // The parameter list.
2484  TemplateParameterList **Params = nullptr;
2485 
2486  // The declaration that's a friend of this class.
2487  FriendUnion Friend;
2488 
2489  // Location of the 'friend' specifier.
2490  SourceLocation FriendLoc;
2491 
2493  TemplateParameterList **Params, unsigned NumParams,
2494  FriendUnion Friend, SourceLocation FriendLoc)
2495  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(NumParams),
2496  Params(Params), Friend(Friend), FriendLoc(FriendLoc) {}
2497 
2498  FriendTemplateDecl(EmptyShell Empty) : Decl(Decl::FriendTemplate, Empty) {}
2499 
2500 public:
2501  friend class ASTDeclReader;
2502 
2503  static FriendTemplateDecl *
2504  Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc,
2506  SourceLocation FriendLoc);
2507 
2508  static FriendTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2509 
2510  /// If this friend declaration names a templated type (or
2511  /// a dependent member type of a templated type), return that
2512  /// type; otherwise return null.
2514  return Friend.dyn_cast<TypeSourceInfo*>();
2515  }
2516 
2517  /// If this friend declaration names a templated function (or
2518  /// a member function of a templated type), return that type;
2519  /// otherwise return null.
2521  return Friend.dyn_cast<NamedDecl*>();
2522  }
2523 
2524  /// Retrieves the location of the 'friend' keyword.
2526  return FriendLoc;
2527  }
2528 
2530  assert(i <= NumParams);
2531  return Params[i];
2532  }
2533 
2534  unsigned getNumTemplateParameters() const {
2535  return NumParams;
2536  }
2537 
2538  // Implement isa/cast/dyncast/etc.
2539  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2540  static bool classofKind(Kind K) { return K == Decl::FriendTemplate; }
2541 };
2542 
2543 /// Declaration of an alias template.
2544 ///
2545 /// For example:
2546 /// \code
2547 /// template <typename T> using V = std::map<T*, int, MyCompare<T>>;
2548 /// \endcode
2550 protected:
2552 
2554  DeclarationName Name, TemplateParameterList *Params,
2555  NamedDecl *Decl)
2556  : RedeclarableTemplateDecl(TypeAliasTemplate, C, DC, L, Name, Params,
2557  Decl) {}
2558 
2559  CommonBase *newCommon(ASTContext &C) const override;
2560 
2562  return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
2563  }
2564 
2565 public:
2566  friend class ASTDeclReader;
2567  friend class ASTDeclWriter;
2568 
2569  /// Get the underlying function declaration of the template.
2571  return static_cast<TypeAliasDecl *>(TemplatedDecl);
2572  }
2573 
2574 
2576  return cast<TypeAliasTemplateDecl>(
2578  }
2580  return cast<TypeAliasTemplateDecl>(
2582  }
2583 
2584  /// Retrieve the previous declaration of this function template, or
2585  /// nullptr if no such declaration exists.
2587  return cast_or_null<TypeAliasTemplateDecl>(
2588  static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl());
2589  }
2591  return cast_or_null<TypeAliasTemplateDecl>(
2592  static_cast<const RedeclarableTemplateDecl *>(
2593  this)->getPreviousDecl());
2594  }
2595 
2597  return cast_or_null<TypeAliasTemplateDecl>(
2599  }
2600 
2601  /// Create a function template node.
2603  SourceLocation L,
2604  DeclarationName Name,
2605  TemplateParameterList *Params,
2606  NamedDecl *Decl);
2607 
2608  /// Create an empty alias template node.
2610 
2611  // Implement isa/cast/dyncast support
2612  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2613  static bool classofKind(Kind K) { return K == TypeAliasTemplate; }
2614 };
2615 
2616 /// Declaration of a function specialization at template class scope.
2617 ///
2618 /// For example:
2619 /// \code
2620 /// template <class T>
2621 /// class A {
2622 /// template <class U> void foo(U a) { }
2623 /// template<> void foo(int a) { }
2624 /// }
2625 /// \endcode
2626 ///
2627 /// "template<> foo(int a)" will be saved in Specialization as a normal
2628 /// CXXMethodDecl. Then during an instantiation of class A, it will be
2629 /// transformed into an actual function specialization.
2630 ///
2631 /// FIXME: This is redundant; we could store the same information directly on
2632 /// the CXXMethodDecl as a DependentFunctionTemplateSpecializationInfo.
2634  CXXMethodDecl *Specialization;
2635  const ASTTemplateArgumentListInfo *TemplateArgs;
2636 
2639  const ASTTemplateArgumentListInfo *TemplArgs)
2640  : Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc),
2641  Specialization(FD), TemplateArgs(TemplArgs) {}
2642 
2644  : Decl(Decl::ClassScopeFunctionSpecialization, Empty) {}
2645 
2646  virtual void anchor();
2647 
2648 public:
2649  friend class ASTDeclReader;
2650  friend class ASTDeclWriter;
2651 
2653  bool hasExplicitTemplateArgs() const { return TemplateArgs; }
2655  return TemplateArgs;
2656  }
2657 
2660  bool HasExplicitTemplateArgs,
2661  const TemplateArgumentListInfo &TemplateArgs) {
2662  return new (C, DC) ClassScopeFunctionSpecializationDecl(
2663  DC, Loc, FD,
2664  HasExplicitTemplateArgs
2665  ? ASTTemplateArgumentListInfo::Create(C, TemplateArgs)
2666  : nullptr);
2667  }
2668 
2670  CreateDeserialized(ASTContext &Context, unsigned ID);
2671 
2672  // Implement isa/cast/dyncast/etc.
2673  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2674 
2675  static bool classofKind(Kind K) {
2676  return K == Decl::ClassScopeFunctionSpecialization;
2677  }
2678 };
2679 
2680 /// Represents a variable template specialization, which refers to
2681 /// a variable template with a given set of template arguments.
2682 ///
2683 /// Variable template specializations represent both explicit
2684 /// specializations of variable templates, as in the example below, and
2685 /// implicit instantiations of variable templates.
2686 ///
2687 /// \code
2688 /// template<typename T> constexpr T pi = T(3.1415926535897932385);
2689 ///
2690 /// template<>
2691 /// constexpr float pi<float>; // variable template specialization pi<float>
2692 /// \endcode
2694  public llvm::FoldingSetNode {
2695 
2696  /// Structure that stores information about a variable template
2697  /// specialization that was instantiated from a variable template partial
2698  /// specialization.
2699  struct SpecializedPartialSpecialization {
2700  /// The variable template partial specialization from which this
2701  /// variable template specialization was instantiated.
2702  VarTemplatePartialSpecializationDecl *PartialSpecialization;
2703 
2704  /// The template argument list deduced for the variable template
2705  /// partial specialization itself.
2706  const TemplateArgumentList *TemplateArgs;
2707  };
2708 
2709  /// The template that this specialization specializes.
2710  llvm::PointerUnion<VarTemplateDecl *, SpecializedPartialSpecialization *>
2711  SpecializedTemplate;
2712 
2713  /// Further info for explicit template specialization/instantiation.
2714  struct ExplicitSpecializationInfo {
2715  /// The type-as-written.
2716  TypeSourceInfo *TypeAsWritten = nullptr;
2717 
2718  /// The location of the extern keyword.
2719  SourceLocation ExternLoc;
2720 
2721  /// The location of the template keyword.
2722  SourceLocation TemplateKeywordLoc;
2723 
2724  ExplicitSpecializationInfo() = default;
2725  };
2726 
2727  /// Further info for explicit template specialization/instantiation.
2728  /// Does not apply to implicit specializations.
2729  ExplicitSpecializationInfo *ExplicitInfo = nullptr;
2730 
2731  /// The template arguments used to describe this specialization.
2732  const TemplateArgumentList *TemplateArgs;
2733  const ASTTemplateArgumentListInfo *TemplateArgsInfo = nullptr;
2734 
2735  /// The point where this template was instantiated (if any).
2736  SourceLocation PointOfInstantiation;
2737 
2738  /// The kind of specialization this declaration refers to.
2739  /// Really a value of type TemplateSpecializationKind.
2740  unsigned SpecializationKind : 3;
2741 
2742  /// Whether this declaration is a complete definition of the
2743  /// variable template specialization. We can't otherwise tell apart
2744  /// an instantiated declaration from an instantiated definition with
2745  /// no initializer.
2746  unsigned IsCompleteDefinition : 1;
2747 
2748 protected:
2750  SourceLocation StartLoc, SourceLocation IdLoc,
2751  VarTemplateDecl *SpecializedTemplate,
2752  QualType T, TypeSourceInfo *TInfo,
2753  StorageClass S,
2755 
2756  explicit VarTemplateSpecializationDecl(Kind DK, ASTContext &Context);
2757 
2758 public:
2759  friend class ASTDeclReader;
2760  friend class ASTDeclWriter;
2761  friend class VarDecl;
2762 
2764  Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
2765  SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T,
2766  TypeSourceInfo *TInfo, StorageClass S,
2769  unsigned ID);
2770 
2771  void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy,
2772  bool Qualified) const override;
2773 
2775  VarDecl *Recent = static_cast<VarDecl *>(this)->getMostRecentDecl();
2776  return cast<VarTemplateSpecializationDecl>(Recent);
2777  }
2778 
2779  /// Retrieve the template that this specialization specializes.
2781 
2782  /// Retrieve the template arguments of the variable template
2783  /// specialization.
2784  const TemplateArgumentList &getTemplateArgs() const { return *TemplateArgs; }
2785 
2786  // TODO: Always set this when creating the new specialization?
2787  void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo);
2788  void setTemplateArgsInfo(const ASTTemplateArgumentListInfo *ArgsInfo);
2789 
2791  return TemplateArgsInfo;
2792  }
2793 
2794  /// Determine the kind of specialization that this
2795  /// declaration represents.
2797  return static_cast<TemplateSpecializationKind>(SpecializationKind);
2798  }
2799 
2802  }
2803 
2805  return isExplicitSpecialization() &&
2806  isa<CXXRecordDecl>(getLexicalDeclContext());
2807  }
2808 
2809  /// True if this declaration is an explicit specialization,
2810  /// explicit instantiation declaration, or explicit instantiation
2811  /// definition.
2815  }
2816 
2818  SpecializationKind = TSK;
2819  }
2820 
2821  /// Get the point of instantiation (if any), or null if none.
2823  return PointOfInstantiation;
2824  }
2825 
2827  assert(Loc.isValid() && "point of instantiation must be valid!");
2828  PointOfInstantiation = Loc;
2829  }
2830 
2831  void setCompleteDefinition() { IsCompleteDefinition = true; }
2832 
2833  /// If this variable template specialization is an instantiation of
2834  /// a template (rather than an explicit specialization), return the
2835  /// variable template or variable template partial specialization from which
2836  /// it was instantiated.
2837  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2840  return llvm::PointerUnion<VarTemplateDecl *,
2842 
2844  }
2845 
2846  /// Retrieve the variable template or variable template partial
2847  /// specialization which was specialized by this.
2848  llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2850  if (const auto *PartialSpec =
2851  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2852  return PartialSpec->PartialSpecialization;
2853 
2854  return SpecializedTemplate.get<VarTemplateDecl *>();
2855  }
2856 
2857  /// Retrieve the set of template arguments that should be used
2858  /// to instantiate the initializer of the variable template or variable
2859  /// template partial specialization from which this variable template
2860  /// specialization was instantiated.
2861  ///
2862  /// \returns For a variable template specialization instantiated from the
2863  /// primary template, this function will return the same template arguments
2864  /// as getTemplateArgs(). For a variable template specialization instantiated
2865  /// from a variable template partial specialization, this function will the
2866  /// return deduced template arguments for the variable template partial
2867  /// specialization itself.
2869  if (const auto *PartialSpec =
2870  SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2871  return *PartialSpec->TemplateArgs;
2872 
2873  return getTemplateArgs();
2874  }
2875 
2876  /// Note that this variable template specialization is actually an
2877  /// instantiation of the given variable template partial specialization whose
2878  /// template arguments have been deduced.
2880  const TemplateArgumentList *TemplateArgs) {
2881  assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2882  "Already set to a variable template partial specialization!");
2883  auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
2884  PS->PartialSpecialization = PartialSpec;
2885  PS->TemplateArgs = TemplateArgs;
2886  SpecializedTemplate = PS;
2887  }
2888 
2889  /// Note that this variable template specialization is an instantiation
2890  /// of the given variable template.
2892  assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
2893  "Previously set to a variable template partial specialization!");
2894  SpecializedTemplate = TemplDecl;
2895  }
2896 
2897  /// Sets the type of this specialization as it was written by
2898  /// the user.
2900  if (!ExplicitInfo)
2901  ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
2902  ExplicitInfo->TypeAsWritten = T;
2903  }
2904 
2905  /// Gets the type of this specialization as it was written by
2906  /// the user, if it was so written.
2908  return ExplicitInfo ? ExplicitInfo->TypeAsWritten : nullptr;
2909  }
2910 
2911  /// Gets the location of the extern keyword, if present.
2913  return ExplicitInfo ? ExplicitInfo->ExternLoc : SourceLocation();
2914  }
2915 
2916  /// Sets the location of the extern keyword.
2918  if (!ExplicitInfo)
2919  ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
2920  ExplicitInfo->ExternLoc = Loc;
2921  }
2922 
2923  /// Sets the location of the template keyword.
2925  if (!ExplicitInfo)
2926  ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
2927  ExplicitInfo->TemplateKeywordLoc = Loc;
2928  }
2929 
2930  /// Gets the location of the template keyword, if present.
2932  return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
2933  }
2934 
2935  void Profile(llvm::FoldingSetNodeID &ID) const {
2936  Profile(ID, TemplateArgs->asArray(), getASTContext());
2937  }
2938 
2939  static void Profile(llvm::FoldingSetNodeID &ID,
2940  ArrayRef<TemplateArgument> TemplateArgs,
2941  ASTContext &Context) {
2942  ID.AddInteger(TemplateArgs.size());
2943  for (const TemplateArgument &TemplateArg : TemplateArgs)
2944  TemplateArg.Profile(ID, Context);
2945  }
2946 
2947  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2948 
2949  static bool classofKind(Kind K) {
2950  return K >= firstVarTemplateSpecialization &&
2951  K <= lastVarTemplateSpecialization;
2952  }
2953 };
2954 
2957  /// The list of template parameters
2958  TemplateParameterList *TemplateParams = nullptr;
2959 
2960  /// The source info for the template arguments as written.
2961  /// FIXME: redundant with TypeAsWritten?
2962  const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr;
2963 
2964  /// The variable template partial specialization from which this
2965  /// variable template partial specialization was instantiated.
2966  ///
2967  /// The boolean value will be true to indicate that this variable template
2968  /// partial specialization was specialized at this level.
2969  llvm::PointerIntPair<VarTemplatePartialSpecializationDecl *, 1, bool>
2970  InstantiatedFromMember;
2971 
2973  ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
2974  SourceLocation IdLoc, TemplateParameterList *Params,
2975  VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo,
2977  const ASTTemplateArgumentListInfo *ArgInfos);
2978 
2980  : VarTemplateSpecializationDecl(VarTemplatePartialSpecialization,
2981  Context),
2982  InstantiatedFromMember(nullptr, false) {}
2983 
2984  void anchor() override;
2985 
2986 public:
2987  friend class ASTDeclReader;
2988  friend class ASTDeclWriter;
2989 
2991  Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc,
2992  SourceLocation IdLoc, TemplateParameterList *Params,
2993  VarTemplateDecl *SpecializedTemplate, QualType T,
2995  const TemplateArgumentListInfo &ArgInfos);
2996 
2998  unsigned ID);
2999 
3001  return cast<VarTemplatePartialSpecializationDecl>(
3002  static_cast<VarTemplateSpecializationDecl *>(
3003  this)->getMostRecentDecl());
3004  }
3005 
3006  /// Get the list of template parameters
3008  return TemplateParams;
3009  }
3010 
3011  /// Get the template arguments as written.
3013  return ArgsAsWritten;
3014  }
3015 
3016  /// \brief All associated constraints of this partial specialization,
3017  /// including the requires clause and any constraints derived from
3018  /// constrained-parameters.
3019  ///
3020  /// The constraints in the resulting list are to be treated as if in a
3021  /// conjunction ("and").
3023  TemplateParams->getAssociatedConstraints(AC);
3024  }
3025 
3027  return TemplateParams->hasAssociatedConstraints();
3028  }
3029 
3030  /// \brief Retrieve the member variable template partial specialization from
3031  /// which this particular variable template partial specialization was
3032  /// instantiated.
3033  ///
3034  /// \code
3035  /// template<typename T>
3036  /// struct Outer {
3037  /// template<typename U> U Inner;
3038  /// template<typename U> U* Inner<U*> = (U*)(0); // #1
3039  /// };
3040  ///
3041  /// template int* Outer<float>::Inner<int*>;
3042  /// \endcode
3043  ///
3044  /// In this example, the instantiation of \c Outer<float>::Inner<int*> will
3045  /// end up instantiating the partial specialization
3046  /// \c Outer<float>::Inner<U*>, which itself was instantiated from the
3047  /// variable template partial specialization \c Outer<T>::Inner<U*>. Given
3048  /// \c Outer<float>::Inner<U*>, this function would return
3049  /// \c Outer<T>::Inner<U*>.
3051  const auto *First =
3052  cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
3053  return First->InstantiatedFromMember.getPointer();
3054  }
3055 
3056  void
3058  auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
3059  First->InstantiatedFromMember.setPointer(PartialSpec);
3060  }
3061 
3062  /// Determines whether this variable template partial specialization
3063  /// was a specialization of a member partial specialization.
3064  ///
3065  /// In the following example, the member template partial specialization
3066  /// \c X<int>::Inner<T*> is a member specialization.
3067  ///
3068  /// \code
3069  /// template<typename T>
3070  /// struct X {
3071  /// template<typename U> U Inner;
3072  /// template<typename U> U* Inner<U*> = (U*)(0);
3073  /// };
3074  ///
3075  /// template<> template<typename T>
3076  /// U* X<int>::Inner<T*> = (T*)(0) + 1;
3077  /// \endcode
3079  const auto *First =
3080  cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
3081  return First->InstantiatedFromMember.getInt();
3082  }
3083 
3084  /// Note that this member template is a specialization.
3086  auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
3087  assert(First->InstantiatedFromMember.getPointer() &&
3088  "Only member templates can be member template specializations");
3089  return First->InstantiatedFromMember.setInt(true);
3090  }
3091 
3092  void Profile(llvm::FoldingSetNodeID &ID) const {
3094  getASTContext());
3095  }
3096 
3097  static void
3098  Profile(llvm::FoldingSetNodeID &ID, ArrayRef<TemplateArgument> TemplateArgs,
3099  TemplateParameterList *TPL, ASTContext &Context);
3100 
3101  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3102 
3103  static bool classofKind(Kind K) {
3104  return K == VarTemplatePartialSpecialization;
3105  }
3106 };
3107 
3108 /// Declaration of a variable template.
3110 protected:
3111  /// Data that is common to all of the declarations of a given
3112  /// variable template.
3113  struct Common : CommonBase {
3114  /// The variable template specializations for this variable
3115  /// template, including explicit specializations and instantiations.
3116  llvm::FoldingSetVector<VarTemplateSpecializationDecl> Specializations;
3117 
3118  /// The variable template partial specializations for this variable
3119  /// template.
3120  llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl>
3122 
3123  Common() = default;
3124  };
3125 
3126  /// Retrieve the set of specializations of this variable template.
3127  llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
3128  getSpecializations() const;
3129 
3130  /// Retrieve the set of partial specializations of this class
3131  /// template.
3132  llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
3133  getPartialSpecializations() const;
3134 
3136  DeclarationName Name, TemplateParameterList *Params,
3137  NamedDecl *Decl)
3138  : RedeclarableTemplateDecl(VarTemplate, C, DC, L, Name, Params, Decl) {}
3139 
3140  CommonBase *newCommon(ASTContext &C) const override;
3141 
3143  return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
3144  }
3145 
3146 public:
3147  friend class ASTDeclReader;
3148  friend class ASTDeclWriter;
3149 
3150  /// Load any lazily-loaded specializations from the external source.
3151  void LoadLazySpecializations() const;
3152 
3153  /// Get the underlying variable declarations of the template.
3155  return static_cast<VarDecl *>(TemplatedDecl);
3156  }
3157 
3158  /// Returns whether this template declaration defines the primary
3159  /// variable pattern.
3162  }
3163 
3165 
3166  /// Create a variable template node.
3169  TemplateParameterList *Params,
3170  VarDecl *Decl);
3171 
3172  /// Create an empty variable template node.
3173  static VarTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID);
3174 
3175  /// Return the specialization with the provided arguments if it exists,
3176  /// otherwise return the insertion point.
3178  findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos);
3179 
3180  /// Insert the specified specialization knowing that it is not already
3181  /// in. InsertPos must be obtained from findSpecialization.
3182  void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos);
3183 
3185  return cast<VarTemplateDecl>(RedeclarableTemplateDecl::getCanonicalDecl());
3186  }
3188  return cast<VarTemplateDecl>(RedeclarableTemplateDecl::getCanonicalDecl());
3189  }
3190 
3191  /// Retrieve the previous declaration of this variable template, or
3192  /// nullptr if no such declaration exists.
3194  return cast_or_null<VarTemplateDecl>(
3195  static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl());
3196  }
3198  return cast_or_null<VarTemplateDecl>(
3199  static_cast<const RedeclarableTemplateDecl *>(
3200  this)->getPreviousDecl());
3201  }
3202 
3204  return cast<VarTemplateDecl>(
3205  static_cast<RedeclarableTemplateDecl *>(this)->getMostRecentDecl());
3206  }
3208  return const_cast<VarTemplateDecl *>(this)->getMostRecentDecl();
3209  }
3210 
3212  return cast_or_null<VarTemplateDecl>(
3214  }
3215 
3216  /// Return the partial specialization with the provided arguments if it
3217  /// exists, otherwise return the insertion point.
3220  TemplateParameterList *TPL, void *&InsertPos);
3221 
3222  /// Insert the specified partial specialization knowing that it is not
3223  /// already in. InsertPos must be obtained from findPartialSpecialization.
3225  void *InsertPos);
3226 
3227  /// Retrieve the partial specializations as an ordered list.
3230 
3231  /// Find a variable template partial specialization which was
3232  /// instantiated
3233  /// from the given member partial specialization.
3234  ///
3235  /// \param D a member variable template partial specialization.
3236  ///
3237  /// \returns the variable template partial specialization which was
3238  /// instantiated
3239  /// from the given member partial specialization, or nullptr if no such
3240  /// partial specialization exists.
3243 
3245  using spec_range = llvm::iterator_range<spec_iterator>;
3246 
3248  return spec_range(spec_begin(), spec_end());
3249  }
3250 
3252  return makeSpecIterator(getSpecializations(), false);
3253  }
3254 
3256  return makeSpecIterator(getSpecializations(), true);
3257  }
3258 
3259  // Implement isa/cast/dyncast support
3260  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3261  static bool classofKind(Kind K) { return K == VarTemplate; }
3262 };
3263 
3264 /// Declaration of a C++2a concept.
3265 class ConceptDecl : public TemplateDecl, public Mergeable<ConceptDecl> {
3266 protected:
3268 
3271  : TemplateDecl(Concept, DC, L, Name, Params),
3273 public:
3274  static ConceptDecl *Create(ASTContext &C, DeclContext *DC,
3276  TemplateParameterList *Params,
3277  Expr *ConstraintExpr);
3278  static ConceptDecl *CreateDeserialized(ASTContext &C, unsigned ID);
3279 
3281  return ConstraintExpr;
3282  }
3283 
3284  SourceRange getSourceRange() const override LLVM_READONLY {
3285  return SourceRange(getTemplateParameters()->getTemplateLoc(),
3287  }
3288 
3289  bool isTypeConcept() const {
3290  return isa<TemplateTypeParmDecl>(getTemplateParameters()->getParam(0));
3291  }
3292 
3294  return cast<ConceptDecl>(getPrimaryMergedDecl(this));
3295  }
3297  return const_cast<ConceptDecl *>(this)->getCanonicalDecl();
3298  }
3299 
3300  // Implement isa/cast/dyncast/etc.
3301  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3302  static bool classofKind(Kind K) { return K == Concept; }
3303 
3304  friend class ASTReader;
3305  friend class ASTDeclReader;
3306  friend class ASTDeclWriter;
3307 };
3308 
3309 /// A template parameter object.
3310 ///
3311 /// Template parameter objects represent values of class type used as template
3312 /// arguments. There is one template parameter object for each such distinct
3313 /// value used as a template argument across the program.
3314 ///
3315 /// \code
3316 /// struct A { int x, y; };
3317 /// template<A> struct S;
3318 /// S<A{1, 2}> s1;
3319 /// S<A{1, 2}> s2; // same type, argument is same TemplateParamObjectDecl.
3320 /// \endcode
3322  public Mergeable<TemplateParamObjectDecl>,
3323  public llvm::FoldingSetNode {
3324 private:
3325  /// The value of this template parameter object.
3326  APValue Value;
3327 
3329  : ValueDecl(TemplateParamObject, DC, SourceLocation(), DeclarationName(),
3330  T),
3331  Value(V) {}
3332 
3333  static TemplateParamObjectDecl *Create(const ASTContext &C, QualType T,
3334  const APValue &V);
3335  static TemplateParamObjectDecl *CreateDeserialized(ASTContext &C,
3336  unsigned ID);
3337 
3338  /// Only ASTContext::getTemplateParamObjectDecl and deserialization
3339  /// create these.
3340  friend class ASTContext;
3341  friend class ASTReader;
3342  friend class ASTDeclReader;
3343 
3344 public:
3345  /// Print this template parameter object in a human-readable format.
3346  void printName(llvm::raw_ostream &OS) const override;
3347 
3348  /// Print this object as an equivalent expression.
3349  void printAsExpr(llvm::raw_ostream &OS) const;
3350  void printAsExpr(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
3351 
3352  /// Print this object as an initializer suitable for a variable of the
3353  /// object's type.
3354  void printAsInit(llvm::raw_ostream &OS) const;
3355  void printAsInit(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const;
3356 
3357  const APValue &getValue() const { return Value; }
3358 
3359  static void Profile(llvm::FoldingSetNodeID &ID, QualType T,
3360  const APValue &V) {
3361  ID.AddPointer(T.getCanonicalType().getAsOpaquePtr());
3362  V.Profile(ID);
3363  }
3364  void Profile(llvm::FoldingSetNodeID &ID) {
3365  Profile(ID, getType(), getValue());
3366  }
3367 
3369  return getFirstDecl();
3370  }
3372  return getFirstDecl();
3373  }
3374 
3375  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3376  static bool classofKind(Kind K) { return K == TemplateParamObject; }
3377 };
3378 
3380  if (auto *PD = P.dyn_cast<TemplateTypeParmDecl *>())
3381  return PD;
3382  if (auto *PD = P.dyn_cast<NonTypeTemplateParmDecl *>())
3383  return PD;
3384  return P.get<TemplateTemplateParmDecl *>();
3385 }
3386 
3388  auto *TD = dyn_cast<TemplateDecl>(D);
3389  return TD && (isa<ClassTemplateDecl>(TD) ||
3390  isa<ClassTemplatePartialSpecializationDecl>(TD) ||
3391  isa<TypeAliasTemplateDecl>(TD) ||
3392  isa<TemplateTemplateParmDecl>(TD))
3393  ? TD
3394  : nullptr;
3395 }
3396 
3397 /// Check whether the template parameter is a pack expansion, and if so,
3398 /// determine the number of parameters produced by that expansion. For instance:
3399 ///
3400 /// \code
3401 /// template<typename ...Ts> struct A {
3402 /// template<Ts ...NTs, template<Ts> class ...TTs, typename ...Us> struct B;
3403 /// };
3404 /// \endcode
3405 ///
3406 /// In \c A<int,int>::B, \c NTs and \c TTs have expanded pack size 2, and \c Us
3407 /// is not a pack expansion, so returns an empty Optional.
3409  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
3410  if (TTP->isExpandedParameterPack())
3411  return TTP->getNumExpansionParameters();
3412  }
3413 
3414  if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3415  if (NTTP->isExpandedParameterPack())
3416  return NTTP->getNumExpansionTypes();
3417  }
3418 
3419  if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3420  if (TTP->isExpandedParameterPack())
3421  return TTP->getNumExpansionTemplateParameters();
3422  }
3423 
3424  return None;
3425 }
3426 
3427 } // namespace clang
3428 
3429 #endif // LLVM_CLANG_AST_DECLTEMPLATE_H
clang::DependentFunctionTemplateSpecializationInfo::Create
static DependentFunctionTemplateSpecializationInfo * Create(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Definition: Decl.cpp:3977
clang::TemplateParameterList::getRequiresClause
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Definition: DeclTemplate.h:175
clang::VarTemplatePartialSpecializationDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:3007
clang::isTemplateExplicitInstantiationOrSpecialization
bool isTemplateExplicitInstantiationOrSpecialization(TemplateSpecializationKind Kind)
True if this template specialization kind is an explicit specialization, explicit instantiation decla...
Definition: Specifiers.h:207
clang::TemplateDecl::getTemplatedDecl
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:441
clang::allocateDefaultArgStorageChain
void * allocateDefaultArgStorageChain(const ASTContext &C)
Definition: DeclTemplate.cpp:220
clang::ClassTemplateSpecializationDecl::setTemplateKeywordLoc
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Definition: DeclTemplate.h:2071
clang::BuiltinTemplateDecl::Create
static BuiltinTemplateDecl * Create(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK)
Definition: DeclTemplate.h:1806
clang::ClassTemplateDecl::spec_range
llvm::iterator_range< spec_iterator > spec_range
Definition: DeclTemplate.h:2441
clang::ClassTemplateDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
Definition: DeclTemplate.h:2330
clang::FunctionTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:384
clang::ConceptDecl::getConstraintExpr
Expr * getConstraintExpr() const
Definition: DeclTemplate.h:3280
clang::ClassTemplatePartialSpecializationDecl::getMostRecentDecl
ClassTemplatePartialSpecializationDecl * getMostRecentDecl()
Definition: DeclTemplate.h:2154
clang::FunctionTemplateDecl::mergePrevDecl
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
Definition: DeclTemplate.cpp:422
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:429
clang::RedeclarableTemplateDecl::setInstantiatedFromMemberTemplate
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
Definition: DeclTemplate.h:953
clang::TemplateParameterList::print
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
Definition: DeclPrinter.cpp:137
clang::TemplateParameterList::Create
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Definition: DeclTemplate.cpp:119
clang::DefaultArgStorage::get
ArgType get() const
Get the default argument's value.
Definition: DeclTemplate.h:350
clang::FriendTemplateDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:2540
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::TemplateArgumentList::TrailingObjects
friend TrailingObjects
Definition: DeclTemplate.h:252
clang::VarTemplateDecl::findSpecialization
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
Definition: DeclTemplate.cpp:1233
clang::VarTemplateDecl::getMostRecentDecl
const VarTemplateDecl * getMostRecentDecl() const
Definition: DeclTemplate.h:3207
clang::FriendTemplateDecl::getFriendLoc
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
Definition: DeclTemplate.h:2525
clang::ClassTemplateDecl::Common::PartialSpecializations
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > PartialSpecializations
The class template partial specializations for this class template.
Definition: DeclTemplate.h:2288
clang::RedeclarableTemplateDecl::CommonBase
Definition: DeclTemplate.h:834
clang::FriendTemplateDecl
Declaration of a friend template.
Definition: DeclTemplate.h:2473
Specifiers.h
clang::RedeclarableTemplateDecl::newCommon
virtual CommonBase * newCommon(ASTContext &C) const =0
clang::TemplateArgumentList::TemplateArgumentList
TemplateArgumentList(OnStackType, ArrayRef< TemplateArgument > Args)
Construct a new, temporary template argument list on the stack.
Definition: DeclTemplate.h:270
clang::NonTypeTemplateParmDecl::getDefaultArgStorage
const DefArgStorage & getDefaultArgStorage() const
Definition: DeclTemplate.h:1488
clang::TemplateParmPosition::TemplateParmPosition
TemplateParmPosition()=delete
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6657
clang::TemplateTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1748
clang::DependentFunctionTemplateSpecializationInfo
Provides information about a dependent function-template specialization declaration.
Definition: DeclTemplate.h:696
clang::VarTemplateDecl::Common::Specializations
llvm::FoldingSetVector< VarTemplateSpecializationDecl > Specializations
The variable template specializations for this variable template, including explicit specializations ...
Definition: DeclTemplate.h:3116
clang::TemplateTypeParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Definition: DeclTemplate.h:1295
clang::DependentFunctionTemplateSpecializationInfo::TrailingObjects
friend TrailingObjects
Definition: DeclTemplate.h:721
clang::TemplateTypeParmDecl::getIndex
unsigned getIndex() const
Retrieve the index of the template parameter.
Definition: DeclTemplate.cpp:695
clang::VarTemplatePartialSpecializationDecl::CreateDeserialized
static VarTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1409
clang::MemberSpecializationInfo
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:632
clang::ClassTemplatePartialSpecializationDecl::Create
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
Definition: DeclTemplate.cpp:1082
clang::UnresolvedSetImpl
A set of unresolved declarations.
Definition: UnresolvedSet.h:61
clang::TypeAliasTemplateDecl::getInstantiatedFromMemberTemplate
TypeAliasTemplateDecl * getInstantiatedFromMemberTemplate() const
Definition: DeclTemplate.h:2596
clang::TypeAliasTemplateDecl::CreateDeserialized
static TypeAliasTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty alias template node.
Definition: DeclTemplate.cpp:1152
clang::AutoType::isConstrained
bool isConstrained() const
Definition: Type.h:5264
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::NonTypeTemplateParmDecl::hasPlaceholderTypeConstraint
bool hasPlaceholderTypeConstraint() const
Determine whether this non-type template parameter's type has a placeholder with a type-constraint.
Definition: DeclTemplate.h:1602
clang::VarTemplateSpecializationDecl::getInstantiatedFrom
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this variable template specialization is an instantiation of a template (rather than an explicit s...
Definition: DeclTemplate.h:2838
clang::TemplateTypeParmDecl::getDefaultArgument
QualType getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1281
clang::TemplateParmPosition::getDepth
unsigned getDepth() const
Get the nesting depth of the template parameter.
Definition: DeclTemplate.h:1183
clang::Redeclarable
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:84
clang::ClassTemplateSpecializationDecl::setTypeAsWritten
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
Definition: DeclTemplate.h:2046
clang::ClassTemplateDecl::spec_begin
spec_iterator spec_begin() const
Definition: DeclTemplate.h:2447
clang::ClassTemplatePartialSpecializationDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:2161
clang::Decl::Decl
Decl()=delete
clang::ClassTemplateSpecializationDecl::getMostRecentDecl
ClassTemplateSpecializationDecl * getMostRecentDecl()
Definition: DeclTemplate.h:1910
clang::FunctionTemplateSpecializationInfo::TemplateArguments
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Definition: DeclTemplate.h:497
clang::TypeAliasTemplateDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:2613
clang::RedeclarableTemplateDecl::makeSpecIterator
static SpecIterator< EntryType > makeSpecIterator(llvm::FoldingSetVector< EntryType > &Specs, bool isEnd)
Definition: DeclTemplate.h:819
clang::VarTemplateDecl::getPreviousDecl
VarTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this variable template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:3193
clang::FunctionTemplateDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
Definition: DeclTemplate.h:1052
clang::Redeclarable< RedeclarableTemplateDecl >::redecls_begin
redecl_iterator redecls_begin() const
Definition: Redeclarable.h:302
clang::TemplateDecl::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.cpp:245
clang::VarTemplateSpecializationDecl::getMostRecentDecl
VarTemplateSpecializationDecl * getMostRecentDecl()
Definition: DeclTemplate.h:2774
clang::TemplateTypeParmDecl::CreateDeserialized
static TemplateTypeParmDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:658
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::TemplateParmPosition::TemplateParmPosition
TemplateParmPosition(unsigned D, unsigned P)
Definition: DeclTemplate.h:1170
clang::NonTypeTemplateParmDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:1619
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:2868
clang::TemplateParameterList::numTrailingObjects
size_t numTrailingObjects(OverloadToken< NamedDecl * >) const
Definition: DeclTemplate.h:99
clang::FunctionTemplateDecl::findSpecialization
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
Definition: DeclTemplate.cpp:395
clang::TemplateParameterList::getParam
const NamedDecl * getParam(unsigned Idx) const
Definition: DeclTemplate.h:143
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::ClassTemplateSpecializationDecl::getPointOfInstantiation
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
Definition: DeclTemplate.h:1969
clang::ClassTemplateSpecializationDecl::getSpecializedTemplate
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:986
clang::VarTemplateDecl::AddPartialSpecialization
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:1260
clang::RedeclarableTemplateDecl::SpecEntryTraits< FunctionTemplateSpecializationInfo >::getDecl
static DeclType * getDecl(FunctionTemplateSpecializationInfo *I)
Definition: DeclTemplate.h:980
clang::VarTemplateDecl::spec_end
spec_iterator spec_end() const
Definition: DeclTemplate.h:3255
clang::ClassTemplateSpecializationDecl::getExternLoc
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
Definition: DeclTemplate.h:2059
clang::TemplateTypeParmDecl::setDefaultArgument
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
Definition: DeclTemplate.h:1300
clang::ClassTemplateSpecializationDecl::Create
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
Definition: DeclTemplate.cpp:933
clang::TemplateArgumentList::TemplateArgumentList
TemplateArgumentList(const TemplateArgumentList *Other)
Produces a shallow copy of the given template argument list.
Definition: DeclTemplate.h:279
clang::TSK_Undeclared
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
Definition: Specifiers.h:179
clang::TemplateParameterList::getRequiresClause
const Expr * getRequiresClause() const
The constraint-expression of the associated requires-clause.
Definition: DeclTemplate.h:180
clang::ClassTemplateDecl::Common::InjectedClassNameType
QualType InjectedClassNameType
The injected-class-name type for this class template.
Definition: DeclTemplate.h:2291
clang::VarTemplateSpecializationDecl::setSpecializationKind
void setSpecializationKind(TemplateSpecializationKind TSK)
Definition: DeclTemplate.h:2817
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::TypeDecl::getTypeForDecl
const Type * getTypeForDecl() const
Definition: Decl.h:3230
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1413
clang::TemplateDecl::getAssociatedConstraints
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the total constraint-expression associated with this template, including constraint-expressions d...
Definition: DeclTemplate.cpp:238
clang::DefaultArgStorage::isSet
bool isSet() const
Determine whether there is a default argument for this parameter.
Definition: DeclTemplate.h:342
clang::RedeclarableTemplateDecl::SpecEntryTraits
Definition: DeclTemplate.h:784
clang::ClassTemplateDecl::spec_end
spec_iterator spec_end() const
Definition: DeclTemplate.h:2451
clang::Redeclarable< RedeclarableTemplateDecl >::redecls_end
redecl_iterator redecls_end() const
Definition: Redeclarable.h:303
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:55
clang::ClassScopeFunctionSpecializationDecl::hasExplicitTemplateArgs
bool hasExplicitTemplateArgs() const
Definition: DeclTemplate.h:2653
clang::TemplateTemplateParmDecl::getDefaultArgStorage
const DefArgStorage & getDefaultArgStorage() const
Definition: DeclTemplate.h:1744
clang::ClassTemplateDecl::getInstantiatedFromMemberTemplate
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
Definition: DeclTemplate.h:2382
clang::ClassScopeFunctionSpecializationDecl
Declaration of a function specialization at template class scope.
Definition: DeclTemplate.h:2633
clang::NonTypeTemplateParmDecl::isPackExpansion
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
Definition: DeclTemplate.h:1534
clang::TemplateTemplateParmDecl::setDefaultArgument
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Definition: DeclTemplate.cpp:867
clang::QualType::getCanonicalType
QualType getCanonicalType() const
Definition: Type.h:6727
clang::TemplateParameterList::end
const_iterator end() const
Definition: DeclTemplate.h:128
clang::ClassTemplateSpecializationDecl::getSpecializationKind
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Definition: DeclTemplate.h:1930
clang::Decl::redecl_range
llvm::iterator_range< redecl_iterator > redecl_range
Definition: DeclBase.h:1010
clang::VarTemplateDecl::getInstantiatedFromMemberTemplate
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
Definition: DeclTemplate.h:3211
clang::ast_matchers::type
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchersInternal.cpp:773
clang::VarTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:3142
clang::Redeclarable< RedeclarableTemplateDecl >::getFirstDecl
RedeclarableTemplateDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:216
DeclCXX.h
clang::TemplateParameterList::getLAngleLoc
SourceLocation getLAngleLoc() const
Definition: DeclTemplate.h:195
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::DependentFunctionTemplateSpecializationInfo::getTemplateArg
const TemplateArgumentLoc & getTemplateArg(unsigned I) const
Returns the nth template argument.
Definition: DeclTemplate.h:750
clang::VarTemplateDecl::getTemplatedDecl
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
Definition: DeclTemplate.h:3154
clang::DependentFunctionTemplateSpecializationInfo::getNumTemplateArgs
unsigned getNumTemplateArgs() const
Returns the number of explicit template arguments that were given.
Definition: DeclTemplate.h:743
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:2026
clang::TemplateSubstitutionKind::Specialization
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
clang::RedeclarableTemplateDecl::SpecIterator::operator*
DeclType * operator*() const
Definition: DeclTemplate.h:810
clang::NonTypeTemplateParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:794
clang::FixedSizeTemplateParameterListStorage::FixedSizeTemplateParameterListStorage
FixedSizeTemplateParameterListStorage(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Definition: DeclTemplate.h:224
clang::NonTypeTemplateParmDecl::getExpansionType
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
Definition: DeclTemplate.h:1573
clang::TemplateParmPosition::PositionWidth
@ PositionWidth
Definition: DeclTemplate.h:1163
clang::TemplateParameterList::asArray
ArrayRef< const NamedDecl * > asArray() const
Definition: DeclTemplate.h:135
clang::VarTemplateSpecializationDecl::getNameForDiagnostic
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
Definition: DeclTemplate.cpp:1332
llvm::Optional< unsigned >
clang::VarTemplatePartialSpecializationDecl::getAssociatedConstraints
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
Definition: DeclTemplate.h:3022
clang::BuiltinTemplateDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.h:1812
clang::RedeclarableTemplateDecl::setMemberSpecialization
void setMemberSpecialization()
Note that this member template is a specialization.
Definition: DeclTemplate.h:907
clang::ClassTemplatePartialSpecializationDecl::getInstantiatedFromMemberTemplate
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMemberTemplate() const
Definition: DeclTemplate.h:2210
clang::NonTypeTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1492
clang::VarTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Definition: DeclTemplate.h:2784
clang::FunctionTemplateSpecializationInfo::setTemplateSpecializationKind
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
Definition: DeclTemplate.h:559
clang::VarTemplateDecl::findPartialSpecInstantiatedFromMember
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
Definition: DeclTemplate.cpp:1286
clang::DefaultArgStorage::clear
void clear()
Remove the default argument, even if it was inherited.
Definition: DeclTemplate.h:395
clang::ClassTemplateSpecializationDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:994
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2104
clang::ClassTemplateSpecializationDecl::setTemplateArgs
void setTemplateArgs(TemplateArgumentList *Args)
Definition: DeclTemplate.h:1924
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::TemplateParmPosition::getPosition
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
Definition: DeclTemplate.h:1191
clang::DependentFunctionTemplateSpecializationInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: DeclTemplate.h:745
clang::RedeclarableTemplateDecl
Declaration of a redeclarable template.
Definition: DeclTemplate.h:765
clang::FunctionTemplateDecl::Create
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
Definition: DeclTemplate.cpp:361
clang::TemplateDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:447
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2693
clang::VarTemplateSpecializationDecl::setPointOfInstantiation
void setPointOfInstantiation(SourceLocation Loc)
Definition: DeclTemplate.h:2826
clang::VarTemplateSpecializationDecl::setTemplateKeywordLoc
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Definition: DeclTemplate.h:2924
clang::DependentFunctionTemplateSpecializationInfo::getTemplateArgs
const TemplateArgumentLoc * getTemplateArgs() const
Returns the explicit template arguments that were given.
Definition: DeclTemplate.h:738
clang::detail::Qualified
std::conditional_t< Const, const T, T > Qualified
Definition: HeaderSearch.h:158
clang::TemplateParmPosition::setDepth
void setDepth(unsigned D)
Definition: DeclTemplate.h:1184
clang::DefaultArgStorage::DefaultArgStorage
DefaultArgStorage()
Definition: DeclTemplate.h:339
clang::TemplateTypeParmDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:1405
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
End
SourceLocation End
Definition: USRLocFinder.cpp:167
clang::TemplateDecl::TemplatedDecl
NamedDecl * TemplatedDecl
Definition: DeclTemplate.h:459
clang::ClassTemplateDecl::Common
Data that is common to all of the declarations of a given class template.
Definition: DeclTemplate.h:2280
clang::TemplateTypeParmDecl::hasTypeConstraint
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
Definition: DeclTemplate.h:1387
clang::VarTemplateDecl::getCanonicalDecl
const VarTemplateDecl * getCanonicalDecl() const
Definition: DeclTemplate.h:3187
clang::ClassTemplateDecl::CreateDeserialized
static ClassTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty class template node.
Definition: DeclTemplate.cpp:472
clang::VarTemplateSpecializationDecl::isExplicitInstantiationOrSpecialization
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
Definition: DeclTemplate.h:2812
clang::TemplateParamObjectDecl::printAsInit
void printAsInit(llvm::raw_ostream &OS) const
Print this object as an initializer suitable for a variable of the object's type.
Definition: DeclTemplate.cpp:1551
clang::TemplateDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:449
clang::VarTemplateDecl::spec_range
llvm::iterator_range< spec_iterator > spec_range
Definition: DeclTemplate.h:3245
clang::TemplateTemplateParmDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:1786
clang::DeclaratorContext::TemplateArg
@ TemplateArg
clang::TemplateTypeParmDecl::getDefaultArgumentInfo
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
Definition: DeclTemplate.h:1286
clang::TemplateTypeParmDecl::setTypeConstraint
void setTypeConstraint(NestedNameSpecifierLoc NNS, DeclarationNameInfo NameInfo, NamedDecl *FoundDecl, ConceptDecl *CD, const ASTTemplateArgumentListInfo *ArgsAsWritten, Expr *ImmediatelyDeclaredConstraint)
Definition: DeclTemplate.cpp:703
clang::TemplateArgumentList::data
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
Definition: DeclTemplate.h:301
clang::VarTemplatePartialSpecializationDecl::getInstantiatedFromMember
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
Definition: DeclTemplate.h:3050
clang::VarTemplateDecl::Common::Common
Common()=default
clang::TemplateDecl::init
void init(NamedDecl *templatedDecl, TemplateParameterList *templateParams)
Initialize the underlying templated declaration and template parameters.
Definition: DeclTemplate.h:469
clang::FunctionTemplateSpecializationInfo::getTemplate
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Definition: DeclTemplate.h:539
clang::ConceptDecl::getCanonicalDecl
ConceptDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclTemplate.h:3293
clang::TemplateTypeParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1278
Decl.h
clang::VarTemplateSpecializationDecl::setTemplateArgsInfo
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
Definition: DeclTemplate.cpp:1357
clang::Redeclarable< RedeclarableTemplateDecl >::redecl_range
llvm::iterator_range< redecl_iterator > redecl_range
Definition: Redeclarable.h:292
clang::ClassTemplateDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:2456
clang::VarTemplatePartialSpecializationDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:3101
clang::TemplateParameterList::getAssociatedConstraints
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints derived from this template parameter list, including the requires clause a...
Definition: DeclTemplate.cpp:186
clang::FriendTemplateDecl::Create
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
Definition: DeclTemplate.cpp:1119
clang::TemplateParameterList::TrailingObjects
friend TrailingObjects
Definition: DeclTemplate.h:110
clang::TemplateArgumentList::operator=
TemplateArgumentList & operator=(const TemplateArgumentList &)=delete
clang::ClassTemplateDecl::getPartialSpecializations
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
Definition: DeclTemplate.cpp:489
clang::TemplateArgumentList::get
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Definition: DeclTemplate.h:283
clang::NonTypeTemplateParmDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:1620
clang::TypeAliasTemplateDecl::getTemplatedDecl
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Definition: DeclTemplate.h:2570
clang::TemplateTypeParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.cpp:679
U
clang::RedeclarableTemplateDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:971
clang::FunctionTemplateDecl::getMostRecentDecl
const FunctionTemplateDecl * getMostRecentDecl() const
Definition: DeclTemplate.h:1086
clang::Decl::getLexicalDeclContext
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:883
clang::TypeAliasTemplateDecl::getCanonicalDecl
TypeAliasTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:2575
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:991
llvm::MutableArrayRef
Definition: LLVM.h:35
clang::TemplateTypeParmDecl::isExpandedParameterPack
bool isExpandedParameterPack() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
Definition: DeclTemplate.h:1365
clang::ClassTemplateDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:2457
clang::FunctionTemplateSpecializationInfo::getPointOfInstantiation
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
Definition: DeclTemplate.h:570
TemplateBase.h
clang::ClassTemplatePartialSpecializationDecl::getInstantiatedFromMember
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
Definition: DeclTemplate.h:2204
V
#define V(N, I)
Definition: ASTContext.h:3233
clang::TemplateDecl::TemplateDecl
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.cpp:230
clang::VarTemplateSpecializationDecl::getTemplateKeywordLoc
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
Definition: DeclTemplate.h:2931
clang::NonTypeTemplateParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Definition: DeclTemplate.h:1502
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:86
clang::VarTemplateDecl::VarTemplateDecl
VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:3135
clang::TemplateArgumentList::CreateCopy
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
Definition: DeclTemplate.cpp:886
clang::VarTemplateDecl::Create
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Definition: DeclTemplate.cpp:1192
clang::VarTemplatePartialSpecializationDecl::isMemberSpecialization
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
Definition: DeclTemplate.h:3078
clang::ClassTemplateSpecializationDecl::getTemplateArgs
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Definition: DeclTemplate.h:1920
clang::TemplateParameterList::getParam
NamedDecl * getParam(unsigned Idx)
Definition: DeclTemplate.h:139
clang::TemplateParmPosition::getIndex
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
Definition: DeclTemplate.h:1199
clang::PackExpansionType
Represents a pack expansion of types.
Definition: Type.h:5883
clang::FunctionTemplateSpecializationInfo::Profile
void Profile(llvm::FoldingSetNodeID &ID)
Definition: DeclTemplate.h:616
clang::TypeAliasTemplateDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:2612
clang::RedeclarableTemplateDecl::SpecEntryTraits< FunctionTemplateSpecializationInfo >::getTemplateArgs
static ArrayRef< TemplateArgument > getTemplateArgs(FunctionTemplateSpecializationInfo *I)
Definition: DeclTemplate.h:985
clang::ClassTemplateDecl::ClassTemplateDecl
ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:2305
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:563
clang::TagTypeKind
TagTypeKind
The kind of a tag type.
Definition: Type.h:5562
clang::FunctionTemplateDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:1144
clang::ClassTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:495
clang::RedeclarableTemplateDecl::SpecIterator::operator->
DeclType * operator->() const
Definition: DeclTemplate.h:814
clang::VarTemplateDecl::getPreviousDecl
const VarTemplateDecl * getPreviousDecl() const
Definition: DeclTemplate.h:3197
clang::Decl::getKind
Kind getKind() const
Definition: DeclBase.h:435
clang::TypeAliasTemplateDecl::getPreviousDecl
TypeAliasTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:2586
clang::VarTemplateDecl::specializations
spec_range specializations() const
Definition: DeclTemplate.h:3247
Id
int Id
Definition: ASTDiff.cpp:191
clang::NonTypeTemplateParmDecl::getNumExpansionTypes
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
Definition: DeclTemplate.h:1566
clang::FunctionTemplateDecl::spec_range
llvm::iterator_range< spec_iterator > spec_range
Definition: DeclTemplate.h:1096
clang::VarTemplateDecl::getPartialSpecializations
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
Definition: DeclTemplate.cpp:1220
DeclBase.h
clang::RedeclarableTemplateDecl::redecl_iterator
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclTemplate.h:959
clang::ConceptDecl
Declaration of a C++2a concept.
Definition: DeclTemplate.h:3265
clang::ClassTemplateSpecializationDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:2096
clang::ClassTemplateDecl::Common::Common
Common()=default
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:220
clang::FunctionTemplateSpecializationInfo::TrailingObjects
friend TrailingObjects
Definition: DeclTemplate.h:526
clang::NonTypeTemplateParmDecl::CreateDeserialized
static NonTypeTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID, bool HasTypeConstraint)
Definition: DeclTemplate.cpp:769
clang::TemplateDecl::TemplateParams
TemplateParameterList * TemplateParams
Definition: DeclTemplate.h:460
clang::FunctionTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:1022
clang::ClassScopeFunctionSpecializationDecl::getTemplateArgsAsWritten
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: DeclTemplate.h:2654
clang::RedeclarableTemplateDecl::RedeclarableTemplateDecl
RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:865
clang::FunctionTemplateDecl::Common
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:997
clang::FunctionDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition: Decl.h:2178
Redeclarable.h
clang::TemplateTemplateParmDecl::getExpansionTemplateParameters
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
Definition: DeclTemplate.h:1739
clang::TemplateDecl::TemplateDecl
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params)
Definition: DeclTemplate.h:419
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::ClassTemplatePartialSpecializationDecl::getInjectedSpecializationType
QualType getInjectedSpecializationType() const
Retrieves the injected specialization type for this partial specialization.
Definition: DeclTemplate.h:2253
clang::TemplateParameterList::TemplateParameterList
TemplateParameterList(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Definition: DeclTemplate.cpp:48
clang::FriendTemplateDecl::FriendUnion
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
Definition: DeclTemplate.h:2477
clang::VarTemplatePartialSpecializationDecl::getTemplateArgsAsWritten
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
Definition: DeclTemplate.h:3012
clang::ClassScopeFunctionSpecializationDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:2673
clang::ClassTemplateSpecializationDecl::CreateDeserialized
static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:959
clang::ClassTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:478
clang::FunctionTemplateDecl::getCanonicalDecl
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:1061
clang::ClassTemplateDecl::getPreviousDecl
ClassTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this class template, or nullptr if no such declaration exists.
Definition: DeclTemplate.h:2364
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7431
clang::VarTemplatePartialSpecializationDecl::setMemberSpecialization
void setMemberSpecialization()
Note that this member template is a specialization.
Definition: DeclTemplate.h:3085
clang::FunctionTemplateDecl::spec_end
spec_iterator spec_end() const
Definition: DeclTemplate.h:1106
clang::VarTemplateDecl::getDefinition
VarTemplateDecl * getDefinition()
Definition: DeclTemplate.cpp:1182
clang::VarTemplateDecl::Common::PartialSpecializations
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > PartialSpecializations
The variable template partial specializations for this variable template.
Definition: DeclTemplate.h:3121
clang::TemplateParameterList::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.cpp:201
clang::ConceptDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.h:3284
clang::VarTemplateDecl::LoadLazySpecializations
void LoadLazySpecializations() const
Load any lazily-loaded specializations from the external source.
Definition: DeclTemplate.cpp:1209
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:61
clang::FunctionTemplateDecl::specializations
spec_range specializations() const
Definition: DeclTemplate.h:1098
clang::MemberSpecializationInfo::setTemplateSpecializationKind
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
Definition: DeclTemplate.h:663
clang::TagDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition: Decl.h:3496
clang::TemplateParamObjectDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID)
Definition: DeclTemplate.h:3364
clang::ConceptDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:3302
clang::RISCV::Policy
Policy
Definition: RISCVVIntrinsicUtils.h:94
clang::ClassTemplateDecl::getMostRecentDecl
const ClassTemplateDecl * getMostRecentDecl() const
Definition: DeclTemplate.h:2378
clang::FriendTemplateDecl::getTemplateParameterList
TemplateParameterList * getTemplateParameterList(unsigned i) const
Definition: DeclTemplate.h:2529
clang::ClassTemplateDecl::specializations
spec_range specializations() const
Definition: DeclTemplate.h:2443
clang::ClassTemplateDecl::findPartialSpecInstantiatedFromMember
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
Definition: DeclTemplate.cpp:602
clang::Stmt::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:348
clang::Mergeable< TemplateParamObjectDecl >::getFirstDecl
TemplateParamObjectDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:320
clang::ClassTemplateSpecializationDecl::setPointOfInstantiation
void setPointOfInstantiation(SourceLocation Loc)
Definition: DeclTemplate.h:1973
clang::NonTypeTemplateParmDecl::setPlaceholderTypeConstraint
void setPlaceholderTypeConstraint(Expr *E)
Definition: DeclTemplate.h:1596
clang::TemplateArgumentLoc::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Definition: TemplateBase.cpp:491
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:457
Type.h
clang::VarTemplateSpecializationDecl::getTemplateArgsInfo
const ASTTemplateArgumentListInfo * getTemplateArgsInfo() const
Definition: DeclTemplate.h:2790
clang::ConceptDecl::Create
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
Definition: DeclTemplate.cpp:1035
clang::FriendTemplateDecl::getFriendDecl
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type),...
Definition: DeclTemplate.h:2520
clang::TemplateTemplateParmDecl
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Definition: DeclTemplate.h:1630
clang::RedeclarableTemplateDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:969
clang::Redeclarable< RedeclarableTemplateDecl >::redecls
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:296
clang::TemplateParmPosition::MaxPosition
static constexpr unsigned MaxPosition
Definition: DeclTemplate.h:1168
ASTContext.h
clang::getPrimaryMergedDecl
Decl * getPrimaryMergedDecl(Decl *D)
Get the primary declaration for a declaration from an AST file.
Definition: Decl.cpp:78
clang::FunctionTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:378
clang::TemplateTemplateParmDecl::getNumExpansionTemplateParameters
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
Definition: DeclTemplate.h:1732
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:879
clang::VarTemplateSpecializationDecl::setInstantiationOf
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this variable template specialization is actually an instantiation of the given variable te...
Definition: DeclTemplate.h:2879
clang::ClassTemplateSpecializationDecl::setInstantiationOf
void setInstantiationOf(ClassTemplateDecl *TemplDecl)
Note that this class template specialization is an instantiation of the given class template.
Definition: DeclTemplate.h:2038
clang::NonTypeTemplateParmDecl::Create
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Definition: DeclTemplate.cpp:739
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:70
clang::NonTypeTemplateParmDecl::setInheritedDefaultArgument
void setInheritedDefaultArgument(const ASTContext &C, NonTypeTemplateParmDecl *Parm)
Definition: DeclTemplate.h:1510
clang::TemplateDecl::setTemplateParameters
void setTemplateParameters(TemplateParameterList *TParams)
Definition: DeclTemplate.h:462
clang::RedeclarableTemplateDecl::getCanonicalDecl
RedeclarableTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:877
clang::TypeDecl
Represents a declaration of a type.
Definition: Decl.h:3206
clang::RedeclarableTemplateDecl::SpecIterator::SpecIterator
SpecIterator()=default
clang::MemberSpecializationInfo::MemberSpecializationInfo
MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, SourceLocation POI=SourceLocation())
Definition: DeclTemplate.h:642
clang::TemplateArgumentList::operator[]
const TemplateArgument & operator[](unsigned Idx) const
Retrieve the template argument at a given index.
Definition: DeclTemplate.h:289
clang::FunctionTemplateSpecializationInfo::Profile
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
Definition: DeclTemplate.h:621
clang::TemplateTemplateParmDecl::Create
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
Definition: DeclTemplate.cpp:826
clang::DependentFunctionTemplateSpecializationInfo::getNumTemplates
unsigned getNumTemplates() const
Returns the number of function templates that this might be a specialization of.
Definition: DeclTemplate.h:729
clang::TypeAliasTemplateDecl::getCanonicalDecl
const TypeAliasTemplateDecl * getCanonicalDecl() const
Definition: DeclTemplate.h:2579
clang::TemplateTypeParmDecl::setInheritedDefaultArgument
void setInheritedDefaultArgument(const ASTContext &C, TemplateTypeParmDecl *Prev)
Set that this default argument was inherited from another parameter.
Definition: DeclTemplate.h:1306
clang::getExpandedPackSize
Optional< unsigned > getExpandedPackSize(const NamedDecl *Param)
Check whether the template parameter is a pack expansion, and if so, determine the number of paramete...
Definition: DeclTemplate.h:3408
clang::TemplateParmPosition::DepthWidth
@ DepthWidth
Definition: DeclTemplate.h:1163
clang::FunctionTemplateSpecializationInfo::Create
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
Definition: DeclTemplate.cpp:892
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::Redeclarable< RedeclarableTemplateDecl >::getPreviousDecl
RedeclarableTemplateDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:204
clang::VarTemplateSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:2935
clang::FriendTemplateDecl::CreateDeserialized
static FriendTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1132
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:2015
clang::TemplateTemplateParmDecl::isPackExpansion
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
Definition: DeclTemplate.h:1705
clang::RedeclarableTemplateDecl::RedeclarableTemplate
friend class RedeclarableTemplate
Definition: DeclTemplate.h:874
clang::Redeclarable< RedeclarableTemplateDecl >::isFirstDecl
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:223
ASTConcept.h
This file provides AST data structures related to concepts.
clang::TemplateTemplateParmDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.h:1778
clang::TemplateParamObjectDecl::getCanonicalDecl
const TemplateParamObjectDecl * getCanonicalDecl() const
Definition: DeclTemplate.h:3371
clang::DefaultArgStorage::set
void set(ArgType Arg)
Set the default argument.
Definition: DeclTemplate.h:370
clang::VarTemplateSpecializationDecl::Create
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
Definition: DeclTemplate.cpp:1317
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1208
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:1996
clang::TemplateParameterList::getTemplateLoc
SourceLocation getTemplateLoc() const
Definition: DeclTemplate.h:194
clang::TemplateTemplateParmDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:1787
clang::TemplateParmPosition::setPosition
void setPosition(unsigned P)
Definition: DeclTemplate.h:1192
clang::TemplateParamObjectDecl
A template parameter object.
Definition: DeclTemplate.h:3321
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:576
clang::MemberSpecializationInfo::getPointOfInstantiation
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
Definition: DeclTemplate.h:672
clang::FunctionTemplateDecl::isAbbreviated
bool isAbbreviated() const
Return whether this function template is an abbreviated function template, e.g.
Definition: DeclTemplate.h:1121
clang::ClassTemplateDecl::findSpecialization
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
Definition: DeclTemplate.cpp:502
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:428
clang::ClassTemplateDecl::AddSpecialization
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:507
clang::FriendTemplateDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:2539
clang::TemplateParameterList::getRAngleLoc
SourceLocation getRAngleLoc() const
Definition: DeclTemplate.h:196
clang::TemplateArgumentList::asArray
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Definition: DeclTemplate.h:292
clang::ClassTemplateSpecializationDecl::getTypeAsWritten
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
Definition: DeclTemplate.h:2054
clang::VarTemplateDecl::getMostRecentDecl
VarTemplateDecl * getMostRecentDecl()
Definition: DeclTemplate.h:3203
clang::TemplateTypeParmDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:1404
clang::VarTemplateSpecializationDecl::getPointOfInstantiation
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
Definition: DeclTemplate.h:2822
clang::ClassTemplateSpecializationDecl::isExplicitSpecialization
bool isExplicitSpecialization() const
Definition: DeclTemplate.h:1934
clang::TemplateParamObjectDecl::printAsExpr
void printAsExpr(llvm::raw_ostream &OS) const
Print this object as an equivalent expression.
Definition: DeclTemplate.cpp:1541
clang::RedeclarableTemplateDecl::loadLazySpecializationsImpl
void loadLazySpecializationsImpl() const
Definition: DeclTemplate.cpp:301
clang::VarTemplateDecl::getSpecializations
llvm::FoldingSetVector< VarTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this variable template.
Definition: DeclTemplate.cpp:1214
clang::VarTemplateDecl::Common
Data that is common to all of the declarations of a given variable template.
Definition: DeclTemplate.h:3113
clang::RedeclarableTemplateDecl::CommonBase::CommonBase
CommonBase()
Definition: DeclTemplate.h:835
clang::VarTemplateDecl::getCanonicalDecl
VarTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:3184
clang::TemplateTypeParmDecl::wasDeclaredWithTypename
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
Definition: DeclTemplate.h:1270
clang::RedeclarableTemplateDecl::SpecEntryTraits::getDecl
static DeclType * getDecl(EntryType *D)
Definition: DeclTemplate.h:787
clang::FunctionTemplateSpecializationInfo::isExplicitSpecialization
bool isExplicitSpecialization() const
Definition: DeclTemplate.h:546
clang::FriendTemplateDecl::getFriendType
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type),...
Definition: DeclTemplate.h:2513
clang::Decl::getSourceRange
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Definition: DeclBase.h:420
clang::FunctionTemplateSpecializationInfo::getFunction
FunctionDecl * getFunction() const
Retrieve the declaration of the function template specialization.
Definition: DeclTemplate.h:536
clang::ConceptDecl::ConstraintExpr
Expr * ConstraintExpr
Definition: DeclTemplate.h:3267
clang::TemplateTemplateParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Definition: DeclTemplate.h:1761
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::Mergeable
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
Definition: Redeclarable.h:314
clang::Redeclarable< TagDecl >::First
TagDecl * First
Definition: Redeclarable.h:187
clang::ClassTemplateSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:2084
SourceLocation.h
clang::VarDecl::isThisDeclarationADefinition
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
Definition: Decl.cpp:2169
clang::VarTemplateDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:3260
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::MemberSpecializationInfo::isExplicitSpecialization
bool isExplicitSpecialization() const
Definition: DeclTemplate.h:658
clang::TemplateTemplateParmDecl::setInheritedDefaultArgument
void setInheritedDefaultArgument(const ASTContext &C, TemplateTemplateParmDecl *Prev)
Definition: DeclTemplate.h:1770
clang::TemplateSpecializationKind
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:176
clang::ClassTemplatePartialSpecializationDecl::getTemplateArgsAsWritten
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
Definition: DeclTemplate.h:2180
clang::RedeclarableTemplateDecl::getCanonicalDecl
const RedeclarableTemplateDecl * getCanonicalDecl() const
Definition: DeclTemplate.h:880
clang::Type::getContainedAutoType
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.h:2403
clang::FunctionTemplateSpecializationInfo
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:480
clang::NonTypeTemplateParmDecl::getExpansionTypeSourceInfo
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
Definition: DeclTemplate.h:1582
clang::FunctionTemplateDecl::Common::Common
Common()=default
clang::TemplateParameterList::end
iterator end()
Definition: DeclTemplate.h:127
clang::NonTypeTemplateParmDecl::getDefaultArgument
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1495
clang::TemplateTypeParmDecl::getTypeConstraint
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
Definition: DeclTemplate.h:1375
clang::getAsNamedDecl
NamedDecl * getAsNamedDecl(TemplateParameter P)
Definition: DeclTemplate.h:3379
false
#define false
Definition: stdbool.h:22
clang::FunctionTemplateDecl::addSpecialization
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
Definition: DeclTemplate.cpp:400
clang::TemplateTemplateParmDecl::TrailingObjects
friend TrailingObjects
Definition: DeclTemplate.h:1667
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2276
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:674
clang::ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
Definition: DeclTemplate.cpp:913
clang::VarTemplateDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
Definition: DeclTemplate.h:3160
clang::ClassTemplateSpecializationDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:2098
clang::TemplateTypeParmDecl::setDeclaredWithTypename
void setDeclaredWithTypename(bool withTypename)
Set whether this template type parameter was declared with the 'typename' or 'class' keyword.
Definition: DeclTemplate.h:1318
clang::DependentFunctionTemplateSpecializationInfo::getRAngleLoc
SourceLocation getRAngleLoc() const
Definition: DeclTemplate.h:759
clang::ClassTemplateDecl::findPartialSpecialization
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
Definition: DeclTemplate.cpp:513
clang::VarTemplateSpecializationDecl::isExplicitSpecialization
bool isExplicitSpecialization() const
Definition: DeclTemplate.h:2800
clang::VarTemplateSpecializationDecl::CreateDeserialized
static VarTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1327
clang::TemplateParameterList::begin
const_iterator begin() const
Definition: DeclTemplate.h:126
clang::ClassTemplateSpecializationDecl::Profile
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
Definition: DeclTemplate.h:2089
clang::NonTypeTemplateParmDecl::removeDefaultArgument
void removeDefaultArgument()
Removes the default argument of this template parameter.
Definition: DeclTemplate.h:1516
clang::RedeclarableTemplateDecl::CommonBase::LazySpecializations
uint32_t * LazySpecializations
If non-null, points to an array of specializations (including partial specializations) known only by ...
Definition: DeclTemplate.h:850
clang::Redeclarable< RedeclarableTemplateDecl >::getNextRedeclaration
RedeclarableTemplateDecl * getNextRedeclaration() const
Definition: Redeclarable.h:189
clang::ClassTemplateSpecializationDecl::setExternLoc
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
Definition: DeclTemplate.h:2064
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:409
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:1562
clang::BuiltinTemplateDecl::getBuiltinTemplateKind
BuiltinTemplateKind getBuiltinTemplateKind() const
Definition: DeclTemplate.h:1816
clang::VarTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2955
clang::FunctionTemplateSpecializationInfo::setPointOfInstantiation
void setPointOfInstantiation(SourceLocation POI)
Set the (first) point of instantiation of this function template specialization.
Definition: DeclTemplate.h:576
clang::TemplateArgumentList::OnStackType
OnStackType
Type used to indicate that the template argument list itself is a stack object.
Definition: DeclTemplate.h:259
clang::TemplateParmPosition::Depth
unsigned Depth
Definition: DeclTemplate.h:1164
clang::RedeclarableTemplateDecl::SpecIterator::SpecIterator
SpecIterator(typename llvm::FoldingSetVector< EntryType >::iterator SetIter)
Definition: DeclTemplate.h:806
llvm::ArrayRef
Definition: LLVM.h:34
clang::RedeclarableTemplateDecl::getCommonPtr
CommonBase * getCommonPtr() const
Retrieves the "common" pointer shared by all (re-)declarations of the same template.
Definition: DeclTemplate.cpp:269
Value
Value
Definition: UninitializedValues.cpp:102
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::BuiltinTemplateDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:1804
clang::DeclaratorDecl
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:731
clang::ClassTemplatePartialSpecializationDecl::CreateDeserialized
static ClassTemplatePartialSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1105
clang::VarTemplatePartialSpecializationDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:3103
clang::VarTemplateDecl::AddSpecialization
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:1238
clang::FixedSizeTemplateParameterListStorage
Stores a list of template parameters and the associated requires-clause (if any) for a TemplateDecl a...
Definition: DeclTemplate.h:216
clang::ClassTemplatePartialSpecializationDecl::setMemberSpecialization
void setMemberSpecialization()
Note that this member template is a specialization.
Definition: DeclTemplate.h:2243
clang::ClassScopeFunctionSpecializationDecl::getSpecialization
CXXMethodDecl * getSpecialization() const
Definition: DeclTemplate.h:2652
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
clang::VarDecl::getTemplateSpecializationKind
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Definition: Decl.cpp:2655
clang::TypeAliasTemplateDecl::Create
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
Definition: DeclTemplate.cpp:1142
LLVM.h
clang::VarTemplateSpecializationDecl::setExternLoc
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
Definition: DeclTemplate.h:2917
clang::VarTemplateSpecializationDecl::setTypeAsWritten
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
Definition: DeclTemplate.h:2899
clang::VarTemplateSpecializationDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:2947
clang::ClassTemplateDecl::getCanonicalDecl
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Definition: DeclTemplate.h:2353
clang::ClassTemplateDecl::getTemplatedDecl
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
Definition: DeclTemplate.h:2324
clang::TSK_ExplicitSpecialization
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
Definition: Specifiers.h:186
clang::DependentFunctionTemplateSpecializationInfo::getTemplate
FunctionTemplateDecl * getTemplate(unsigned I) const
Returns the i'th template candidate.
Definition: DeclTemplate.h:732
clang::ValueDecl::ValueDecl
ValueDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T)
Definition: Decl.h:680
clang::TemplateParamObjectDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:3376
clang::VarTemplatePartialSpecializationDecl::Create
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
Definition: DeclTemplate.cpp:1391
clang::TemplateTypeParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
Definition: DeclTemplate.cpp:673
clang::VarTemplateSpecializationDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:2949
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:238
clang::Redeclarable< RedeclarableTemplateDecl >::getMostRecentDecl
RedeclarableTemplateDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:226
clang::RedeclarableTemplateDecl::SpecIterator
Definition: DeclTemplate.h:798
clang::TemplateParameterList::size
unsigned size() const
Definition: DeclTemplate.h:130
clang::VarTemplateSpecializationDecl::getExternLoc
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
Definition: DeclTemplate.h:2912
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::VarTemplateSpecializationDecl::setCompleteDefinition
void setCompleteDefinition()
Definition: DeclTemplate.h:2831
clang::ClassScopeFunctionSpecializationDecl::CreateDeserialized
static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID)
Definition: DeclTemplate.cpp:1172
clang::TemplateParameterList::asArray
ArrayRef< NamedDecl * > asArray()
Definition: DeclTemplate.h:132
clang::ConceptDecl::ConceptDecl
ConceptDecl(DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr)
Definition: DeclTemplate.h:3269
clang::ClassTemplatePartialSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:2259
clang::RedeclarableTemplateDecl::addSpecializationImpl
void addSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, EntryType *Entry, void *InsertPos)
Definition: DeclTemplate.cpp:329
clang::MemberSpecializationInfo::getInstantiatedFrom
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Definition: DeclTemplate.h:651
clang::TemplateParameterList::getDepth
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
Definition: DeclTemplate.cpp:156
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:2849
clang::TemplateTypeParmDecl::isParameterPack
bool isParameterPack() const
Returns whether this is a parameter pack.
Definition: DeclTemplate.cpp:699
clang::TemplateArgumentList::OnStack
@ OnStack
Definition: DeclTemplate.h:259
clang::TemplateTypeParmDecl::getDefaultArgStorage
const DefArgStorage & getDefaultArgStorage() const
Definition: DeclTemplate.h:1274
clang::CXXRecordDecl::getMostRecentNonInjectedDecl
CXXRecordDecl * getMostRecentNonInjectedDecl()
Definition: DeclCXX.h:528
clang::TemplateParameterList::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Definition: DeclTemplate.h:198
clang::VarTemplateSpecializationDecl::setInstantiationOf
void setInstantiationOf(VarTemplateDecl *TemplDecl)
Note that this variable template specialization is an instantiation of the given variable template.
Definition: DeclTemplate.h:2891
clang::TypeAliasTemplateDecl::getCommonPtr
Common * getCommonPtr()
Definition: DeclTemplate.h:2561
clang::FunctionTemplateDecl::getTemplatedDecl
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Definition: DeclTemplate.h:1046
clang::TemplateTypeParmDecl::isPackExpansion
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
Definition: DeclTemplate.h:1333
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:341
clang::ConceptDecl::isTypeConcept
bool isTypeConcept() const
Definition: DeclTemplate.h:3289
clang::TemplateParmPosition::MaxDepth
static constexpr unsigned MaxDepth
Definition: DeclTemplate.h:1167
std
Definition: Format.h:4321
clang::DefaultArgStorage
Storage for a default argument.
Definition: DeclTemplate.h:315
clang::TemplateTypeParmDecl::Create
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, Optional< unsigned > NumExpanded=None)
Definition: DeclTemplate.cpp:641
clang::FunctionTemplateDecl::getPreviousDecl
const FunctionTemplateDecl * getPreviousDecl() const
Definition: DeclTemplate.h:1076
DeclarationName.h
clang::ClassTemplateDecl::getPreviousDecl
const ClassTemplateDecl * getPreviousDecl() const
Definition: DeclTemplate.h:2368
clang::VarTemplatePartialSpecializationDecl::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: DeclTemplate.h:3092
clang::RedeclarableTemplateDecl::Common
CommonBase * Common
Pointer to the common data shared by all declarations of this template.
Definition: DeclTemplate.h:855
clang::TypeAliasTemplateDecl::getPreviousDecl
const TypeAliasTemplateDecl * getPreviousDecl() const
Definition: DeclTemplate.h:2590
clang::ClassTemplateSpecializationDecl::getNameForDiagnostic
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
Definition: DeclTemplate.cpp:967
clang::FunctionTemplateDecl::getPreviousDecl
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
Definition: DeclTemplate.h:1072
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::ClassTemplateSpecializationDecl::getInstantiatedFrom
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
Definition: DeclTemplate.h:1984
clang::TemplateTemplateParmDecl::getDefaultArgument
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1751
clang::TemplateTypeParmDecl::getAssociatedConstraints
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the associated-constraints of this template parameter.
Definition: DeclTemplate.h:1396
clang::ClassTemplatePartialSpecializationDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:2268
clang::FunctionTemplateDecl::FunctionTemplateDecl
FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:1014
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:1836
clang::ClassTemplateDecl::Create
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
Definition: DeclTemplate.cpp:460
clang::ClassTemplateDecl::getMostRecentDecl
ClassTemplateDecl * getMostRecentDecl()
Definition: DeclTemplate.h:2374
clang
Definition: CalledOnceCheck.h:17
clang::VarTemplateSpecializationDecl::isClassScopeExplicitSpecialization
bool isClassScopeExplicitSpecialization() const
Definition: DeclTemplate.h:2804
clang::TemplateTypeParmDecl::getNumExpansionParameters
unsigned getNumExpansionParameters() const
Retrieves the number of parameters in an expanded parameter pack.
Definition: DeclTemplate.h:1368
clang::VarTemplatePartialSpecializationDecl::getMostRecentDecl
VarTemplatePartialSpecializationDecl * getMostRecentDecl()
Definition: DeclTemplate.h:3000
clang::VarTemplatePartialSpecializationDecl::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.h:3026
clang::TemplateTemplateParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
Definition: DeclTemplate.cpp:862
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:1947
clang::FunctionTemplateDecl::getInstantiatedFromMemberTemplate
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
Definition: DeclTemplate.h:1090
clang::ConceptDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:3301
clang::NonTypeTemplateParmDecl::isParameterPack
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
Definition: DeclTemplate.h:1527
clang::ClassTemplateSpecializationDecl::setSpecializationKind
void setSpecializationKind(TemplateSpecializationKind TSK)
Definition: DeclTemplate.h:1964
clang::DefaultArgStorage::isInherited
bool isInherited() const
Determine whether the default argument for this parameter was inherited from a previous declaration o...
Definition: DeclTemplate.h:346
clang::FunctionTemplateDecl::getSpecializations
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > & getSpecializations() const
Retrieve the set of function template specializations of this function template.
Definition: DeclTemplate.cpp:389
clang::TemplateDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.h:453
clang::ClassTemplateDecl::Common::Specializations
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > Specializations
The class template specializations for this class template, including explicit specializations and in...
Definition: DeclTemplate.h:2283
clang::ClassTemplatePartialSpecializationDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:2270
clang::RedeclarableTemplateDecl::findSpecializationImpl
SpecEntryTraits< EntryType >::DeclType * findSpecializationImpl(llvm::FoldingSetVector< EntryType > &Specs, void *&InsertPos, ProfileArguments &&...ProfileArgs)
Definition: DeclTemplate.cpp:316
clang::FunctionTemplateDecl::getCanonicalDecl
const FunctionTemplateDecl * getCanonicalDecl() const
Definition: DeclTemplate.h:1065
clang::TemplateTemplateParmDecl::isExpandedParameterPack
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
Definition: DeclTemplate.h:1728
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::ClassTemplatePartialSpecializationDecl::getAssociatedConstraints
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
Definition: DeclTemplate.h:2171
clang::VarTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:1226
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6646
clang::TemplateParmPosition
Defines the position of a template parameter within a template parameter list.
Definition: DeclTemplate.h:1161
clang::TemplateTemplateParmDecl::removeDefaultArgument
void removeDefaultArgument()
Removes the default argument of this template parameter.
Definition: DeclTemplate.h:1776
clang::TemplateParameterList::begin
iterator begin()
Definition: DeclTemplate.h:125
clang::ClassTemplateDecl::getCommonPtr
Common * getCommonPtr() const
Definition: DeclTemplate.h:2312
clang::ClassTemplatePartialSpecializationDecl::isMemberSpecialization
bool isMemberSpecialization()
Determines whether this class template partial specialization template was a specialization of a memb...
Definition: DeclTemplate.h:2236
clang::RedeclarableTemplateDecl::getInstantiatedFromMemberTemplate
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or nullptr if this template w...
Definition: DeclTemplate.h:949
clang::RedeclarableTemplateDecl::CommonBase::InstantiatedFromMember
llvm::PointerIntPair< RedeclarableTemplateDecl *, 1, bool > InstantiatedFromMember
The template from which this was most directly instantiated (or null).
Definition: DeclTemplate.h:843
clang::TemplateParameterList::const_iterator
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Definition: DeclTemplate.h:123
clang::TemplateParameterList::shouldIncludeTypeForArgument
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
Definition: DeclTemplate.cpp:205
clang::TemplateParamObjectDecl::getCanonicalDecl
TemplateParamObjectDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclTemplate.h:3368
clang::TemplateTypeParmDecl::removeDefaultArgument
void removeDefaultArgument()
Removes the default argument of this template parameter.
Definition: DeclTemplate.h:1312
clang::Decl::DeclContext
friend class DeclContext
Definition: DeclBase.h:249
clang::NonTypeTemplateParmDecl::getPlaceholderTypeConstraint
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
Definition: DeclTemplate.h:1591
clang::ClassTemplateSpecializationDecl::getTemplateKeywordLoc
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
Definition: DeclTemplate.h:2078
clang::ASTTemplateArgumentListInfo::Create
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
Definition: TemplateBase.cpp:602
clang::ClassTemplateDecl::getSpecializations
llvm::FoldingSetVector< ClassTemplateSpecializationDecl > & getSpecializations() const
Retrieve the set of specializations of this class template.
Definition: DeclTemplate.cpp:483
clang::BuiltinTemplateDecl
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
Definition: DeclTemplate.h:1793
clang::RedeclarableTemplateDecl::SpecEntryTraits::DeclType
EntryType DeclType
Definition: DeclTemplate.h:785
clang::VarTemplateSpecializationDecl::getSpecializedTemplate
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Definition: DeclTemplate.cpp:1350
clang::TemplateParameterList::hasParameterPack
bool hasParameterPack() const
Determine whether this template parameter list contains a parameter pack.
Definition: DeclTemplate.h:167
clang::FunctionTemplateDecl::Common::Specializations
llvm::FoldingSetVector< FunctionTemplateSpecializationInfo > Specializations
The function template specializations for this function template, including explicit specializations ...
Definition: DeclTemplate.h:1000
clang::TemplateParamObjectDecl::Profile
static void Profile(llvm::FoldingSetNodeID &ID, QualType T, const APValue &V)
Definition: DeclTemplate.h:3359
clang::FunctionTemplateSpecializationInfo::TemplateArgumentsAsWritten
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Definition: DeclTemplate.h:501
clang::TypeAliasTemplateDecl
Declaration of an alias template.
Definition: DeclTemplate.h:2549
clang::TemplateParameterList::getMinRequiredArguments
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
Definition: DeclTemplate.cpp:130
clang::TemplateTemplateParmDecl::CreateDeserialized
static TemplateTemplateParmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:846
clang::TypeAliasTemplateDecl::TypeAliasTemplateDecl
TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Definition: DeclTemplate.h:2553
clang::RedeclarableTemplateDecl::SpecEntryTraits::getTemplateArgs
static ArrayRef< TemplateArgument > getTemplateArgs(EntryType *D)
Definition: DeclTemplate.h:791
clang::ConceptDecl::getCanonicalDecl
const ConceptDecl * getCanonicalDecl() const
Definition: DeclTemplate.h:3296
clang::QualType::getAsOpaquePtr
void * getAsOpaquePtr() const
Definition: Type.h:782
clang::TemplateParamObjectDecl::printName
void printName(llvm::raw_ostream &OS) const override
Print this template parameter object in a human-readable format.
Definition: DeclTemplate.cpp:1535
clang::Decl::EmptyShell
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Definition: DeclBase.h:99
clang::FunctionTemplateSpecializationInfo::isExplicitInstantiationOrSpecialization
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
Definition: DeclTemplate.h:553
clang::FunctionTemplateSpecializationInfo::getTemplateSpecializationKind
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:542
clang::VarTemplateDecl::spec_begin
spec_iterator spec_begin() const
Definition: DeclTemplate.h:3251
clang::ClassTemplateSpecializationDecl::isExplicitInstantiationOrSpecialization
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
Definition: DeclTemplate.h:1955
clang::FunctionTemplateDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:1145
clang::ClassTemplateDecl::getInjectedClassNameSpecialization
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template.
Definition: DeclTemplate.cpp:614
clang::FunctionTemplateDecl::getMostRecentDecl
FunctionTemplateDecl * getMostRecentDecl()
Definition: DeclTemplate.h:1081
clang::APValue
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
clang::ConceptDecl::CreateDeserialized
static ConceptDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclTemplate.cpp:1046
clang::isTemplateInstantiation
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:200
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:612
clang::DependentFunctionTemplateSpecializationInfo::getLAngleLoc
SourceLocation getLAngleLoc() const
Definition: DeclTemplate.h:755
clang::DefaultArgStorage::getInheritedFrom
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
Definition: DeclTemplate.h:361
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::TemplateParameterList::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Determine whether this template parameter list contains an unexpanded parameter pack.
Definition: DeclTemplate.cpp:94
clang::TypeAliasDecl
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3370
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:685
true
#define true
Definition: stdbool.h:21
clang::MemberSpecializationInfo::getTemplateSpecializationKind
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:654
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3109
clang::RedeclarableTemplateDecl::isMemberSpecialization
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Definition: DeclTemplate.h:902
clang::NonTypeTemplateParmDecl::setDefaultArgument
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Definition: DeclTemplate.h:1509
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::ASTDeclReader
Definition: ASTReaderDecl.cpp:81
clang::NonTypeTemplateParmDecl::getDefaultArgumentLoc
SourceLocation getDefaultArgumentLoc() const
Retrieve the location of the default argument, if any.
Definition: DeclTemplate.cpp:801
clang::TemplateParamObjectDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:3375
clang::FunctionTemplateDecl::CreateDeserialized
static FunctionTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty function template node.
Definition: DeclTemplate.cpp:371
clang::TemplateParamObjectDecl::getValue
const APValue & getValue() const
Definition: DeclTemplate.h:3357
clang::TypeAliasTemplateDecl::newCommon
CommonBase * newCommon(ASTContext &C) const override
Definition: DeclTemplate.cpp:1159
clang::ClassTemplateDecl::getCanonicalDecl
const ClassTemplateDecl * getCanonicalDecl() const
Definition: DeclTemplate.h:2357
clang::FriendTemplateDecl::getNumTemplateParameters
unsigned getNumTemplateParameters() const
Definition: DeclTemplate.h:2534
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:767
clang::ClassScopeFunctionSpecializationDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:2675
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1832
clang::BuiltinTemplateDecl::classof
static bool classof(const Decl *D)
Definition: DeclTemplate.h:1803
clang::ASTDeclWriter
Definition: ASTWriterDecl.cpp:34
clang::FunctionTemplateDecl::spec_begin
spec_iterator spec_begin() const
Definition: DeclTemplate.h:1102
clang::FunctionTemplateDecl::Common::InjectedArgs
TemplateArgument * InjectedArgs
The set of "injected" template arguments used within this function template.
Definition: DeclTemplate.h:1009
clang::TemplateParmPosition::Position
unsigned Position
Definition: DeclTemplate.h:1165
clang::ClassTemplatePartialSpecializationDecl::setInstantiatedFromMember
void setInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *PartialSpec)
Definition: DeclTemplate.h:2214
clang::ClassTemplatePartialSpecializationDecl::hasAssociatedConstraints
bool hasAssociatedConstraints() const
Definition: DeclTemplate.h:2175
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:432
clang::VarTemplateSpecializationDecl::Profile
static void Profile(llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
Definition: DeclTemplate.h:2939
clang::TemplateDecl::isTypeAlias
bool isTypeAlias() const
Definition: DeclTemplate.cpp:253
clang::ClassTemplateSpecializationDecl::setSpecializedTemplate
void setSpecializedTemplate(ClassTemplateDecl *Specialized)
Definition: DeclTemplate.h:1960
clang::TemplateArgumentList::size
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:298
clang::BuiltinTemplateKind
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition: Builtins.h:285
GCCTypeClass::None
@ None
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1877
clang::TemplateTypeParmDecl::getDepth
unsigned getDepth() const
Retrieve the depth of the template parameter.
Definition: DeclTemplate.cpp:691
clang::TemplateParameter
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Definition: DeclTemplate.h:64
clang::DefaultArgStorage::setInherited
void setInherited(const ASTContext &C, ParmDecl *InheritedFrom)
Set that the default argument was inherited from another parameter.
Definition: DeclTemplate.h:376
clang::MemberSpecializationInfo::setPointOfInstantiation
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
Definition: DeclTemplate.h:677
clang::FunctionTemplateDecl::getInjectedTemplateArgs
ArrayRef< TemplateArgument > getInjectedTemplateArgs()
Retrieve the "injected" template arguments that correspond to the template parameters of this functio...
Definition: DeclTemplate.cpp:406
clang::VarTemplateSpecializationDecl::VarTemplateSpecializationDecl
VarTemplateSpecializationDecl(Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
Definition: DeclTemplate.cpp:1301
clang::TypeConstraint
Definition: ASTConcept.h:169
clang::VarTemplateSpecializationDecl::getSpecializationKind
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
Definition: DeclTemplate.h:2796
clang::VarTemplateDecl::findPartialSpecialization
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
Definition: DeclTemplate.cpp:1244
clang::ClassTemplateDecl::AddPartialSpecialization
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
Definition: DeclTemplate.cpp:563
clang::TemplateParameterList::numTrailingObjects
size_t numTrailingObjects(OverloadToken< Expr * >) const
Definition: DeclTemplate.h:103
clang::ClassScopeFunctionSpecializationDecl::Create
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, const TemplateArgumentListInfo &TemplateArgs)
Definition: DeclTemplate.h:2659
clang::VarTemplateSpecializationDecl::getTypeAsWritten
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
Definition: DeclTemplate.h:2907
clang::NonTypeTemplateParmDecl::getAssociatedConstraints
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr * > &AC) const
Get the associated-constraints of this template parameter.
Definition: DeclTemplate.h:1613
clang::FunctionTemplateSpecializationInfo::PointOfInstantiation
SourceLocation PointOfInstantiation
The point at which this function template specialization was first instantiated.
Definition: DeclTemplate.h:505
clang::FunctionTemplateSpecializationInfo::getMemberSpecializationInfo
MemberSpecializationInfo * getMemberSpecializationInfo() const
Get the specialization info if this function template specialization is also a member specialization:
Definition: DeclTemplate.h:610
clang::TemplateTemplateParmDecl::isParameterPack
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
Definition: DeclTemplate.h:1699
clang::VarTemplateDecl::classofKind
static bool classofKind(Kind K)
Definition: DeclTemplate.h:3261
clang::getAsTypeTemplateDecl
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
Definition: DeclTemplate.h:3387
clang::VarTemplateDecl::CreateDeserialized
static VarTemplateDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create an empty variable template node.
Definition: DeclTemplate.cpp:1203
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1983
clang::VarTemplatePartialSpecializationDecl::setInstantiatedFromMember
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
Definition: DeclTemplate.h:3057
clang::StorageClass
StorageClass
Storage classes.
Definition: Specifiers.h:236