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