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