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