clang  6.0.0svn
TemplateBase.cpp
Go to the documentation of this file.
1 //===- TemplateBase.cpp - Common template AST class implementation --------===//
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 implements common classes used throughout C++ template
11 // representations.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "clang/AST/TemplateBase.h"
16 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclBase.h"
19 #include "clang/AST/DeclTemplate.h"
20 #include "clang/AST/Expr.h"
21 #include "clang/AST/ExprCXX.h"
23 #include "clang/AST/TemplateName.h"
24 #include "clang/AST/Type.h"
25 #include "clang/AST/TypeLoc.h"
26 #include "clang/Basic/Diagnostic.h"
27 #include "clang/Basic/LLVM.h"
30 #include "llvm/ADT/APSInt.h"
31 #include "llvm/ADT/FoldingSet.h"
32 #include "llvm/ADT/None.h"
33 #include "llvm/ADT/SmallString.h"
34 #include "llvm/ADT/StringRef.h"
35 #include "llvm/Support/Casting.h"
36 #include "llvm/Support/Compiler.h"
37 #include "llvm/Support/ErrorHandling.h"
38 #include "llvm/Support/raw_ostream.h"
39 #include <cassert>
40 #include <cstddef>
41 #include <cstdint>
42 #include <cstring>
43 
44 using namespace clang;
45 
46 /// \brief Print a template integral argument value.
47 ///
48 /// \param TemplArg the TemplateArgument instance to print.
49 ///
50 /// \param Out the raw_ostream instance to use for printing.
51 ///
52 /// \param Policy the printing policy for EnumConstantDecl printing.
53 static void printIntegral(const TemplateArgument &TemplArg,
54  raw_ostream &Out, const PrintingPolicy& Policy) {
55  const Type *T = TemplArg.getIntegralType().getTypePtr();
56  const llvm::APSInt &Val = TemplArg.getAsIntegral();
57 
58  if (const EnumType *ET = T->getAs<EnumType>()) {
59  for (const EnumConstantDecl* ECD : ET->getDecl()->enumerators()) {
60  // In Sema::CheckTemplateArugment, enum template arguments value are
61  // extended to the size of the integer underlying the enum type. This
62  // may create a size difference between the enum value and template
63  // argument value, requiring isSameValue here instead of operator==.
64  if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
65  ECD->printQualifiedName(Out, Policy);
66  return;
67  }
68  }
69  }
70 
71  if (T->isBooleanType() && !Policy.MSVCFormatting) {
72  Out << (Val.getBoolValue() ? "true" : "false");
73  } else if (T->isCharType()) {
74  const char Ch = Val.getZExtValue();
75  Out << ((Ch == '\'') ? "'\\" : "'");
76  Out.write_escaped(StringRef(&Ch, 1), /*UseHexEscapes=*/ true);
77  Out << "'";
78  } else {
79  Out << Val;
80  }
81 }
82 
83 //===----------------------------------------------------------------------===//
84 // TemplateArgument Implementation
85 //===----------------------------------------------------------------------===//
86 
88  QualType Type) {
89  Integer.Kind = Integral;
90  // Copy the APSInt value into our decomposed form.
91  Integer.BitWidth = Value.getBitWidth();
92  Integer.IsUnsigned = Value.isUnsigned();
93  // If the value is large, we have to get additional memory from the ASTContext
94  unsigned NumWords = Value.getNumWords();
95  if (NumWords > 1) {
96  void *Mem = Ctx.Allocate(NumWords * sizeof(uint64_t));
97  std::memcpy(Mem, Value.getRawData(), NumWords * sizeof(uint64_t));
98  Integer.pVal = static_cast<uint64_t *>(Mem);
99  } else {
100  Integer.VAL = Value.getZExtValue();
101  }
102 
103  Integer.Type = Type.getAsOpaquePtr();
104 }
105 
109  if (Args.empty())
110  return getEmptyPack();
111 
112  return TemplateArgument(Args.copy(Context));
113 }
114 
116  switch (getKind()) {
117  case Null:
118  llvm_unreachable("Should not have a NULL template argument");
119 
120  case Type:
121  return getAsType()->isDependentType() ||
122  isa<PackExpansionType>(getAsType());
123 
124  case Template:
125  return getAsTemplate().isDependent();
126 
127  case TemplateExpansion:
128  return true;
129 
130  case Declaration:
131  if (DeclContext *DC = dyn_cast<DeclContext>(getAsDecl()))
132  return DC->isDependentContext();
134 
135  case NullPtr:
136  return false;
137 
138  case Integral:
139  // Never dependent
140  return false;
141 
142  case Expression:
143  return (getAsExpr()->isTypeDependent() || getAsExpr()->isValueDependent() ||
144  isa<PackExpansionExpr>(getAsExpr()));
145 
146  case Pack:
147  for (const auto &P : pack_elements())
148  if (P.isDependent())
149  return true;
150  return false;
151  }
152 
153  llvm_unreachable("Invalid TemplateArgument Kind!");
154 }
155 
157  switch (getKind()) {
158  case Null:
159  llvm_unreachable("Should not have a NULL template argument");
160 
161  case Type:
163 
164  case Template:
166 
167  case TemplateExpansion:
168  return true;
169 
170  case Declaration:
171  if (DeclContext *DC = dyn_cast<DeclContext>(getAsDecl()))
172  return DC->isDependentContext();
174 
175  case NullPtr:
176  return false;
177 
178  case Integral:
179  // Never dependent
180  return false;
181 
182  case Expression:
184 
185  case Pack:
186  for (const auto &P : pack_elements())
187  if (P.isInstantiationDependent())
188  return true;
189  return false;
190  }
191 
192  llvm_unreachable("Invalid TemplateArgument Kind!");
193 }
194 
196  switch (getKind()) {
197  case Null:
198  case Declaration:
199  case Integral:
200  case Pack:
201  case Template:
202  case NullPtr:
203  return false;
204 
205  case TemplateExpansion:
206  return true;
207 
208  case Type:
209  return isa<PackExpansionType>(getAsType());
210 
211  case Expression:
212  return isa<PackExpansionExpr>(getAsExpr());
213  }
214 
215  llvm_unreachable("Invalid TemplateArgument Kind!");
216 }
217 
219  switch (getKind()) {
220  case Null:
221  case Declaration:
222  case Integral:
223  case TemplateExpansion:
224  case NullPtr:
225  break;
226 
227  case Type:
229  return true;
230  break;
231 
232  case Template:
234  return true;
235  break;
236 
237  case Expression:
239  return true;
240  break;
241 
242  case Pack:
243  for (const auto &P : pack_elements())
244  if (P.containsUnexpandedParameterPack())
245  return true;
246 
247  break;
248  }
249 
250  return false;
251 }
252 
254  assert(getKind() == TemplateExpansion);
255  if (TemplateArg.NumExpansions)
256  return TemplateArg.NumExpansions - 1;
257 
258  return None;
259 }
260 
262  switch (getKind()) {
268  return QualType();
269 
271  return getIntegralType();
272 
274  return getAsExpr()->getType();
275 
277  return getParamTypeForDecl();
278 
280  return getNullPtrType();
281  }
282 
283  llvm_unreachable("Invalid TemplateArgument Kind!");
284 }
285 
286 void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
287  const ASTContext &Context) const {
288  ID.AddInteger(getKind());
289  switch (getKind()) {
290  case Null:
291  break;
292 
293  case Type:
294  getAsType().Profile(ID);
295  break;
296 
297  case NullPtr:
298  getNullPtrType().Profile(ID);
299  break;
300 
301  case Declaration:
302  ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : nullptr);
303  break;
304 
305  case Template:
306  case TemplateExpansion: {
308  if (TemplateTemplateParmDecl *TTP
309  = dyn_cast_or_null<TemplateTemplateParmDecl>(
310  Template.getAsTemplateDecl())) {
311  ID.AddBoolean(true);
312  ID.AddInteger(TTP->getDepth());
313  ID.AddInteger(TTP->getPosition());
314  ID.AddBoolean(TTP->isParameterPack());
315  } else {
316  ID.AddBoolean(false);
317  ID.AddPointer(Context.getCanonicalTemplateName(Template)
318  .getAsVoidPointer());
319  }
320  break;
321  }
322 
323  case Integral:
324  getAsIntegral().Profile(ID);
325  getIntegralType().Profile(ID);
326  break;
327 
328  case Expression:
329  getAsExpr()->Profile(ID, Context, true);
330  break;
331 
332  case Pack:
333  ID.AddInteger(Args.NumArgs);
334  for (unsigned I = 0; I != Args.NumArgs; ++I)
335  Args.Args[I].Profile(ID, Context);
336  }
337 }
338 
340  if (getKind() != Other.getKind()) return false;
341 
342  switch (getKind()) {
343  case Null:
344  case Type:
345  case Expression:
346  case Template:
347  case TemplateExpansion:
348  case NullPtr:
349  return TypeOrValue.V == Other.TypeOrValue.V;
350 
351  case Declaration:
352  return getAsDecl() == Other.getAsDecl();
353 
354  case Integral:
355  return getIntegralType() == Other.getIntegralType() &&
356  getAsIntegral() == Other.getAsIntegral();
357 
358  case Pack:
359  if (Args.NumArgs != Other.Args.NumArgs) return false;
360  for (unsigned I = 0, E = Args.NumArgs; I != E; ++I)
361  if (!Args.Args[I].structurallyEquals(Other.Args.Args[I]))
362  return false;
363  return true;
364  }
365 
366  llvm_unreachable("Invalid TemplateArgument Kind!");
367 }
368 
370  assert(isPackExpansion());
371 
372  switch (getKind()) {
373  case Type:
374  return getAsType()->getAs<PackExpansionType>()->getPattern();
375 
376  case Expression:
377  return cast<PackExpansionExpr>(getAsExpr())->getPattern();
378 
379  case TemplateExpansion:
381 
382  case Declaration:
383  case Integral:
384  case Pack:
385  case Null:
386  case Template:
387  case NullPtr:
388  return TemplateArgument();
389  }
390 
391  llvm_unreachable("Invalid TemplateArgument Kind!");
392 }
393 
395  raw_ostream &Out) const {
396  switch (getKind()) {
397  case Null:
398  Out << "(no value)";
399  break;
400 
401  case Type: {
402  PrintingPolicy SubPolicy(Policy);
403  SubPolicy.SuppressStrongLifetime = true;
404  getAsType().print(Out, SubPolicy);
405  break;
406  }
407 
408  case Declaration: {
409  NamedDecl *ND = cast<NamedDecl>(getAsDecl());
410  Out << '&';
411  if (ND->getDeclName()) {
412  // FIXME: distinguish between pointer and reference args?
413  ND->printQualifiedName(Out);
414  } else {
415  Out << "(anonymous)";
416  }
417  break;
418  }
419 
420  case NullPtr:
421  Out << "nullptr";
422  break;
423 
424  case Template:
425  getAsTemplate().print(Out, Policy);
426  break;
427 
428  case TemplateExpansion:
429  getAsTemplateOrTemplatePattern().print(Out, Policy);
430  Out << "...";
431  break;
432 
433  case Integral:
434  printIntegral(*this, Out, Policy);
435  break;
436 
437  case Expression:
438  getAsExpr()->printPretty(Out, nullptr, Policy);
439  break;
440 
441  case Pack:
442  Out << "<";
443  bool First = true;
444  for (const auto &P : pack_elements()) {
445  if (First)
446  First = false;
447  else
448  Out << ", ";
449 
450  P.print(Policy, Out);
451  }
452  Out << ">";
453  break;
454  }
455 }
456 
457 void TemplateArgument::dump(raw_ostream &Out) const {
458  LangOptions LO; // FIXME! see also TemplateName::dump().
459  LO.CPlusPlus = true;
460  LO.Bool = true;
461  print(PrintingPolicy(LO), Out);
462 }
463 
464 LLVM_DUMP_METHOD void TemplateArgument::dump() const { dump(llvm::errs()); }
465 
466 //===----------------------------------------------------------------------===//
467 // TemplateArgumentLoc Implementation
468 //===----------------------------------------------------------------------===//
469 
471  switch (Argument.getKind()) {
473  return getSourceExpression()->getSourceRange();
474 
476  return getSourceDeclExpression()->getSourceRange();
477 
479  return getSourceNullPtrExpression()->getSourceRange();
480 
482  if (TypeSourceInfo *TSI = getTypeSourceInfo())
483  return TSI->getTypeLoc().getSourceRange();
484  else
485  return SourceRange();
486 
488  if (getTemplateQualifierLoc())
489  return SourceRange(getTemplateQualifierLoc().getBeginLoc(),
490  getTemplateNameLoc());
491  return SourceRange(getTemplateNameLoc());
492 
494  if (getTemplateQualifierLoc())
495  return SourceRange(getTemplateQualifierLoc().getBeginLoc(),
496  getTemplateEllipsisLoc());
497  return SourceRange(getTemplateNameLoc(), getTemplateEllipsisLoc());
498 
500  return getSourceIntegralExpression()->getSourceRange();
501 
504  return SourceRange();
505  }
506 
507  llvm_unreachable("Invalid TemplateArgument Kind!");
508 }
509 
511  const TemplateArgument &Arg) {
512  switch (Arg.getKind()) {
514  // This is bad, but not as bad as crashing because of argument
515  // count mismatches.
516  return DB << "(null template argument)";
517 
519  return DB << Arg.getAsType();
520 
522  return DB << Arg.getAsDecl();
523 
525  return DB << "nullptr";
526 
528  return DB << Arg.getAsIntegral().toString(10);
529 
531  return DB << Arg.getAsTemplate();
532 
534  return DB << Arg.getAsTemplateOrTemplatePattern() << "...";
535 
537  // This shouldn't actually ever happen, so it's okay that we're
538  // regurgitating an expression here.
539  // FIXME: We're guessing at LangOptions!
540  SmallString<32> Str;
541  llvm::raw_svector_ostream OS(Str);
542  LangOptions LangOpts;
543  LangOpts.CPlusPlus = true;
544  PrintingPolicy Policy(LangOpts);
545  Arg.getAsExpr()->printPretty(OS, nullptr, Policy);
546  return DB << OS.str();
547  }
548 
549  case TemplateArgument::Pack: {
550  // FIXME: We're guessing at LangOptions!
551  SmallString<32> Str;
552  llvm::raw_svector_ostream OS(Str);
553  LangOptions LangOpts;
554  LangOpts.CPlusPlus = true;
555  PrintingPolicy Policy(LangOpts);
556  Arg.print(Policy, OS);
557  return DB << OS.str();
558  }
559  }
560 
561  llvm_unreachable("Invalid TemplateArgument Kind!");
562 }
563 
566  const TemplateArgumentListInfo &List) {
567  std::size_t size = totalSizeToAlloc<TemplateArgumentLoc>(List.size());
568  void *Mem = C.Allocate(size, alignof(ASTTemplateArgumentListInfo));
569  return new (Mem) ASTTemplateArgumentListInfo(List);
570 }
571 
572 ASTTemplateArgumentListInfo::ASTTemplateArgumentListInfo(
573  const TemplateArgumentListInfo &Info) {
574  LAngleLoc = Info.getLAngleLoc();
575  RAngleLoc = Info.getRAngleLoc();
576  NumTemplateArgs = Info.size();
577 
578  TemplateArgumentLoc *ArgBuffer = getTrailingObjects<TemplateArgumentLoc>();
579  for (unsigned i = 0; i != NumTemplateArgs; ++i)
580  new (&ArgBuffer[i]) TemplateArgumentLoc(Info[i]);
581 }
582 
584  SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &Info,
585  TemplateArgumentLoc *OutArgArray) {
586  this->TemplateKWLoc = TemplateKWLoc;
587  LAngleLoc = Info.getLAngleLoc();
588  RAngleLoc = Info.getRAngleLoc();
589  NumTemplateArgs = Info.size();
590 
591  for (unsigned i = 0; i != NumTemplateArgs; ++i)
592  new (&OutArgArray[i]) TemplateArgumentLoc(Info[i]);
593 }
594 
596  assert(TemplateKWLoc.isValid());
597  LAngleLoc = SourceLocation();
598  RAngleLoc = SourceLocation();
599  this->TemplateKWLoc = TemplateKWLoc;
600  NumTemplateArgs = 0;
601 }
602 
604  SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &Info,
605  TemplateArgumentLoc *OutArgArray, bool &Dependent,
606  bool &InstantiationDependent, bool &ContainsUnexpandedParameterPack) {
607  this->TemplateKWLoc = TemplateKWLoc;
608  LAngleLoc = Info.getLAngleLoc();
609  RAngleLoc = Info.getRAngleLoc();
610  NumTemplateArgs = Info.size();
611 
612  for (unsigned i = 0; i != NumTemplateArgs; ++i) {
613  Dependent = Dependent || Info[i].getArgument().isDependent();
614  InstantiationDependent = InstantiationDependent ||
615  Info[i].getArgument().isInstantiationDependent();
616  ContainsUnexpandedParameterPack =
617  ContainsUnexpandedParameterPack ||
618  Info[i].getArgument().containsUnexpandedParameterPack();
619 
620  new (&OutArgArray[i]) TemplateArgumentLoc(Info[i]);
621  }
622 }
623 
625  TemplateArgumentListInfo &Info) const {
626  Info.setLAngleLoc(LAngleLoc);
627  Info.setRAngleLoc(RAngleLoc);
628  for (unsigned I = 0; I != NumTemplateArgs; ++I)
629  Info.addArgument(ArgArray[I]);
630 }
Defines the clang::ASTContext interface.
static const Decl * getCanonicalDecl(const Decl *D)
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
Definition: TemplateName.h:310
A (possibly-)qualified type.
Definition: Type.h:653
static void printIntegral(const TemplateArgument &TemplArg, raw_ostream &Out, const PrintingPolicy &Policy)
Print a template integral argument value.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: Type.h:991
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c.h:60
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2661
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:87
Defines the C++ template declaration subclasses.
StringRef P
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:195
The base class of the type hierarchy.
Definition: Type.h:1353
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:64
A container of type source information.
Definition: Decl.h:86
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:566
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6307
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:57
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:595
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
Defines the clang::Expr interface and subclasses for C++ expressions.
QualType getIntegralType() const
Retrieve the type of the integral value.
Definition: TemplateBase.h:315
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:291
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
static TemplateArgument getEmptyPack()
Definition: TemplateBase.h:227
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool SuppressNNS=false) const
Print the template name.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:330
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:149
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:72
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isCharType() const
Definition: Type.cpp:1750
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
SourceRange getSourceRange() const LLVM_READONLY
Fetches the full source range of the argument.
QualType getParamTypeForDecl() const
Definition: TemplateBase.h:269
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
A convenient class for passing around template argument information.
Definition: TemplateBase.h:546
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Definition: TemplateBase.h:275
Defines the Diagnostic-related interfaces.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:5720
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
void * getAsOpaquePtr() const
Definition: Type.h:699
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:955
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:264
Defines the clang::LangOptions interface.
const FunctionProtoType * T
constexpr TemplateArgument()
Construct an empty, invalid template argument.
Definition: TemplateBase.h:142
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:68
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: Type.h:1051
DeclContext * getDeclContext()
Definition: DeclBase.h:425
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Defines the clang::TypeLoc interface and its subclasses.
QualType getType() const
Definition: Expr.h:128
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1026
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
void printQualifiedName(raw_ostream &OS) const
printQualifiedName - Returns human-readable qualified name for declaration, like A::B::i, for i being member of namespace A::B.
Definition: Decl.cpp:1478
void copyInto(const TemplateArgumentLoc *ArgArray, TemplateArgumentListInfo &List) const
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:191
Encodes a location in the source.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4004
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Definition: TemplateBase.h:301
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:565
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:586
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:1866
Represents a pack expansion of types.
Definition: Type.h:4996
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:354
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:650
Represents a template argument.
Definition: TemplateBase.h:51
Dataflow Directional Tag Classes.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
bool isValid() const
Return true if this is a valid SourceLocation object.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1252
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:80
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
bool isBooleanType() const
Definition: Type.h:6234
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
The template argument is a type.
Definition: TemplateBase.h:60
The template argument is actually a parameter pack.
Definition: TemplateBase.h:91
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:235
Defines the clang::SourceLocation class and associated facilities.
static const ASTTemplateArgumentListInfo * Create(ASTContext &C, const TemplateArgumentListInfo &List)
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:76
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
void initializeFrom(SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &List, TemplateArgumentLoc *OutArgArray)
SourceLocation getLAngleLoc() const
Definition: TemplateBase.h:562
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:1860
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:257
bool MSVCFormatting
Use whitespace and punctuation like MSVC does.
void dump() const
Debugging aid that dumps the template argument to standard error.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
Definition: Decl.h:245
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:281
SourceLocation getRAngleLoc() const
Definition: TemplateBase.h:563
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:288
bool isDependent() const
Determines whether this is a dependent template name.
bool isInstantiationDependent() const
Determines whether this is a template name that somehow depends on a template parameter.