clang  14.0.0git
TemplateBase.h
Go to the documentation of this file.
1 //===- TemplateBase.h - Core classes for 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 // This file provides definitions which are common for all kinds of
10 // template representation.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_TEMPLATEBASE_H
15 #define LLVM_CLANG_AST_TEMPLATEBASE_H
16 
19 #include "clang/AST/TemplateName.h"
20 #include "clang/AST/Type.h"
21 #include "clang/Basic/LLVM.h"
23 #include "llvm/ADT/APInt.h"
24 #include "llvm/ADT/APSInt.h"
25 #include "llvm/ADT/ArrayRef.h"
26 #include "llvm/ADT/None.h"
27 #include "llvm/ADT/Optional.h"
28 #include "llvm/ADT/SmallVector.h"
29 #include "llvm/Support/Compiler.h"
30 #include "llvm/Support/TrailingObjects.h"
31 #include <cassert>
32 #include <cstddef>
33 #include <cstdint>
34 
35 namespace llvm {
36 
37 class FoldingSetNodeID;
38 
39 // Provide PointerLikeTypeTraits for clang::Expr*, this default one requires a
40 // full definition of Expr, but this file only sees a forward del because of
41 // the dependency.
42 template <> struct PointerLikeTypeTraits<clang::Expr *> {
43  static inline void *getAsVoidPointer(clang::Expr *P) { return P; }
44  static inline clang::Expr *getFromVoidPointer(void *P) {
45  return static_cast<clang::Expr *>(P);
46  }
47  static constexpr int NumLowBitsAvailable = 2;
48 };
49 
50 } // namespace llvm
51 
52 namespace clang {
53 
54 class ASTContext;
55 class DiagnosticBuilder;
56 class Expr;
57 struct PrintingPolicy;
58 class TypeSourceInfo;
59 class ValueDecl;
60 
61 /// Represents a template argument.
63 public:
64  /// The kind of template argument we're storing.
65  enum ArgKind {
66  /// Represents an empty template argument, e.g., one that has not
67  /// been deduced.
68  Null = 0,
69 
70  /// The template argument is a type.
72 
73  /// The template argument is a declaration that was provided for a pointer,
74  /// reference, or pointer to member non-type template parameter.
76 
77  /// The template argument is a null pointer or null pointer to member that
78  /// was provided for a non-type template parameter.
80 
81  /// The template argument is an integral value stored in an llvm::APSInt
82  /// that was provided for an integral non-type template parameter.
84 
85  /// The template argument is a template name that was provided for a
86  /// template template parameter.
88 
89  /// The template argument is a pack expansion of a template name that was
90  /// provided for a template template parameter.
92 
93  /// The template argument is an expression, and we've not resolved it to one
94  /// of the other forms yet, either because it's dependent or because we're
95  /// representing a non-canonical template argument (for instance, in a
96  /// TemplateSpecializationType).
98 
99  /// The template argument is actually a parameter pack. Arguments are stored
100  /// in the Args struct.
102  };
103 
104 private:
105  /// The kind of template argument we're storing.
106 
107  struct DA {
108  unsigned Kind;
109  void *QT;
110  ValueDecl *D;
111  };
112  struct I {
113  unsigned Kind;
114  // We store a decomposed APSInt with the data allocated by ASTContext if
115  // BitWidth > 64. The memory may be shared between multiple
116  // TemplateArgument instances.
117  unsigned BitWidth : 31;
118  unsigned IsUnsigned : 1;
119  union {
120  /// Used to store the <= 64 bits integer value.
121  uint64_t VAL;
122 
123  /// Used to store the >64 bits integer value.
124  const uint64_t *pVal;
125  };
126  void *Type;
127  };
128  struct A {
129  unsigned Kind;
130  unsigned NumArgs;
131  const TemplateArgument *Args;
132  };
133  struct TA {
134  unsigned Kind;
135  unsigned NumExpansions;
136  void *Name;
137  };
138  struct TV {
139  unsigned Kind;
140  uintptr_t V;
141  };
142  union {
143  struct DA DeclArg;
144  struct I Integer;
145  struct A Args;
146  struct TA TemplateArg;
147  struct TV TypeOrValue;
148  };
149 
150 public:
151  /// Construct an empty, invalid template argument.
152  constexpr TemplateArgument() : TypeOrValue({Null, 0}) {}
153 
154  /// Construct a template type argument.
155  TemplateArgument(QualType T, bool isNullPtr = false) {
156  TypeOrValue.Kind = isNullPtr ? NullPtr : Type;
157  TypeOrValue.V = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
158  }
159 
160  /// Construct a template argument that refers to a
161  /// declaration, which is either an external declaration or a
162  /// template declaration.
164  assert(D && "Expected decl");
165  DeclArg.Kind = Declaration;
166  DeclArg.QT = QT.getAsOpaquePtr();
167  DeclArg.D = D;
168  }
169 
170  /// Construct an integral constant template argument. The memory to
171  /// store the value is allocated with Ctx.
173 
174  /// Construct an integral constant template argument with the same
175  /// value as Other but a different type.
177  Integer = Other.Integer;
178  Integer.Type = Type.getAsOpaquePtr();
179  }
180 
181  /// Construct a template argument that is a template.
182  ///
183  /// This form of template argument is generally used for template template
184  /// parameters. However, the template name could be a dependent template
185  /// name that ends up being instantiated to a function template whose address
186  /// is taken.
187  ///
188  /// \param Name The template name.
190  TemplateArg.Kind = Template;
191  TemplateArg.Name = Name.getAsVoidPointer();
192  TemplateArg.NumExpansions = 0;
193  }
194 
195  /// Construct a template argument that is a template pack expansion.
196  ///
197  /// This form of template argument is generally used for template template
198  /// parameters. However, the template name could be a dependent template
199  /// name that ends up being instantiated to a function template whose address
200  /// is taken.
201  ///
202  /// \param Name The template name.
203  ///
204  /// \param NumExpansions The number of expansions that will be generated by
205  /// instantiating
208  TemplateArg.Name = Name.getAsVoidPointer();
209  if (NumExpansions)
210  TemplateArg.NumExpansions = *NumExpansions + 1;
211  else
212  TemplateArg.NumExpansions = 0;
213  }
214 
215  /// Construct a template argument that is an expression.
216  ///
217  /// This form of template argument only occurs in template argument
218  /// lists used for dependent types and for expression; it will not
219  /// occur in a non-dependent, canonical template argument list.
221  TypeOrValue.Kind = Expression;
222  TypeOrValue.V = reinterpret_cast<uintptr_t>(E);
223  }
224 
225  /// Construct a template argument that is a template argument pack.
226  ///
227  /// We assume that storage for the template arguments provided
228  /// outlives the TemplateArgument itself.
230  this->Args.Kind = Pack;
231  this->Args.Args = Args.data();
232  this->Args.NumArgs = Args.size();
233  }
234 
235  TemplateArgument(TemplateName, bool) = delete;
236 
238 
239  /// Create a new template argument pack by copying the given set of
240  /// template arguments.
243 
244  /// Return the kind of stored template argument.
245  ArgKind getKind() const { return (ArgKind)TypeOrValue.Kind; }
246 
247  /// Determine whether this template argument has no value.
248  bool isNull() const { return getKind() == Null; }
249 
250  TemplateArgumentDependence getDependence() const;
251 
252  /// Whether this template argument is dependent on a template
253  /// parameter such that its result can change from one instantiation to
254  /// another.
255  bool isDependent() const;
256 
257  /// Whether this template argument is dependent on a template
258  /// parameter.
259  bool isInstantiationDependent() const;
260 
261  /// Whether this template argument contains an unexpanded
262  /// parameter pack.
263  bool containsUnexpandedParameterPack() const;
264 
265  /// Determine whether this template argument is a pack expansion.
266  bool isPackExpansion() const;
267 
268  /// Retrieve the type for a type template argument.
269  QualType getAsType() const {
270  assert(getKind() == Type && "Unexpected kind");
271  return QualType::getFromOpaquePtr(reinterpret_cast<void*>(TypeOrValue.V));
272  }
273 
274  /// Retrieve the declaration for a declaration non-type
275  /// template argument.
276  ValueDecl *getAsDecl() const {
277  assert(getKind() == Declaration && "Unexpected kind");
278  return DeclArg.D;
279  }
280 
282  assert(getKind() == Declaration && "Unexpected kind");
284  }
285 
286  /// Retrieve the type for null non-type template argument.
288  assert(getKind() == NullPtr && "Unexpected kind");
289  return QualType::getFromOpaquePtr(reinterpret_cast<void*>(TypeOrValue.V));
290  }
291 
292  /// Retrieve the template name for a template name argument.
294  assert(getKind() == Template && "Unexpected kind");
296  }
297 
298  /// Retrieve the template argument as a template name; if the argument
299  /// is a pack expansion, return the pattern as a template name.
301  assert((getKind() == Template || getKind() == TemplateExpansion) &&
302  "Unexpected kind");
303 
305  }
306 
307  /// Retrieve the number of expansions that a template template argument
308  /// expansion will produce, if known.
310 
311  /// Retrieve the template argument as an integral value.
312  // FIXME: Provide a way to read the integral data without copying the value.
314  assert(getKind() == Integral && "Unexpected kind");
315 
316  using namespace llvm;
317 
318  if (Integer.BitWidth <= 64)
319  return APSInt(APInt(Integer.BitWidth, Integer.VAL), Integer.IsUnsigned);
320 
321  unsigned NumWords = APInt::getNumWords(Integer.BitWidth);
322  return APSInt(APInt(Integer.BitWidth, makeArrayRef(Integer.pVal, NumWords)),
323  Integer.IsUnsigned);
324  }
325 
326  /// Retrieve the type of the integral value.
328  assert(getKind() == Integral && "Unexpected kind");
329  return QualType::getFromOpaquePtr(Integer.Type);
330  }
331 
333  assert(getKind() == Integral && "Unexpected kind");
334  Integer.Type = T.getAsOpaquePtr();
335  }
336 
337  /// If this is a non-type template argument, get its type. Otherwise,
338  /// returns a null QualType.
340 
341  /// Retrieve the template argument as an expression.
342  Expr *getAsExpr() const {
343  assert(getKind() == Expression && "Unexpected kind");
344  return reinterpret_cast<Expr *>(TypeOrValue.V);
345  }
346 
347  /// Iterator that traverses the elements of a template argument pack.
349 
350  /// Iterator referencing the first argument of a template argument
351  /// pack.
353  assert(getKind() == Pack);
354  return Args.Args;
355  }
356 
357  /// Iterator referencing one past the last argument of a template
358  /// argument pack.
360  assert(getKind() == Pack);
361  return Args.Args + Args.NumArgs;
362  }
363 
364  /// Iterator range referencing all of the elements of a template
365  /// argument pack.
367  return llvm::makeArrayRef(pack_begin(), pack_end());
368  }
369 
370  /// The number of template arguments in the given template argument
371  /// pack.
372  unsigned pack_size() const {
373  assert(getKind() == Pack);
374  return Args.NumArgs;
375  }
376 
377  /// Return the array of arguments in this template argument pack.
379  assert(getKind() == Pack);
380  return llvm::makeArrayRef(Args.Args, Args.NumArgs);
381  }
382 
383  /// Determines whether two template arguments are superficially the
384  /// same.
385  bool structurallyEquals(const TemplateArgument &Other) const;
386 
387  /// When the template argument is a pack expansion, returns
388  /// the pattern of the pack expansion.
390 
391  /// Print this template argument to the given output stream.
392  void print(const PrintingPolicy &Policy, raw_ostream &Out,
393  bool IncludeType) const;
394 
395  /// Debugging aid that dumps the template argument.
396  void dump(raw_ostream &Out) const;
397 
398  /// Debugging aid that dumps the template argument to standard error.
399  void dump() const;
400 
401  /// Used to insert TemplateArguments into FoldingSets.
402  void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const;
403 };
404 
405 /// Location information for a TemplateArgument.
407 private:
408  struct TemplateTemplateArgLocInfo {
409  // FIXME: We'd like to just use the qualifier in the TemplateName,
410  // but template arguments get canonicalized too quickly.
411  NestedNameSpecifier *Qualifier;
412  void *QualifierLocData;
413  SourceLocation TemplateNameLoc;
414  SourceLocation EllipsisLoc;
415  };
416 
417  llvm::PointerUnion<TemplateTemplateArgLocInfo *, Expr *, TypeSourceInfo *>
418  Pointer;
419 
420  TemplateTemplateArgLocInfo *getTemplate() const {
421  return Pointer.get<TemplateTemplateArgLocInfo *>();
422  }
423 
424 public:
427 
429  // Ctx is used for allocation -- this case is unusually large and also rare,
430  // so we store the payload out-of-line.
432  SourceLocation TemplateNameLoc,
433  SourceLocation EllipsisLoc);
434 
436  return Pointer.get<TypeSourceInfo *>();
437  }
438 
439  Expr *getAsExpr() const { return Pointer.get<Expr *>(); }
440 
442  const auto *Template = getTemplate();
443  return NestedNameSpecifierLoc(Template->Qualifier,
444  Template->QualifierLocData);
445  }
446 
448  return getTemplate()->TemplateNameLoc;
449  }
450 
452  return getTemplate()->EllipsisLoc;
453  }
454 };
455 
456 /// Location wrapper for a TemplateArgument. TemplateArgument is to
457 /// TemplateArgumentLoc as Type is to TypeLoc.
459  TemplateArgument Argument;
460  TemplateArgumentLocInfo LocInfo;
461 
462 public:
464 
467  : Argument(Argument), LocInfo(Opaque) {}
468 
470  : Argument(Argument), LocInfo(TInfo) {
471  assert(Argument.getKind() == TemplateArgument::Type);
472  }
473 
475  : Argument(Argument), LocInfo(E) {
476 
477  // Permit any kind of template argument that can be represented with an
478  // expression.
479  assert(Argument.getKind() == TemplateArgument::NullPtr ||
480  Argument.getKind() == TemplateArgument::Integral ||
481  Argument.getKind() == TemplateArgument::Declaration ||
482  Argument.getKind() == TemplateArgument::Expression);
483  }
484 
486  NestedNameSpecifierLoc QualifierLoc,
487  SourceLocation TemplateNameLoc,
488  SourceLocation EllipsisLoc = SourceLocation())
489  : Argument(Argument),
490  LocInfo(Ctx, QualifierLoc, TemplateNameLoc, EllipsisLoc) {
491  assert(Argument.getKind() == TemplateArgument::Template ||
493  }
494 
495  /// - Fetches the primary location of the argument.
497  if (Argument.getKind() == TemplateArgument::Template ||
499  return getTemplateNameLoc();
500 
501  return getSourceRange().getBegin();
502  }
503 
504  /// - Fetches the full source range of the argument.
505  SourceRange getSourceRange() const LLVM_READONLY;
506 
507  const TemplateArgument &getArgument() const {
508  return Argument;
509  }
510 
512  return LocInfo;
513  }
514 
516  if (Argument.getKind() != TemplateArgument::Type)
517  return nullptr;
518  return LocInfo.getAsTypeSourceInfo();
519  }
520 
522  assert(Argument.getKind() == TemplateArgument::Expression);
523  return LocInfo.getAsExpr();
524  }
525 
527  assert(Argument.getKind() == TemplateArgument::Declaration);
528  return LocInfo.getAsExpr();
529  }
530 
532  assert(Argument.getKind() == TemplateArgument::NullPtr);
533  return LocInfo.getAsExpr();
534  }
535 
537  assert(Argument.getKind() == TemplateArgument::Integral);
538  return LocInfo.getAsExpr();
539  }
540 
542  if (Argument.getKind() != TemplateArgument::Template &&
544  return NestedNameSpecifierLoc();
545  return LocInfo.getTemplateQualifierLoc();
546  }
547 
549  if (Argument.getKind() != TemplateArgument::Template &&
551  return SourceLocation();
552  return LocInfo.getTemplateNameLoc();
553  }
554 
557  return SourceLocation();
558  return LocInfo.getTemplateEllipsisLoc();
559  }
560 };
561 
562 /// A convenient class for passing around template argument
563 /// information. Designed to be passed by reference.
566  SourceLocation LAngleLoc;
567  SourceLocation RAngleLoc;
568 
569 public:
570  TemplateArgumentListInfo() = default;
571 
573  SourceLocation RAngleLoc)
574  : LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {}
575 
576  // This can leak if used in an AST node, use ASTTemplateArgumentListInfo
577  // instead.
578  void *operator new(size_t bytes, ASTContext &C) = delete;
579 
580  SourceLocation getLAngleLoc() const { return LAngleLoc; }
581  SourceLocation getRAngleLoc() const { return RAngleLoc; }
582 
583  void setLAngleLoc(SourceLocation Loc) { LAngleLoc = Loc; }
584  void setRAngleLoc(SourceLocation Loc) { RAngleLoc = Loc; }
585 
586  unsigned size() const { return Arguments.size(); }
587 
589  return Arguments.data();
590  }
591 
593  return Arguments;
594  }
595 
596  const TemplateArgumentLoc &operator[](unsigned I) const {
597  return Arguments[I];
598  }
599 
601  return Arguments[I];
602  }
603 
604  void addArgument(const TemplateArgumentLoc &Loc) {
605  Arguments.push_back(Loc);
606  }
607 };
608 
609 /// Represents an explicit template argument list in C++, e.g.,
610 /// the "<int>" in "sort<int>".
611 /// This is safe to be used inside an AST node, in contrast with
612 /// TemplateArgumentListInfo.
614  : private llvm::TrailingObjects<ASTTemplateArgumentListInfo,
615  TemplateArgumentLoc> {
616 private:
617  friend class ASTNodeImporter;
618  friend TrailingObjects;
619 
621 
622 public:
623  /// The source location of the left angle bracket ('<').
625 
626  /// The source location of the right angle bracket ('>').
628 
629  /// The number of template arguments in TemplateArgs.
630  unsigned NumTemplateArgs;
631 
632  SourceLocation getLAngleLoc() const { return LAngleLoc; }
633  SourceLocation getRAngleLoc() const { return RAngleLoc; }
634 
635  /// Retrieve the template arguments
637  return getTrailingObjects<TemplateArgumentLoc>();
638  }
639  unsigned getNumTemplateArgs() const { return NumTemplateArgs; }
640 
642  return llvm::makeArrayRef(getTemplateArgs(), getNumTemplateArgs());
643  }
644 
645  const TemplateArgumentLoc &operator[](unsigned I) const {
646  return getTemplateArgs()[I];
647  }
648 
649  static const ASTTemplateArgumentListInfo *
650  Create(const ASTContext &C, const TemplateArgumentListInfo &List);
651 };
652 
653 /// Represents an explicit template argument list in C++, e.g.,
654 /// the "<int>" in "sort<int>".
655 ///
656 /// It is intended to be used as a trailing object on AST nodes, and
657 /// as such, doesn't contain the array of TemplateArgumentLoc itself,
658 /// but expects the containing object to also provide storage for
659 /// that.
660 struct alignas(void *) ASTTemplateKWAndArgsInfo {
661  /// The source location of the left angle bracket ('<').
663 
664  /// The source location of the right angle bracket ('>').
666 
667  /// The source location of the template keyword; this is used
668  /// as part of the representation of qualified identifiers, such as
669  /// S<T>::template apply<T>. Will be empty if this expression does
670  /// not have a template keyword.
672 
673  /// The number of template arguments in TemplateArgs.
674  unsigned NumTemplateArgs;
675 
676  void initializeFrom(SourceLocation TemplateKWLoc,
677  const TemplateArgumentListInfo &List,
678  TemplateArgumentLoc *OutArgArray);
679  // FIXME: The parameter Deps is the result populated by this method, the
680  // caller doesn't need it since it is populated by computeDependence. remove
681  // it.
682  void initializeFrom(SourceLocation TemplateKWLoc,
683  const TemplateArgumentListInfo &List,
684  TemplateArgumentLoc *OutArgArray,
685  TemplateArgumentDependence &Deps);
686  void initializeFrom(SourceLocation TemplateKWLoc);
687 
688  void copyInto(const TemplateArgumentLoc *ArgArray,
689  TemplateArgumentListInfo &List) const;
690 };
691 
693  const TemplateArgument &Arg);
694 
697  return getArgs() + getNumArgs();
698 }
699 
702  return getArgs() + getNumArgs();
703 }
704 
705 inline const TemplateArgument &
707  assert(Idx < getNumArgs() && "Template argument out of range");
708  return getArgs()[Idx];
709 }
710 
711 inline const TemplateArgument &
713  assert(Idx < getNumArgs() && "Template argument out of range");
714  return getArgs()[Idx];
715 }
716 
717 inline const TemplateArgument &AutoType::getArg(unsigned Idx) const {
718  assert(Idx < getNumArgs() && "Template argument out of range");
719  return getArgs()[Idx];
720 }
721 
722 } // namespace clang
723 
724 #endif // LLVM_CLANG_AST_TEMPLATEBASE_H
clang::TemplateArgument::TemplateArgument
TemplateArgument(QualType T, bool isNullPtr=false)
Construct a template type argument.
Definition: TemplateBase.h:155
clang::DependentTemplateSpecializationType::end
iterator end() const
Definition: TemplateBase.h:701
llvm
Definition: Dominators.h:30
clang::TemplateArgument::TemplateArgument
TemplateArgument(ValueDecl *D, QualType QT)
Construct a template argument that refers to a declaration, which is either an external declaration o...
Definition: TemplateBase.h:163
clang::TemplateArgumentLocInfo::TemplateArgumentLocInfo
TemplateArgumentLocInfo(Expr *E)
Definition: TemplateBase.h:428
clang::interp::APInt
llvm::APInt APInt
Definition: Integral.h:27
clang::CharSourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:285
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
clang::TemplateArgument::getDependence
TemplateArgumentDependence getDependence() const
Definition: TemplateBase.cpp:189
clang::TemplateArgument::getAsTemplateOrTemplatePattern
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
Definition: TemplateBase.h:300
clang::ASTTemplateKWAndArgsInfo::RAngleLoc
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:665
clang::TemplateArgument::pack_elements
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:366
clang::TemplateArgument::pack_begin
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:352
clang::TemplateArgument::Null
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:68
DependenceFlags.h
clang::TemplateArgumentLocInfo::getTemplateQualifierLoc
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:441
clang::TemplateArgumentListInfo::getArgumentArray
const TemplateArgumentLoc * getArgumentArray() const
Definition: TemplateBase.h:588
clang::TemplateArgumentLoc::getSourceExpression
Expr * getSourceExpression() const
Definition: TemplateBase.h:521
llvm::SmallVector
Definition: LLVM.h:38
clang::TemplateArgumentLoc::getTemplateEllipsisLoc
SourceLocation getTemplateEllipsisLoc() const
Definition: TemplateBase.h:555
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::ASTTemplateKWAndArgsInfo::TemplateKWLoc
SourceLocation TemplateKWLoc
The source location of the template keyword; this is used as part of the representation of qualified ...
Definition: TemplateBase.h:671
clang::TemplateArgument::TemplateArg
struct TA TemplateArg
Definition: TemplateBase.h:146
clang::TemplateArgument::Profile
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
Definition: TemplateBase.cpp:305
clang::TemplateArgument::getIntegralType
QualType getIntegralType() const
Retrieve the type of the integral value.
Definition: TemplateBase.h:327
clang::TemplateArgument::getParamTypeForDecl
QualType getParamTypeForDecl() const
Definition: TemplateBase.h:281
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::TemplateArgumentLocInfo::TemplateArgumentLocInfo
TemplateArgumentLocInfo()
Definition: TemplateBase.h:425
clang::TemplateArgumentListInfo::getRAngleLoc
SourceLocation getRAngleLoc() const
Definition: TemplateBase.h:581
clang::TemplateArgument::Declaration
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:75
clang::DependentTemplateSpecializationType::getArg
const TemplateArgument & getArg(unsigned Idx) const
Definition: TemplateBase.h:712
clang::TemplateArgumentLoc::TemplateArgumentLoc
TemplateArgumentLoc()
Definition: TemplateBase.h:463
clang::ASTTemplateArgumentListInfo::getTemplateArgs
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
Definition: TemplateBase.h:636
llvm::Optional< unsigned >
getArgument
static const TemplateArgument & getArgument(const TemplateArgument &A)
Definition: TypePrinter.cpp:1856
clang::ASTTemplateArgumentListInfo::getRAngleLoc
SourceLocation getRAngleLoc() const
Definition: TemplateBase.h:633
clang::TemplateArgument::isNull
bool isNull() const
Determine whether this template argument has no value.
Definition: TemplateBase.h:248
Expression
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:59
clang::TemplateArgumentLocInfo::getAsExpr
Expr * getAsExpr() const
Definition: TemplateBase.h:439
clang::ASTTemplateArgumentListInfo::NumTemplateArgs
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:630
clang::tooling::fixit::internal::getSourceRange
CharSourceRange getSourceRange(const SourceRange &Range)
Returns the token CharSourceRange corresponding to Range.
Definition: FixIt.h:32
clang::TemplateArgument::setIntegralType
void setIntegralType(QualType T)
Definition: TemplateBase.h:332
clang::ASTTemplateKWAndArgsInfo::LAngleLoc
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:662
clang::TemplateArgument::getAsExpr
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:342
TemplateName.h
clang::TemplateArgumentLoc::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:515
clang::TemplateArgument::TemplateArgument
TemplateArgument(TemplateName Name)
Construct a template argument that is a template.
Definition: TemplateBase.h:189
clang::TemplateArgument::Expression
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:97
clang::ASTTemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:641
clang::TemplateArgument::getAsIntegral
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Definition: TemplateBase.h:313
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::TemplateArgumentLoc::TemplateArgumentLoc
TemplateArgumentLoc(ASTContext &Ctx, const TemplateArgument &Argument, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc=SourceLocation())
Definition: TemplateBase.h:485
clang::TemplateArgumentListInfo::getLAngleLoc
SourceLocation getLAngleLoc() const
Definition: TemplateBase.h:580
clang::TemplateArgument::Integral
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:83
clang::TemplateArgument::TypeOrValue
struct TV TypeOrValue
Definition: TemplateBase.h:147
APSInt
llvm::APSInt APSInt
Definition: ByteCodeEmitter.cpp:19
clang::TemplateArgument::NullPtr
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:79
clang::TemplateArgumentLoc::getLocation
SourceLocation getLocation() const
Definition: TemplateBase.h:496
clang::TemplateArgumentLoc::TemplateArgumentLoc
TemplateArgumentLoc(const TemplateArgument &Argument, TemplateArgumentLocInfo Opaque)
Definition: TemplateBase.h:465
clang::TemplateArgumentLoc::getSourceDeclExpression
Expr * getSourceDeclExpression() const
Definition: TemplateBase.h:526
V
#define V(N, I)
Definition: ASTContext.h:3113
clang::TemplateArgumentLoc::getLocInfo
TemplateArgumentLocInfo getLocInfo() const
Definition: TemplateBase.h:511
clang::TemplateArgument::TemplateArgument
TemplateArgument(TemplateName Name, Optional< unsigned > NumExpansions)
Construct a template argument that is a template pack expansion.
Definition: TemplateBase.h:206
clang::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:245
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:564
clang::TemplateArgumentListInfo::operator[]
TemplateArgumentLoc & operator[](unsigned I)
Definition: TemplateBase.h:600
clang::TemplateArgumentListInfo::addArgument
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:604
clang::TemplateArgumentListInfo::TemplateArgumentListInfo
TemplateArgumentListInfo(SourceLocation LAngleLoc, SourceLocation RAngleLoc)
Definition: TemplateBase.h:572
clang::TemplateArgument::TemplateArgument
TemplateArgument(Expr *E)
Construct a template argument that is an expression.
Definition: TemplateBase.h:220
clang::TemplateArgument::getEmptyPack
static TemplateArgument getEmptyPack()
Definition: TemplateBase.h:237
clang::TemplateArgument::DeclArg
struct DA DeclArg
Definition: TemplateBase.h:143
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:211
clang::TemplateArgumentLocInfo::getAsTypeSourceInfo
TypeSourceInfo * getAsTypeSourceInfo() const
Definition: TemplateBase.h:435
clang::StreamingDiagnostic
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Definition: Diagnostic.h:1105
clang::TemplateArgumentLocInfo::getTemplateNameLoc
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:447
NestedNameSpecifier.h
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:62
uintptr_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c-base.h:124
clang::TemplateArgument::pack_end
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
Definition: TemplateBase.h:359
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:458
Type.h
clang::TemplateArgumentListInfo::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:583
clang::TemplateArgument::CreatePackCopy
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
Definition: TemplateBase.cpp:181
clang::TemplateArgumentLoc::TemplateArgumentLoc
TemplateArgumentLoc(const TemplateArgument &Argument, TypeSourceInfo *TInfo)
Definition: TemplateBase.h:469
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::TemplateArgument::isPackExpansion
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
Definition: TemplateBase.cpp:245
clang::TemplateArgumentListInfo::operator[]
const TemplateArgumentLoc & operator[](unsigned I) const
Definition: TemplateBase.h:596
clang::operator<<
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Definition: ASTContext.cpp:11770
clang::TemplateArgument::TemplateArgument
TemplateArgument(const TemplateArgument &Other, QualType Type)
Construct an integral constant template argument with the same value as Other but a different type.
Definition: TemplateBase.h:176
clang::TemplateArgument::getNonTypeTemplateArgumentType
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
Definition: TemplateBase.cpp:280
clang::TemplateArgument::TemplateArgument
TemplateArgument(ArrayRef< TemplateArgument > Args)
Construct a template argument that is a template argument pack.
Definition: TemplateBase.h:229
clang::TemplateArgument::TemplateExpansion
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:91
clang::ASTTemplateArgumentListInfo::operator[]
const TemplateArgumentLoc & operator[](unsigned I) const
Definition: TemplateBase.h:645
clang::TemplateArgumentListInfo::arguments
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:592
clang::TemplateArgumentLoc::TemplateArgumentLoc
TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E)
Definition: TemplateBase.h:474
SourceLocation.h
clang::TemplateSpecializationType::getArg
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
Definition: TemplateBase.h:706
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::TemplateArgument::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
Definition: TemplateBase.cpp:268
clang::TemplateArgument::getPackAsArray
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
Definition: TemplateBase.h:378
clang::ASTTemplateArgumentListInfo::LAngleLoc
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:624
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:676
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:192
clang::TemplateArgument::Args
struct A Args
Definition: TemplateBase.h:145
clang::TemplateArgumentListInfo::size
unsigned size() const
Definition: TemplateBase.h:586
clang::TemplateArgumentLoc::getSourceIntegralExpression
Expr * getSourceIntegralExpression() const
Definition: TemplateBase.h:536
clang::TemplateArgument::dump
void dump() const
Debugging aid that dumps the template argument to standard error.
Definition: TemplateBase.cpp:494
llvm::ArrayRef
Definition: LLVM.h:34
clang::ASTTemplateArgumentListInfo::getLAngleLoc
SourceLocation getLAngleLoc() const
Definition: TemplateBase.h:632
Value
Value
Definition: UninitializedValues.cpp:102
llvm::PointerLikeTypeTraits< clang::Expr * >::getAsVoidPointer
static void * getAsVoidPointer(clang::Expr *P)
Definition: TemplateBase.h:43
clang::TemplateArgument::getNumTemplateExpansions
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
Definition: TemplateBase.cpp:272
clang::TemplateArgument::isDependent
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
Definition: TemplateBase.cpp:237
LLVM.h
clang::TemplateArgument::isInstantiationDependent
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
Definition: TemplateBase.cpp:241
clang::TemplateArgument::TemplateArgument
constexpr TemplateArgument()
Construct an empty, invalid template argument.
Definition: TemplateBase.h:152
clang::TemplateArgumentLoc::getSourceNullPtrExpression
Expr * getSourceNullPtrExpression() const
Definition: TemplateBase.h:531
clang::TemplateName::getFromVoidPointer
static TemplateName getFromVoidPointer(void *Ptr)
Build a template name from a void pointer.
Definition: TemplateName.h:339
clang::ASTTemplateArgumentListInfo::getNumTemplateArgs
unsigned getNumTemplateArgs() const
Definition: TemplateBase.h:639
clang::QualType::getFromOpaquePtr
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:720
bytes
static StringRef bytes(const std::vector< T, Allocator > &v)
Definition: ASTWriter.cpp:123
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::TemplateArgument::getAsDecl
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:276
clang::TemplateArgument::print
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
Definition: TemplateBase.cpp:417
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang::TemplateArgument::Type
@ Type
The template argument is a type.
Definition: TemplateBase.h:71
clang
Definition: CalledOnceCheck.h:17
clang::TemplateArgumentListInfo::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:584
clang::TemplateArgument::getPackExpansionPattern
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
Definition: TemplateBase.cpp:392
clang::TemplateArgument::getNullPtrType
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Definition: TemplateBase.h:287
clang::TemplateArgument::Template
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:87
clang::TemplateArgument::getAsTemplate
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:293
clang::TemplateArgument::ArgKind
ArgKind
The kind of template argument we're storing.
Definition: TemplateBase.h:65
clang::Declarator
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1804
clang::ASTNodeImporter
Definition: ASTImporter.cpp:140
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6396
llvm::PointerLikeTypeTraits< clang::Expr * >::getFromVoidPointer
static clang::Expr * getFromVoidPointer(void *P)
Definition: TemplateBase.h:44
llvm::PointerLikeTypeTraits
Definition: DeclGroup.h:139
clang::ASTTemplateKWAndArgsInfo::NumTemplateArgs
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:674
clang::QualType::getAsOpaquePtr
void * getAsOpaquePtr() const
Definition: Type.h:718
clang::AutoType::getArg
const TemplateArgument & getArg(unsigned Idx) const
Definition: TemplateBase.h:717
clang::TemplateArgument::pack_size
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:372
GCCTypeClass::Pointer
@ Pointer
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:613
clang::TemplateSpecializationType::end
iterator end() const
Definition: TemplateBase.h:696
clang::TemplateArgumentLoc::getTemplateQualifierLoc
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:541
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::TemplateArgumentLoc::getTemplateNameLoc
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:548
clang::ASTTemplateKWAndArgsInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:660
clang::TemplateArgumentLocInfo::TemplateArgumentLocInfo
TemplateArgumentLocInfo(TypeSourceInfo *Declarator)
Definition: TemplateBase.h:426
clang::TemplateArgumentLocInfo::getTemplateEllipsisLoc
SourceLocation getTemplateEllipsisLoc() const
Definition: TemplateBase.h:451
GCCTypeClass::None
@ None
clang::ASTTemplateArgumentListInfo::RAngleLoc
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:627
clang::TemplateArgument::Integer
struct I Integer
Definition: TemplateBase.h:144
clang::TemplateArgumentLocInfo
Location information for a TemplateArgument.
Definition: TemplateBase.h:406
clang::TemplateArgument::structurallyEquals
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
Definition: TemplateBase.cpp:359
clang::TemplateArgument::getAsType
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:269
clang::TemplateArgument::Pack
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:101