clang  16.0.0git
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"
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/StringExtras.h"
35 #include "llvm/ADT/StringRef.h"
36 #include "llvm/Support/Casting.h"
37 #include "llvm/Support/Compiler.h"
38 #include "llvm/Support/ErrorHandling.h"
39 #include "llvm/Support/raw_ostream.h"
40 #include <cassert>
41 #include <cstddef>
42 #include <cstdint>
43 #include <cstring>
44 
45 using namespace clang;
46 
47 /// Print a template integral argument value.
48 ///
49 /// \param TemplArg the TemplateArgument instance to print.
50 ///
51 /// \param Out the raw_ostream instance to use for printing.
52 ///
53 /// \param Policy the printing policy for EnumConstantDecl printing.
54 ///
55 /// \param IncludeType If set, ensure that the type of the expression printed
56 /// matches the type of the template argument.
57 static void printIntegral(const TemplateArgument &TemplArg, raw_ostream &Out,
58  const PrintingPolicy &Policy, bool IncludeType) {
59  const Type *T = TemplArg.getIntegralType().getTypePtr();
60  const llvm::APSInt &Val = TemplArg.getAsIntegral();
61 
62  if (Policy.UseEnumerators) {
63  if (const EnumType *ET = T->getAs<EnumType>()) {
64  for (const EnumConstantDecl *ECD : ET->getDecl()->enumerators()) {
65  // In Sema::CheckTemplateArugment, enum template arguments value are
66  // extended to the size of the integer underlying the enum type. This
67  // may create a size difference between the enum value and template
68  // argument value, requiring isSameValue here instead of operator==.
69  if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
70  ECD->printQualifiedName(Out, Policy);
71  return;
72  }
73  }
74  }
75  }
76 
77  if (Policy.MSVCFormatting)
78  IncludeType = false;
79 
80  if (T->isBooleanType()) {
81  if (!Policy.MSVCFormatting)
82  Out << (Val.getBoolValue() ? "true" : "false");
83  else
84  Out << Val;
85  } else if (T->isCharType()) {
86  if (IncludeType) {
87  if (T->isSpecificBuiltinType(BuiltinType::SChar))
88  Out << "(signed char)";
89  else if (T->isSpecificBuiltinType(BuiltinType::UChar))
90  Out << "(unsigned char)";
91  }
92  CharacterLiteral::print(Val.getZExtValue(), CharacterLiteral::Ascii, Out);
93  } else if (T->isAnyCharacterType() && !Policy.MSVCFormatting) {
95  if (T->isWideCharType())
97  else if (T->isChar8Type())
99  else if (T->isChar16Type())
101  else if (T->isChar32Type())
103  else
105  CharacterLiteral::print(Val.getExtValue(), Kind, Out);
106  } else if (IncludeType) {
107  if (const auto *BT = T->getAs<BuiltinType>()) {
108  switch (BT->getKind()) {
109  case BuiltinType::ULongLong:
110  Out << Val << "ULL";
111  break;
112  case BuiltinType::LongLong:
113  Out << Val << "LL";
114  break;
115  case BuiltinType::ULong:
116  Out << Val << "UL";
117  break;
118  case BuiltinType::Long:
119  Out << Val << "L";
120  break;
121  case BuiltinType::UInt:
122  Out << Val << "U";
123  break;
124  case BuiltinType::Int:
125  Out << Val;
126  break;
127  default:
128  Out << "(" << T->getCanonicalTypeInternal().getAsString(Policy) << ")"
129  << Val;
130  break;
131  }
132  } else
133  Out << "(" << T->getCanonicalTypeInternal().getAsString(Policy) << ")"
134  << Val;
135  } else
136  Out << Val;
137 }
138 
139 static unsigned getArrayDepth(QualType type) {
140  unsigned count = 0;
141  while (const auto *arrayType = type->getAsArrayTypeUnsafe()) {
142  count++;
143  type = arrayType->getElementType();
144  }
145  return count;
146 }
147 
148 static bool needsAmpersandOnTemplateArg(QualType paramType, QualType argType) {
149  // Generally, if the parameter type is a pointer, we must be taking the
150  // address of something and need a &. However, if the argument is an array,
151  // this could be implicit via array-to-pointer decay.
152  if (!paramType->isPointerType())
153  return paramType->isMemberPointerType();
154  if (argType->isArrayType())
155  return getArrayDepth(argType) == getArrayDepth(paramType->getPointeeType());
156  return true;
157 }
158 
159 //===----------------------------------------------------------------------===//
160 // TemplateArgument Implementation
161 //===----------------------------------------------------------------------===//
162 
164  QualType Type) {
165  Integer.Kind = Integral;
166  // Copy the APSInt value into our decomposed form.
167  Integer.BitWidth = Value.getBitWidth();
168  Integer.IsUnsigned = Value.isUnsigned();
169  // If the value is large, we have to get additional memory from the ASTContext
170  unsigned NumWords = Value.getNumWords();
171  if (NumWords > 1) {
172  void *Mem = Ctx.Allocate(NumWords * sizeof(uint64_t));
173  std::memcpy(Mem, Value.getRawData(), NumWords * sizeof(uint64_t));
174  Integer.pVal = static_cast<uint64_t *>(Mem);
175  } else {
176  Integer.VAL = Value.getZExtValue();
177  }
178 
179  Integer.Type = Type.getAsOpaquePtr();
180 }
181 
185  if (Args.empty())
186  return getEmptyPack();
187 
188  return TemplateArgument(Args.copy(Context));
189 }
190 
191 TemplateArgumentDependence TemplateArgument::getDependence() const {
193  switch (getKind()) {
194  case Null:
195  llvm_unreachable("Should not have a NULL template argument");
196 
197  case Type:
199  if (isa<PackExpansionType>(getAsType()))
200  Deps |= TemplateArgumentDependence::Dependent;
201  return Deps;
202 
203  case Template:
205 
206  case TemplateExpansion:
207  return TemplateArgumentDependence::Dependent |
208  TemplateArgumentDependence::Instantiation;
209 
210  case Declaration: {
211  auto *DC = dyn_cast<DeclContext>(getAsDecl());
212  if (!DC)
213  DC = getAsDecl()->getDeclContext();
214  if (DC->isDependentContext())
215  Deps = TemplateArgumentDependence::Dependent |
216  TemplateArgumentDependence::Instantiation;
217  return Deps;
218  }
219 
220  case NullPtr:
221  case Integral:
223 
224  case Expression:
226  if (isa<PackExpansionExpr>(getAsExpr()))
227  Deps |= TemplateArgumentDependence::Dependent |
228  TemplateArgumentDependence::Instantiation;
229  return Deps;
230 
231  case Pack:
232  for (const auto &P : pack_elements())
233  Deps |= P.getDependence();
234  return Deps;
235  }
236  llvm_unreachable("unhandled ArgKind");
237 }
238 
240  return getDependence() & TemplateArgumentDependence::Dependent;
241 }
242 
244  return getDependence() & TemplateArgumentDependence::Instantiation;
245 }
246 
248  switch (getKind()) {
249  case Null:
250  case Declaration:
251  case Integral:
252  case Pack:
253  case Template:
254  case NullPtr:
255  return false;
256 
257  case TemplateExpansion:
258  return true;
259 
260  case Type:
261  return isa<PackExpansionType>(getAsType());
262 
263  case Expression:
264  return isa<PackExpansionExpr>(getAsExpr());
265  }
266 
267  llvm_unreachable("Invalid TemplateArgument Kind!");
268 }
269 
271  return getDependence() & TemplateArgumentDependence::UnexpandedPack;
272 }
273 
275  assert(getKind() == TemplateExpansion);
276  if (TemplateArg.NumExpansions)
277  return TemplateArg.NumExpansions - 1;
278 
279  return None;
280 }
281 
283  switch (getKind()) {
289  return QualType();
290 
292  return getIntegralType();
293 
295  return getAsExpr()->getType();
296 
298  return getParamTypeForDecl();
299 
301  return getNullPtrType();
302  }
303 
304  llvm_unreachable("Invalid TemplateArgument Kind!");
305 }
306 
307 void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
308  const ASTContext &Context) const {
309  ID.AddInteger(getKind());
310  switch (getKind()) {
311  case Null:
312  break;
313 
314  case Type:
315  getAsType().Profile(ID);
316  break;
317 
318  case NullPtr:
320  break;
321 
322  case Declaration:
324  ID.AddPointer(getAsDecl());
325  break;
326 
327  case TemplateExpansion:
328  ID.AddInteger(TemplateArg.NumExpansions);
329  LLVM_FALLTHROUGH;
330  case Template:
332  break;
333 
334  case Integral:
335  getAsIntegral().Profile(ID);
337  break;
338 
339  case Expression:
340  getAsExpr()->Profile(ID, Context, true);
341  break;
342 
343  case Pack:
344  ID.AddInteger(Args.NumArgs);
345  for (unsigned I = 0; I != Args.NumArgs; ++I)
346  Args.Args[I].Profile(ID, Context);
347  }
348 }
349 
351  if (getKind() != Other.getKind()) return false;
352 
353  switch (getKind()) {
354  case Null:
355  case Type:
356  case Expression:
357  case NullPtr:
358  return TypeOrValue.V == Other.TypeOrValue.V;
359 
360  case Template:
361  case TemplateExpansion:
362  return TemplateArg.Name == Other.TemplateArg.Name &&
363  TemplateArg.NumExpansions == Other.TemplateArg.NumExpansions;
364 
365  case Declaration:
366  return getAsDecl() == Other.getAsDecl() &&
368 
369  case Integral:
370  return getIntegralType() == Other.getIntegralType() &&
371  getAsIntegral() == Other.getAsIntegral();
372 
373  case Pack:
374  if (Args.NumArgs != Other.Args.NumArgs) return false;
375  for (unsigned I = 0, E = Args.NumArgs; I != E; ++I)
376  if (!Args.Args[I].structurallyEquals(Other.Args.Args[I]))
377  return false;
378  return true;
379  }
380 
381  llvm_unreachable("Invalid TemplateArgument Kind!");
382 }
383 
385  assert(isPackExpansion());
386 
387  switch (getKind()) {
388  case Type:
389  return getAsType()->castAs<PackExpansionType>()->getPattern();
390 
391  case Expression:
392  return cast<PackExpansionExpr>(getAsExpr())->getPattern();
393 
394  case TemplateExpansion:
396 
397  case Declaration:
398  case Integral:
399  case Pack:
400  case Null:
401  case Template:
402  case NullPtr:
403  return TemplateArgument();
404  }
405 
406  llvm_unreachable("Invalid TemplateArgument Kind!");
407 }
408 
409 void TemplateArgument::print(const PrintingPolicy &Policy, raw_ostream &Out,
410  bool IncludeType) const {
411 
412  switch (getKind()) {
413  case Null:
414  Out << "(no value)";
415  break;
416 
417  case Type: {
418  PrintingPolicy SubPolicy(Policy);
419  SubPolicy.SuppressStrongLifetime = true;
420  getAsType().print(Out, SubPolicy);
421  break;
422  }
423 
424  case Declaration: {
425  NamedDecl *ND = getAsDecl();
427  if (auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
428  TPO->getType().getUnqualifiedType().print(Out, Policy);
429  TPO->printAsInit(Out, Policy);
430  break;
431  }
432  }
433  if (auto *VD = dyn_cast<ValueDecl>(ND)) {
434  if (needsAmpersandOnTemplateArg(getParamTypeForDecl(), VD->getType()))
435  Out << "&";
436  }
437  ND->printQualifiedName(Out);
438  break;
439  }
440 
441  case NullPtr:
442  // FIXME: Include the type if it's not obvious from the context.
443  Out << "nullptr";
444  break;
445 
446  case Template:
448  break;
449 
450  case TemplateExpansion:
452  Out << "...";
453  break;
454 
455  case Integral:
456  printIntegral(*this, Out, Policy, IncludeType);
457  break;
458 
459  case Expression:
460  getAsExpr()->printPretty(Out, nullptr, Policy);
461  break;
462 
463  case Pack:
464  Out << "<";
465  bool First = true;
466  for (const auto &P : pack_elements()) {
467  if (First)
468  First = false;
469  else
470  Out << ", ";
471 
472  P.print(Policy, Out, IncludeType);
473  }
474  Out << ">";
475  break;
476  }
477 }
478 
479 void TemplateArgument::dump(raw_ostream &Out) const {
480  LangOptions LO; // FIXME! see also TemplateName::dump().
481  LO.CPlusPlus = true;
482  LO.Bool = true;
483  print(PrintingPolicy(LO), Out, /*IncludeType*/ true);
484 }
485 
486 LLVM_DUMP_METHOD void TemplateArgument::dump() const { dump(llvm::errs()); }
487 
488 //===----------------------------------------------------------------------===//
489 // TemplateArgumentLoc Implementation
490 //===----------------------------------------------------------------------===//
491 
493  switch (Argument.getKind()) {
496 
499 
502 
504  if (TypeSourceInfo *TSI = getTypeSourceInfo())
505  return TSI->getTypeLoc().getSourceRange();
506  else
507  return SourceRange();
508 
511  return SourceRange(getTemplateQualifierLoc().getBeginLoc(),
514 
517  return SourceRange(getTemplateQualifierLoc().getBeginLoc(),
520 
523 
526  return SourceRange();
527  }
528 
529  llvm_unreachable("Invalid TemplateArgument Kind!");
530 }
531 
532 template <typename T>
533 static const T &DiagTemplateArg(const T &DB, const TemplateArgument &Arg) {
534  switch (Arg.getKind()) {
536  // This is bad, but not as bad as crashing because of argument
537  // count mismatches.
538  return DB << "(null template argument)";
539 
541  return DB << Arg.getAsType();
542 
544  return DB << Arg.getAsDecl();
545 
547  return DB << "nullptr";
548 
550  return DB << toString(Arg.getAsIntegral(), 10);
551 
553  return DB << Arg.getAsTemplate();
554 
556  return DB << Arg.getAsTemplateOrTemplatePattern() << "...";
557 
559  // This shouldn't actually ever happen, so it's okay that we're
560  // regurgitating an expression here.
561  // FIXME: We're guessing at LangOptions!
562  SmallString<32> Str;
563  llvm::raw_svector_ostream OS(Str);
564  LangOptions LangOpts;
565  LangOpts.CPlusPlus = true;
566  PrintingPolicy Policy(LangOpts);
567  Arg.getAsExpr()->printPretty(OS, nullptr, Policy);
568  return DB << OS.str();
569  }
570 
571  case TemplateArgument::Pack: {
572  // FIXME: We're guessing at LangOptions!
573  SmallString<32> Str;
574  llvm::raw_svector_ostream OS(Str);
575  LangOptions LangOpts;
576  LangOpts.CPlusPlus = true;
577  PrintingPolicy Policy(LangOpts);
578  Arg.print(Policy, OS, /*IncludeType*/ true);
579  return DB << OS.str();
580  }
581  }
582 
583  llvm_unreachable("Invalid TemplateArgument Kind!");
584 }
585 
587  const TemplateArgument &Arg) {
588  return DiagTemplateArg(DB, Arg);
589 }
590 
592  ASTContext &Ctx, NestedNameSpecifierLoc QualifierLoc,
593  SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc) {
594  TemplateTemplateArgLocInfo *Template = new (Ctx) TemplateTemplateArgLocInfo;
595  Template->Qualifier = QualifierLoc.getNestedNameSpecifier();
596  Template->QualifierLocData = QualifierLoc.getOpaqueData();
597  Template->TemplateNameLoc = TemplateNameLoc;
598  Template->EllipsisLoc = EllipsisLoc;
599  Pointer = Template;
600 }
601 
604  const TemplateArgumentListInfo &List) {
605  std::size_t size = totalSizeToAlloc<TemplateArgumentLoc>(List.size());
606  void *Mem = C.Allocate(size, alignof(ASTTemplateArgumentListInfo));
607  return new (Mem) ASTTemplateArgumentListInfo(List);
608 }
609 
612  const ASTTemplateArgumentListInfo *List) {
613  if (!List)
614  return nullptr;
615  std::size_t size =
616  totalSizeToAlloc<TemplateArgumentLoc>(List->getNumTemplateArgs());
617  void *Mem = C.Allocate(size, alignof(ASTTemplateArgumentListInfo));
618  return new (Mem) ASTTemplateArgumentListInfo(List);
619 }
620 
621 ASTTemplateArgumentListInfo::ASTTemplateArgumentListInfo(
622  const TemplateArgumentListInfo &Info) {
623  LAngleLoc = Info.getLAngleLoc();
624  RAngleLoc = Info.getRAngleLoc();
625  NumTemplateArgs = Info.size();
626 
627  TemplateArgumentLoc *ArgBuffer = getTrailingObjects<TemplateArgumentLoc>();
628  for (unsigned i = 0; i != NumTemplateArgs; ++i)
629  new (&ArgBuffer[i]) TemplateArgumentLoc(Info[i]);
630 }
631 
632 ASTTemplateArgumentListInfo::ASTTemplateArgumentListInfo(
633  const ASTTemplateArgumentListInfo *Info) {
634  LAngleLoc = Info->getLAngleLoc();
635  RAngleLoc = Info->getRAngleLoc();
637 
638  TemplateArgumentLoc *ArgBuffer = getTrailingObjects<TemplateArgumentLoc>();
639  for (unsigned i = 0; i != NumTemplateArgs; ++i)
640  new (&ArgBuffer[i]) TemplateArgumentLoc((*Info)[i]);
641 }
642 
644  SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &Info,
645  TemplateArgumentLoc *OutArgArray) {
646  this->TemplateKWLoc = TemplateKWLoc;
647  LAngleLoc = Info.getLAngleLoc();
648  RAngleLoc = Info.getRAngleLoc();
649  NumTemplateArgs = Info.size();
650 
651  for (unsigned i = 0; i != NumTemplateArgs; ++i)
652  new (&OutArgArray[i]) TemplateArgumentLoc(Info[i]);
653 }
654 
656  assert(TemplateKWLoc.isValid());
659  this->TemplateKWLoc = TemplateKWLoc;
660  NumTemplateArgs = 0;
661 }
662 
664  SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &Info,
665  TemplateArgumentLoc *OutArgArray, TemplateArgumentDependence &Deps) {
666  this->TemplateKWLoc = TemplateKWLoc;
667  LAngleLoc = Info.getLAngleLoc();
668  RAngleLoc = Info.getRAngleLoc();
669  NumTemplateArgs = Info.size();
670 
671  for (unsigned i = 0; i != NumTemplateArgs; ++i) {
672  Deps |= Info[i].getArgument().getDependence();
673 
674  new (&OutArgArray[i]) TemplateArgumentLoc(Info[i]);
675  }
676 }
677 
679  TemplateArgumentListInfo &Info) const {
680  Info.setLAngleLoc(LAngleLoc);
681  Info.setRAngleLoc(RAngleLoc);
682  for (unsigned I = 0; I != NumTemplateArgs; ++I)
683  Info.addArgument(ArgArray[I]);
684 }
clang::BuiltinType
This class is used for builtin types like 'int'.
Definition: Type.h:2620
clang::TemplateName::Qualified::Fully
@ Fully
clang::CharacterLiteral::CharacterKind
CharacterKind
Definition: Expr.h:1595
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::TemplateArgument::getDependence
TemplateArgumentDependence getDependence() const
Definition: TemplateBase.cpp:191
clang::TemplateArgument::getAsTemplateOrTemplatePattern
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
Definition: TemplateBase.h:299
clang::ASTTemplateKWAndArgsInfo::RAngleLoc
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:671
clang::TemplateArgument::pack_elements
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:365
clang::TemplateArgument::Null
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:67
DependenceFlags.h
clang::TemplateArgumentLoc::getSourceExpression
Expr * getSourceExpression() const
Definition: TemplateBase.h:520
clang::Type::isCharType
bool isCharType() const
Definition: Type.cpp:1962
clang::TemplateArgumentLoc::getTemplateEllipsisLoc
SourceLocation getTemplateEllipsisLoc() const
Definition: TemplateBase.h:554
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::ASTTemplateKWAndArgsInfo::TemplateKWLoc
SourceLocation TemplateKWLoc
The source location of the template keyword; this is used as part of the representation of qualified ...
Definition: TemplateBase.h:677
clang::TemplateArgument::TemplateArg
struct TA TemplateArg
Definition: TemplateBase.h:145
clang::TemplateArgument::Profile
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
Definition: TemplateBase.cpp:307
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::TemplateArgument::getIntegralType
QualType getIntegralType() const
Retrieve the type of the integral value.
Definition: TemplateBase.h:326
clang::Type::isWideCharType
bool isWideCharType() const
Definition: Type.cpp:1971
needsAmpersandOnTemplateArg
static bool needsAmpersandOnTemplateArg(QualType paramType, QualType argType)
Definition: TemplateBase.cpp:148
clang::Stmt::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:324
clang::TemplateArgument::getParamTypeForDecl
QualType getParamTypeForDecl() const
Definition: TemplateBase.h:280
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:56
clang::TemplateArgumentLocInfo::TemplateArgumentLocInfo
TemplateArgumentLocInfo()
Definition: TemplateBase.h:424
clang::TemplateArgumentListInfo::getRAngleLoc
SourceLocation getRAngleLoc() const
Definition: TemplateBase.h:580
clang::ast_matchers::type
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchersInternal.cpp:773
memcpy
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Definition: __clang_cuda_device_functions.h:1549
clang::TemplateArgument::Declaration
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:74
llvm::Optional< unsigned >
clang::ComparisonCategoryType::First
@ First
clang::CharacterLiteral::UTF8
@ UTF8
Definition: Expr.h:1598
clang::ASTTemplateArgumentListInfo::getRAngleLoc
SourceLocation getRAngleLoc() const
Definition: TemplateBase.h:635
clang::QualType::getAsString
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Definition: Type.h:1088
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::ASTTemplateArgumentListInfo::NumTemplateArgs
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:632
clang::ASTTemplateKWAndArgsInfo::LAngleLoc
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:668
clang::TemplateArgument::getAsExpr
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:341
TemplateName.h
clang::TemplateArgumentLoc::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:514
clang::TemplateArgument::Expression
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:96
clang::TemplateArgument::getAsIntegral
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Definition: TemplateBase.h:312
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1565
Decl.h
clang::TemplateArgumentListInfo::getLAngleLoc
SourceLocation getLAngleLoc() const
Definition: TemplateBase.h:579
clang::TemplateArgument::Integral
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:82
size_t
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c-base.h:118
PrettyPrinter.h
clang::TemplateArgument::TypeOrValue
struct TV TypeOrValue
Definition: TemplateBase.h:146
clang::toTemplateArgumentDependence
TemplateArgumentDependence toTemplateArgumentDependence(TypeDependence D)
Definition: DependenceFlags.h:301
APSInt
llvm::APSInt APSInt
Definition: ByteCodeEmitter.cpp:19
clang::TemplateArgument::NullPtr
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:78
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:734
clang::TemplateArgumentLoc::getSourceDeclExpression
Expr * getSourceDeclExpression() const
Definition: TemplateBase.h:525
TemplateBase.h
clang::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:244
DeclTemplate.h
clang::PackExpansionType
Represents a pack expansion of types.
Definition: Type.h:5830
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:563
clang::CharacterLiteral::Wide
@ Wide
Definition: Expr.h:1597
clang::Stmt::printPretty
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Definition: StmtPrinter.cpp:2737
DeclBase.h
clang::TemplateArgumentListInfo::addArgument
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:603
hlsl::uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:25
clang::XRayInstrKind::None
constexpr XRayInstrMask None
Definition: XRayInstr.h:38
clang::Type::isAnyCharacterType
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
Definition: Type.cpp:1998
printIntegral
static void printIntegral(const TemplateArgument &TemplArg, raw_ostream &Out, const PrintingPolicy &Policy, bool IncludeType)
Print a template integral argument value.
Definition: TemplateBase.cpp:57
clang::TemplateArgument::getEmptyPack
static TemplateArgument getEmptyPack()
Definition: TemplateBase.h:236
clang::threadSafety::sx::toString
std::string toString(const til::SExpr *E)
Definition: ThreadSafetyCommon.h:91
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::StreamingDiagnostic
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Definition: Diagnostic.h:1110
LangOptions.h
Diagnostic.h
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7386
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:61
clang::Type::isChar8Type
bool isChar8Type() const
Definition: Type.cpp:1978
clang::RISCV::Policy
Policy
Definition: RISCVVIntrinsicUtils.h:96
clang::ASTTemplateKWAndArgsInfo::initializeFrom
void initializeFrom(SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &List, TemplateArgumentLoc *OutArgArray)
Definition: TemplateBase.cpp:643
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:457
clang::TemplateArgumentLoc::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Definition: TemplateBase.cpp:492
Type.h
Expr.h
llvm::SmallString< 32 >
clang::TemplateArgumentListInfo::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:582
ASTContext.h
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:625
clang::Type::getCanonicalTypeInternal
QualType getCanonicalTypeInternal() const
Definition: Type.h:2584
clang::TemplateArgument::CreatePackCopy
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
Definition: TemplateBase.cpp:183
clang::EnumConstantDecl
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3145
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::Stmt::Profile
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
Definition: StmtProfile.cpp:2369
ExprCXX.h
clang::TemplateArgument::isPackExpansion
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
Definition: TemplateBase.cpp:247
clang::operator<<
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Definition: ASTContext.cpp:13400
clang::ast_matchers::arrayType
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
Definition: ASTMatchersInternal.cpp:1035
clang::TemplateArgument::getNonTypeTemplateArgumentType
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
Definition: TemplateBase.cpp:282
clang::CharacterLiteral::Ascii
@ Ascii
Definition: Expr.h:1596
clang::TemplateArgument::TemplateExpansion
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:90
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7453
clang::NestedNameSpecifierLoc::getOpaqueData
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
Definition: NestedNameSpecifier.h:279
SourceLocation.h
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::CharacterLiteral::UTF16
@ UTF16
Definition: Expr.h:1599
clang::Type::isMemberPointerType
bool isMemberPointerType() const
Definition: Type.h:6931
clang::TemplateArgument::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
Definition: TemplateBase.cpp:270
clang::Type::isPointerType
bool isPointerType() const
Definition: Type.h:6883
clang::ASTTemplateArgumentListInfo::LAngleLoc
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:626
clang::TemplateArgument::Args
struct A Args
Definition: TemplateBase.h:144
clang::TemplateArgumentListInfo::size
unsigned size() const
Definition: TemplateBase.h:585
clang::TemplateArgumentLoc::getSourceIntegralExpression
Expr * getSourceIntegralExpression() const
Definition: TemplateBase.h:535
clang::TemplateArgument::dump
void dump() const
Debugging aid that dumps the template argument to standard error.
Definition: TemplateBase.cpp:486
llvm::ArrayRef< TemplateArgument >
clang::ASTTemplateArgumentListInfo::getLAngleLoc
SourceLocation getLAngleLoc() const
Definition: TemplateBase.h:634
Value
Value
Definition: UninitializedValues.cpp:103
getArrayDepth
static unsigned getArrayDepth(QualType type)
Definition: TemplateBase.cpp:139
clang::TemplateArgument::getNumTemplateExpansions
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
Definition: TemplateBase.cpp:274
clang::TemplateArgument::isDependent
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
Definition: TemplateBase.cpp:239
LLVM.h
clang::TemplateArgument::isInstantiationDependent
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
Definition: TemplateBase.cpp:243
clang::PrintingPolicy::SuppressStrongLifetime
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Definition: PrettyPrinter.h:179
clang::TemplateArgument::TemplateArgument
constexpr TemplateArgument()
Construct an empty, invalid template argument.
Definition: TemplateBase.h:151
clang::TemplateArgumentLoc::getSourceNullPtrExpression
Expr * getSourceNullPtrExpression() const
Definition: TemplateBase.h:530
clang::ASTTemplateArgumentListInfo::getNumTemplateArgs
unsigned getNumTemplateArgs() const
Definition: TemplateBase.h:641
DiagTemplateArg
static const T & DiagTemplateArg(const T &DB, const TemplateArgument &Arg)
Definition: TemplateBase.cpp:533
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:81
clang::Type::isBooleanType
bool isBooleanType() const
Definition: Type.h:7296
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::ASTTemplateKWAndArgsInfo::copyInto
void copyInto(const TemplateArgumentLoc *ArgArray, TemplateArgumentListInfo &List) const
Definition: TemplateBase.cpp:678
clang::TemplateArgument::getAsDecl
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:275
isRecordType
static bool isRecordType(QualType T)
Definition: SemaExprMember.cpp:1216
clang::TemplateArgument::print
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
Definition: TemplateBase.cpp:409
clang::TemplateName::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
Definition: TemplateName.cpp:285
clang::QualType::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: Type.h:1154
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::TemplateArgument::Type
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
clang
Definition: CalledOnceCheck.h:17
clang::TemplateArgumentListInfo::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:583
clang::TemplateName::Profile
void Profile(llvm::FoldingSetNodeID &ID)
Definition: TemplateName.h:353
clang::TemplateArgument::getPackExpansionPattern
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
Definition: TemplateBase.cpp:384
clang::Type::isArrayType
bool isArrayType() const
Definition: Type.h:6949
clang::CharacterLiteral::UTF32
@ UTF32
Definition: Expr.h:1600
clang::TemplateArgument::getNullPtrType
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Definition: TemplateBase.h:286
clang::TemplateArgument::Template
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:86
clang::TemplateArgument::getAsTemplate
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:292
clang::NestedNameSpecifierLoc::getNestedNameSpecifier
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Definition: NestedNameSpecifier.h:274
clang::Expr::getType
QualType getType() const
Definition: Expr.h:141
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6593
clang::ASTTemplateArgumentListInfo::Create
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
Definition: TemplateBase.cpp:603
clang::ASTTemplateKWAndArgsInfo::NumTemplateArgs
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:680
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6622
clang::QualType::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: TypePrinter.cpp:2320
GCCTypeClass::Pointer
@ Pointer
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:612
clang::TemplateArgumentLoc::getTemplateQualifierLoc
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:540
clang::Type::isSpecificBuiltinType
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Definition: Type.h:7149
clang::TemplateArgumentLoc::getTemplateNameLoc
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:547
clang::EnumType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:4842
clang::NamedDecl::printQualifiedName
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:1633
clang::Type::isChar16Type
bool isChar16Type() const
Definition: Type.cpp:1984
GCCTypeClass::None
@ None
clang::ASTTemplateArgumentListInfo::RAngleLoc
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:629
clang::TemplateArgument::Integer
struct I Integer
Definition: TemplateBase.h:143
clang::Type::isChar32Type
bool isChar32Type() const
Definition: Type.cpp:1990
clang::TemplateArgument::structurallyEquals
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
Definition: TemplateBase.cpp:350
TypeLoc.h
clang::TemplateArgument::getAsType
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:268
clang::CharacterLiteral::print
static void print(unsigned val, CharacterKind Kind, raw_ostream &OS)
Definition: Expr.cpp:1027
clang::TemplateArgument::Pack
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:100
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:441