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