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