clang  14.0.0git
TypeLoc.cpp
Go to the documentation of this file.
1 //===- TypeLoc.cpp - Type Source Info Wrapper -----------------------------===//
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 defines the TypeLoc subclasses implementations.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/TypeLoc.h"
14 #include "clang/AST/DeclTemplate.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Attr.h"
17 #include "clang/AST/Expr.h"
19 #include "clang/AST/TemplateBase.h"
20 #include "clang/AST/TemplateName.h"
23 #include "clang/Basic/Specifiers.h"
24 #include "llvm/Support/ErrorHandling.h"
25 #include "llvm/Support/MathExtras.h"
26 #include <algorithm>
27 #include <cassert>
28 #include <cstdint>
29 #include <cstring>
30 
31 using namespace clang;
32 
33 static const unsigned TypeLocMaxDataAlign = alignof(void *);
34 
35 //===----------------------------------------------------------------------===//
36 // TypeLoc Implementation
37 //===----------------------------------------------------------------------===//
38 
39 namespace {
40 
41 class TypeLocRanger : public TypeLocVisitor<TypeLocRanger, SourceRange> {
42 public:
43 #define ABSTRACT_TYPELOC(CLASS, PARENT)
44 #define TYPELOC(CLASS, PARENT) \
45  SourceRange Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
46  return TyLoc.getLocalSourceRange(); \
47  }
48 #include "clang/AST/TypeLocNodes.def"
49 };
50 
51 } // namespace
52 
53 SourceRange TypeLoc::getLocalSourceRangeImpl(TypeLoc TL) {
54  if (TL.isNull()) return SourceRange();
55  return TypeLocRanger().Visit(TL);
56 }
57 
58 namespace {
59 
60 class TypeAligner : public TypeLocVisitor<TypeAligner, unsigned> {
61 public:
62 #define ABSTRACT_TYPELOC(CLASS, PARENT)
63 #define TYPELOC(CLASS, PARENT) \
64  unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
65  return TyLoc.getLocalDataAlignment(); \
66  }
67 #include "clang/AST/TypeLocNodes.def"
68 };
69 
70 } // namespace
71 
72 /// Returns the alignment of the type source info data block.
74  if (Ty.isNull()) return 1;
75  return TypeAligner().Visit(TypeLoc(Ty, nullptr));
76 }
77 
78 namespace {
79 
80 class TypeSizer : public TypeLocVisitor<TypeSizer, unsigned> {
81 public:
82 #define ABSTRACT_TYPELOC(CLASS, PARENT)
83 #define TYPELOC(CLASS, PARENT) \
84  unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
85  return TyLoc.getLocalDataSize(); \
86  }
87 #include "clang/AST/TypeLocNodes.def"
88 };
89 
90 } // namespace
91 
92 /// Returns the size of the type source info data block.
94  unsigned Total = 0;
95  TypeLoc TyLoc(Ty, nullptr);
96  unsigned MaxAlign = 1;
97  while (!TyLoc.isNull()) {
98  unsigned Align = getLocalAlignmentForType(TyLoc.getType());
99  MaxAlign = std::max(Align, MaxAlign);
100  Total = llvm::alignTo(Total, Align);
101  Total += TypeSizer().Visit(TyLoc);
102  TyLoc = TyLoc.getNextTypeLoc();
103  }
104  Total = llvm::alignTo(Total, MaxAlign);
105  return Total;
106 }
107 
108 namespace {
109 
110 class NextLoc : public TypeLocVisitor<NextLoc, TypeLoc> {
111 public:
112 #define ABSTRACT_TYPELOC(CLASS, PARENT)
113 #define TYPELOC(CLASS, PARENT) \
114  TypeLoc Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
115  return TyLoc.getNextTypeLoc(); \
116  }
117 #include "clang/AST/TypeLocNodes.def"
118 };
119 
120 } // namespace
121 
122 /// Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
123 /// TypeLoc is a PointerLoc and next TypeLoc is for "int".
124 TypeLoc TypeLoc::getNextTypeLocImpl(TypeLoc TL) {
125  return NextLoc().Visit(TL);
126 }
127 
128 /// Initializes a type location, and all of its children
129 /// recursively, as if the entire tree had been written in the
130 /// given location.
131 void TypeLoc::initializeImpl(ASTContext &Context, TypeLoc TL,
132  SourceLocation Loc) {
133  while (true) {
134  switch (TL.getTypeLocClass()) {
135 #define ABSTRACT_TYPELOC(CLASS, PARENT)
136 #define TYPELOC(CLASS, PARENT) \
137  case CLASS: { \
138  CLASS##TypeLoc TLCasted = TL.castAs<CLASS##TypeLoc>(); \
139  TLCasted.initializeLocal(Context, Loc); \
140  TL = TLCasted.getNextTypeLoc(); \
141  if (!TL) return; \
142  continue; \
143  }
144 #include "clang/AST/TypeLocNodes.def"
145  }
146  }
147 }
148 
149 namespace {
150 
151 class TypeLocCopier : public TypeLocVisitor<TypeLocCopier> {
152  TypeLoc Source;
153 
154 public:
155  TypeLocCopier(TypeLoc source) : Source(source) {}
156 
157 #define ABSTRACT_TYPELOC(CLASS, PARENT)
158 #define TYPELOC(CLASS, PARENT) \
159  void Visit##CLASS##TypeLoc(CLASS##TypeLoc dest) { \
160  dest.copyLocal(Source.castAs<CLASS##TypeLoc>()); \
161  }
162 #include "clang/AST/TypeLocNodes.def"
163 };
164 
165 } // namespace
166 
167 void TypeLoc::copy(TypeLoc other) {
168  assert(getFullDataSize() == other.getFullDataSize());
169 
170  // If both data pointers are aligned to the maximum alignment, we
171  // can memcpy because getFullDataSize() accurately reflects the
172  // layout of the data.
173  if (reinterpret_cast<uintptr_t>(Data) ==
174  llvm::alignTo(reinterpret_cast<uintptr_t>(Data),
176  reinterpret_cast<uintptr_t>(other.Data) ==
177  llvm::alignTo(reinterpret_cast<uintptr_t>(other.Data),
179  memcpy(Data, other.Data, getFullDataSize());
180  return;
181  }
182 
183  // Copy each of the pieces.
184  TypeLoc TL(getType(), Data);
185  do {
186  TypeLocCopier(other).Visit(TL);
187  other = other.getNextTypeLoc();
188  } while ((TL = TL.getNextTypeLoc()));
189 }
190 
192  TypeLoc Cur = *this;
193  TypeLoc LeftMost = Cur;
194  while (true) {
195  switch (Cur.getTypeLocClass()) {
196  case Elaborated:
197  LeftMost = Cur;
198  break;
199  case FunctionProto:
201  ->hasTrailingReturn()) {
202  LeftMost = Cur;
203  break;
204  }
205  LLVM_FALLTHROUGH;
206  case FunctionNoProto:
207  case ConstantArray:
208  case DependentSizedArray:
209  case IncompleteArray:
210  case VariableArray:
211  // FIXME: Currently QualifiedTypeLoc does not have a source range
212  case Qualified:
213  Cur = Cur.getNextTypeLoc();
214  continue;
215  default:
216  if (Cur.getLocalSourceRange().getBegin().isValid())
217  LeftMost = Cur;
218  Cur = Cur.getNextTypeLoc();
219  if (Cur.isNull())
220  break;
221  continue;
222  } // switch
223  break;
224  } // while
225  return LeftMost.getLocalSourceRange().getBegin();
226 }
227 
229  TypeLoc Cur = *this;
230  TypeLoc Last;
231  while (true) {
232  switch (Cur.getTypeLocClass()) {
233  default:
234  if (!Last)
235  Last = Cur;
236  return Last.getLocalSourceRange().getEnd();
237  case Paren:
238  case ConstantArray:
239  case DependentSizedArray:
240  case IncompleteArray:
241  case VariableArray:
242  case FunctionNoProto:
243  // The innermost type with suffix syntax always determines the end of the
244  // type.
245  Last = Cur;
246  break;
247  case FunctionProto:
249  Last = TypeLoc();
250  else
251  Last = Cur;
252  break;
253  case ObjCObjectPointer:
254  // `id` and `id<...>` have no star location.
256  break;
257  LLVM_FALLTHROUGH;
258  case Pointer:
259  case BlockPointer:
260  case MemberPointer:
261  case LValueReference:
262  case RValueReference:
263  case PackExpansion:
264  // Types with prefix syntax only determine the end of the type if there
265  // is no suffix type.
266  if (!Last)
267  Last = Cur;
268  break;
269  case Qualified:
270  case Elaborated:
271  break;
272  }
273  Cur = Cur.getNextTypeLoc();
274  }
275 }
276 
277 namespace {
278 
279 struct TSTChecker : public TypeLocVisitor<TSTChecker, bool> {
280  // Overload resolution does the real work for us.
281  static bool isTypeSpec(TypeSpecTypeLoc _) { return true; }
282  static bool isTypeSpec(TypeLoc _) { return false; }
283 
284 #define ABSTRACT_TYPELOC(CLASS, PARENT)
285 #define TYPELOC(CLASS, PARENT) \
286  bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
287  return isTypeSpec(TyLoc); \
288  }
289 #include "clang/AST/TypeLocNodes.def"
290 };
291 
292 } // namespace
293 
294 /// Determines if the given type loc corresponds to a
295 /// TypeSpecTypeLoc. Since there is not actually a TypeSpecType in
296 /// the type hierarchy, this is made somewhat complicated.
297 ///
298 /// There are a lot of types that currently use TypeSpecTypeLoc
299 /// because it's a convenient base class. Ideally we would not accept
300 /// those here, but ideally we would have better implementations for
301 /// them.
302 bool TypeSpecTypeLoc::isKind(const TypeLoc &TL) {
303  if (TL.getType().hasLocalQualifiers()) return false;
304  return TSTChecker().Visit(TL);
305 }
306 
308  TagDecl *D = getDecl();
309  return D->isCompleteDefinition() &&
310  (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
311 }
312 
313 // Reimplemented to account for GNU/C++ extension
314 // typeof unary-expression
315 // where there are no parentheses.
317  if (getRParenLoc().isValid())
319  else
320  return SourceRange(getTypeofLoc(),
321  getUnderlyingExpr()->getSourceRange().getEnd());
322 }
323 
324 
326  if (needsExtraLocalData())
327  return static_cast<TypeSpecifierType>(getWrittenBuiltinSpecs().Type);
328  switch (getTypePtr()->getKind()) {
329  case BuiltinType::Void:
330  return TST_void;
331  case BuiltinType::Bool:
332  return TST_bool;
333  case BuiltinType::Char_U:
334  case BuiltinType::Char_S:
335  return TST_char;
336  case BuiltinType::Char8:
337  return TST_char8;
338  case BuiltinType::Char16:
339  return TST_char16;
340  case BuiltinType::Char32:
341  return TST_char32;
342  case BuiltinType::WChar_S:
343  case BuiltinType::WChar_U:
344  return TST_wchar;
345  case BuiltinType::UChar:
346  case BuiltinType::UShort:
347  case BuiltinType::UInt:
348  case BuiltinType::ULong:
349  case BuiltinType::ULongLong:
350  case BuiltinType::UInt128:
351  case BuiltinType::SChar:
352  case BuiltinType::Short:
353  case BuiltinType::Int:
354  case BuiltinType::Long:
355  case BuiltinType::LongLong:
356  case BuiltinType::Int128:
357  case BuiltinType::Half:
358  case BuiltinType::Float:
359  case BuiltinType::Double:
360  case BuiltinType::LongDouble:
361  case BuiltinType::Float16:
362  case BuiltinType::Float128:
363  case BuiltinType::Ibm128:
364  case BuiltinType::ShortAccum:
365  case BuiltinType::Accum:
366  case BuiltinType::LongAccum:
367  case BuiltinType::UShortAccum:
368  case BuiltinType::UAccum:
369  case BuiltinType::ULongAccum:
370  case BuiltinType::ShortFract:
371  case BuiltinType::Fract:
372  case BuiltinType::LongFract:
373  case BuiltinType::UShortFract:
374  case BuiltinType::UFract:
375  case BuiltinType::ULongFract:
376  case BuiltinType::SatShortAccum:
377  case BuiltinType::SatAccum:
378  case BuiltinType::SatLongAccum:
379  case BuiltinType::SatUShortAccum:
380  case BuiltinType::SatUAccum:
381  case BuiltinType::SatULongAccum:
382  case BuiltinType::SatShortFract:
383  case BuiltinType::SatFract:
384  case BuiltinType::SatLongFract:
385  case BuiltinType::SatUShortFract:
386  case BuiltinType::SatUFract:
387  case BuiltinType::SatULongFract:
388  case BuiltinType::BFloat16:
389  llvm_unreachable("Builtin type needs extra local data!");
390  // Fall through, if the impossible happens.
391 
392  case BuiltinType::NullPtr:
393  case BuiltinType::Overload:
394  case BuiltinType::Dependent:
395  case BuiltinType::BoundMember:
396  case BuiltinType::UnknownAny:
397  case BuiltinType::ARCUnbridgedCast:
398  case BuiltinType::PseudoObject:
399  case BuiltinType::ObjCId:
400  case BuiltinType::ObjCClass:
401  case BuiltinType::ObjCSel:
402 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
403  case BuiltinType::Id:
404 #include "clang/Basic/OpenCLImageTypes.def"
405 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
406  case BuiltinType::Id:
407 #include "clang/Basic/OpenCLExtensionTypes.def"
408  case BuiltinType::OCLSampler:
409  case BuiltinType::OCLEvent:
410  case BuiltinType::OCLClkEvent:
411  case BuiltinType::OCLQueue:
412  case BuiltinType::OCLReserveID:
413 #define SVE_TYPE(Name, Id, SingletonId) \
414  case BuiltinType::Id:
415 #include "clang/Basic/AArch64SVEACLETypes.def"
416 #define PPC_VECTOR_TYPE(Name, Id, Size) \
417  case BuiltinType::Id:
418 #include "clang/Basic/PPCTypes.def"
419 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
420 #include "clang/Basic/RISCVVTypes.def"
421  case BuiltinType::BuiltinFn:
422  case BuiltinType::IncompleteMatrixIdx:
423  case BuiltinType::OMPArraySection:
424  case BuiltinType::OMPArrayShaping:
425  case BuiltinType::OMPIterator:
426  return TST_unspecified;
427  }
428 
429  llvm_unreachable("Invalid BuiltinType Kind!");
430 }
431 
432 TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) {
433  while (ParenTypeLoc PTL = TL.getAs<ParenTypeLoc>())
434  TL = PTL.getInnerLoc();
435  return TL;
436 }
437 
439  if (auto ATL = getAs<AttributedTypeLoc>()) {
440  const Attr *A = ATL.getAttr();
441  if (A && (isa<TypeNullableAttr>(A) || isa<TypeNonNullAttr>(A) ||
442  isa<TypeNullUnspecifiedAttr>(A)))
443  return A->getLocation();
444  }
445 
446  return {};
447 }
448 
450  // Qualified types.
451  if (auto qual = getAs<QualifiedTypeLoc>())
452  return qual;
453 
454  TypeLoc loc = IgnoreParens();
455 
456  // Attributed types.
457  if (auto attr = loc.getAs<AttributedTypeLoc>()) {
458  if (attr.isQualifier()) return attr;
459  return attr.getModifiedLoc().findExplicitQualifierLoc();
460  }
461 
462  // C11 _Atomic types.
463  if (auto atomic = loc.getAs<AtomicTypeLoc>()) {
464  return atomic;
465  }
466 
467  return {};
468 }
469 
471  SourceLocation Loc) {
472  setNameLoc(Loc);
473  if (!getNumProtocols()) return;
474 
477  for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
478  setProtocolLoc(i, Loc);
479 }
480 
482  SourceLocation Loc) {
486  for (unsigned i = 0, e = getNumTypeArgs(); i != e; ++i) {
487  setTypeArgTInfo(i,
488  Context.getTrivialTypeSourceInfo(
489  getTypePtr()->getTypeArgsAsWritten()[i], Loc));
490  }
493  for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
494  setProtocolLoc(i, Loc);
495 }
496 
498  // Note that this does *not* include the range of the attribute
499  // enclosure, e.g.:
500  // __attribute__((foo(bar)))
501  // ^~~~~~~~~~~~~~~ ~~
502  // or
503  // [[foo(bar)]]
504  // ^~ ~~
505  // That enclosure doesn't necessarily belong to a single attribute
506  // anyway.
507  return getAttr() ? getAttr()->getRange() : SourceRange();
508 }
509 
511  SourceLocation Loc) {
513  ::initializeLocal(Context, Loc);
515  getUnderlyingType(), Loc);
516 }
517 
519  SourceLocation Loc) {
520  setKWLoc(Loc);
521  setRParenLoc(Loc);
522  setLParenLoc(Loc);
523  this->setUnderlyingTInfo(
524  Context.getTrivialTypeSourceInfo(getTypePtr()->getBaseType(), Loc));
525 }
526 
528  SourceLocation Loc) {
531  Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
532  setQualifierLoc(Builder.getWithLocInContext(Context));
533 }
534 
536  SourceLocation Loc) {
539  Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
540  setQualifierLoc(Builder.getWithLocInContext(Context));
541  setNameLoc(Loc);
542 }
543 
544 void
546  SourceLocation Loc) {
548  if (getTypePtr()->getQualifier()) {
550  Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
551  setQualifierLoc(Builder.getWithLocInContext(Context));
552  } else {
554  }
556  setTemplateNameLoc(Loc);
557  setLAngleLoc(Loc);
558  setRAngleLoc(Loc);
560  getTypePtr()->getArgs(),
561  getArgInfos(), Loc);
562 }
563 
565  unsigned NumArgs,
566  const TemplateArgument *Args,
567  TemplateArgumentLocInfo *ArgInfos,
568  SourceLocation Loc) {
569  for (unsigned i = 0, e = NumArgs; i != e; ++i) {
570  switch (Args[i].getKind()) {
572  llvm_unreachable("Impossible TemplateArgument");
573 
577  ArgInfos[i] = TemplateArgumentLocInfo();
578  break;
579 
581  ArgInfos[i] = TemplateArgumentLocInfo(Args[i].getAsExpr());
582  break;
583 
585  ArgInfos[i] = TemplateArgumentLocInfo(
586  Context.getTrivialTypeSourceInfo(Args[i].getAsType(),
587  Loc));
588  break;
589 
593  TemplateName Template = Args[i].getAsTemplateOrTemplatePattern();
595  Builder.MakeTrivial(Context, DTN->getQualifier(), Loc);
596  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
597  Builder.MakeTrivial(Context, QTN->getQualifier(), Loc);
598 
599  ArgInfos[i] = TemplateArgumentLocInfo(
600  Context, Builder.getWithLocInContext(Context), Loc,
602  : Loc);
603  break;
604  }
605 
607  ArgInfos[i] = TemplateArgumentLocInfo();
608  break;
609  }
610  }
611 }
612 
614  return DeclarationNameInfo(getNamedConcept()->getDeclName(),
615  getLocalData()->ConceptNameLoc);
616 }
617 
620  setTemplateKWLoc(Loc);
621  setConceptNameLoc(Loc);
622  setFoundDecl(nullptr);
623  setRAngleLoc(Loc);
624  setLAngleLoc(Loc);
625  setRParenLoc(Loc);
627  getTypePtr()->getArgs(),
628  getArgInfos(), Loc);
629  setNameLoc(Loc);
630 }
631 
632 
633 namespace {
634 
635  class GetContainedAutoTypeLocVisitor :
636  public TypeLocVisitor<GetContainedAutoTypeLocVisitor, TypeLoc> {
637  public:
639 
640  TypeLoc VisitAutoTypeLoc(AutoTypeLoc TL) {
641  return TL;
642  }
643 
644  // Only these types can contain the desired 'auto' type.
645 
646  TypeLoc VisitElaboratedTypeLoc(ElaboratedTypeLoc T) {
647  return Visit(T.getNamedTypeLoc());
648  }
649 
650  TypeLoc VisitQualifiedTypeLoc(QualifiedTypeLoc T) {
651  return Visit(T.getUnqualifiedLoc());
652  }
653 
654  TypeLoc VisitPointerTypeLoc(PointerTypeLoc T) {
655  return Visit(T.getPointeeLoc());
656  }
657 
658  TypeLoc VisitBlockPointerTypeLoc(BlockPointerTypeLoc T) {
659  return Visit(T.getPointeeLoc());
660  }
661 
662  TypeLoc VisitReferenceTypeLoc(ReferenceTypeLoc T) {
663  return Visit(T.getPointeeLoc());
664  }
665 
666  TypeLoc VisitMemberPointerTypeLoc(MemberPointerTypeLoc T) {
667  return Visit(T.getPointeeLoc());
668  }
669 
670  TypeLoc VisitArrayTypeLoc(ArrayTypeLoc T) {
671  return Visit(T.getElementLoc());
672  }
673 
674  TypeLoc VisitFunctionTypeLoc(FunctionTypeLoc T) {
675  return Visit(T.getReturnLoc());
676  }
677 
678  TypeLoc VisitParenTypeLoc(ParenTypeLoc T) {
679  return Visit(T.getInnerLoc());
680  }
681 
682  TypeLoc VisitAttributedTypeLoc(AttributedTypeLoc T) {
683  return Visit(T.getModifiedLoc());
684  }
685 
686  TypeLoc VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc T) {
687  return Visit(T.getInnerLoc());
688  }
689 
690  TypeLoc VisitAdjustedTypeLoc(AdjustedTypeLoc T) {
691  return Visit(T.getOriginalLoc());
692  }
693 
694  TypeLoc VisitPackExpansionTypeLoc(PackExpansionTypeLoc T) {
695  return Visit(T.getPatternLoc());
696  }
697  };
698 
699 } // namespace
700 
702  TypeLoc Res = GetContainedAutoTypeLocVisitor().Visit(*this);
703  if (Res.isNull())
704  return AutoTypeLoc();
705  return Res.getAs<AutoTypeLoc>();
706 }
clang::DependentTemplateSpecializationTypeLoc::setTemplateKeywordLoc
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2394
clang::TypeLoc::Data
void * Data
Definition: TypeLoc.h:63
clang::ObjCObjectPointerTypeLoc
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1303
clang::ParenTypeLoc::getInnerLoc
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1151
clang::AutoTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:618
max
__DEVICE__ int max(int __a, int __b)
Definition: __clang_cuda_math.h:196
clang::FunctionProtoType::hasTrailingReturn
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:4234
clang::TST_char8
@ TST_char8
Definition: Specifiers.h:57
clang::TST_bool
@ TST_bool
Definition: Specifiers.h:72
Specifiers.h
clang::BlockPointerTypeLoc
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1248
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::DependentTemplateSpecializationTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:545
clang::PointerTypeLoc
Wrapper for source info for pointers.
Definition: TypeLoc.h:1235
clang::TypeLoc::copy
void copy(TypeLoc other)
Copies the other type loc into this one.
Definition: TypeLoc.cpp:167
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::ConcreteTypeLoc< UnqualTypeLoc, TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo >::getLocalData
TypeOfTypeLocInfo * getLocalData() const
Definition: TypeLoc.h:422
clang::ReferenceTypeLoc
Definition: TypeLoc.h:1316
clang::TST_unspecified
@ TST_unspecified
Definition: Specifiers.h:53
clang::TemplateArgument::Null
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:67
clang::AutoTypeLoc::setFoundDecl
void setFoundDecl(NamedDecl *D)
Definition: TypeLoc.h:2137
clang::BuiltinTypeLoc::getWrittenTypeSpec
TypeSpecifierType getWrittenTypeSpec() const
Definition: TypeLoc.cpp:325
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::Attr::getLocation
SourceLocation getLocation() const
Definition: Attr.h:88
clang::TST_void
@ TST_void
Definition: Specifiers.h:54
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:674
Attr.h
clang::ObjCObjectTypeLoc::setTypeArgTInfo
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:958
TypeLocMaxDataAlign
static const unsigned TypeLocMaxDataAlign
Definition: TypeLoc.cpp:33
TypeLocVisitor.h
clang::DependentTemplateSpecializationTypeLoc::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2418
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
clang::TagTypeLoc::isDefinition
bool isDefinition() const
True if the tag was defined in this type specifier.
Definition: TypeLoc.cpp:307
clang::TypeLoc::getFullDataSizeForType
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
Definition: TypeLoc.cpp:93
clang::AttributedTypeLoc::getAttr
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:882
clang::TypeLoc::getEndLoc
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:228
clang::TypeSpecTypeLoc::getNameLoc
SourceLocation getNameLoc() const
Definition: TypeLoc.h:523
clang::ArrayTypeLoc::getElementLoc
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1526
clang::ObjCTypeParamTypeLoc::setNameLoc
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:773
clang::ConcreteTypeLoc< UnqualTypeLoc, BuiltinTypeLoc, BuiltinType, BuiltinLocInfo >::getTypePtr
const BuiltinType * getTypePtr() const
Definition: TypeLoc.h:409
clang::ObjCTypeParamTypeLoc::setProtocolLoc
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:806
clang::ObjCObjectTypeLoc::setProtocolLoc
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:988
TemplateName.h
clang::ObjCObjectPointerTypeLoc::getStarLoc
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1307
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::DependentNameTypeLoc::setElaboratedKeywordLoc
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2305
Paren
@ Paren
Definition: PPMacroExpansion.cpp:630
clang::ObjCTypeParamTypeLoc::setProtocolRAngleLoc
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:793
clang::ObjCObjectTypeLoc::setProtocolLAngleLoc
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:967
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
clang::TypeLoc::getBeginLoc
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
clang::FunctionTypeLoc
Wrapper for source info for functions.
Definition: TypeLoc.h:1360
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::TypeOfTypeLocInfo::UnderlyingTInfo
TypeSourceInfo * UnderlyingTInfo
Definition: TypeLoc.h:1914
clang::ObjCObjectTypeLoc::setHasBaseTypeAsWritten
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:1007
clang::PackExpansionTypeLoc
Definition: TypeLoc.h:2475
TemplateBase.h
clang::TypeofLikeTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1958
clang::ast_matchers::attr
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
Definition: ASTMatchersInternal.cpp:1030
clang::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:244
DeclTemplate.h
clang::QualifiedTypeLoc
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition: TypeLoc.h:277
clang::DependentTemplateSpecializationTypeLoc::setQualifierLoc
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2374
clang::AtomicTypeLoc
Definition: TypeLoc.h:2508
clang::AutoTypeLoc::setTemplateKWLoc
void setTemplateKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2121
clang::ObjCTypeParamTypeLoc::getNumProtocols
unsigned getNumProtocols() const
Definition: TypeLoc.h:797
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::TagTypeLoc::getDecl
TagDecl * getDecl() const
Definition: TypeLoc.h:720
NestedNameSpecifier.h
clang::ParenTypeLoc
Definition: TypeLoc.h:1122
clang::AutoTypeLoc::setRParenLoc
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2103
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:61
clang::AutoTypeLoc::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2163
clang::MacroQualifiedTypeLoc::getInnerLoc
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1096
clang::TypeLoc::getContainedAutoTypeLoc
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
Definition: TypeLoc.cpp:701
clang::WrittenBuiltinSpecs::Type
unsigned Type
Definition: Specifiers.h:99
uintptr_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c-base.h:124
Expr.h
ASTContext.h
clang::ObjCObjectTypeLoc::getNumProtocols
unsigned getNumProtocols() const
Definition: TypeLoc.h:979
clang::TypeOfTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:510
clang::DependentNameTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:535
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3331
clang::ObjCTypeParamTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:470
clang::TST_char
@ TST_char
Definition: Specifiers.h:55
clang::UnaryTransformTypeLoc::setUnderlyingTInfo
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:2053
clang::UnaryTransformTypeLoc::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2044
clang::AttributedTypeLoc
Type source information for an attributed type.
Definition: TypeLoc.h:860
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::TypeLoc::isNull
bool isNull() const
Definition: TypeLoc.h:120
clang::BuiltinTypeLoc::needsExtraLocalData
bool needsExtraLocalData() const
Definition: TypeLoc.h:582
clang::MemberPointerTypeLoc
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1265
clang::TagDecl::isCompleteDefinition
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3436
clang::DependentTemplateSpecializationTypeLoc::setTemplateNameLoc
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2402
clang::AdjustedTypeLoc
Definition: TypeLoc.h:1168
clang::NestedNameSpecifierLocBuilder
Class that aids in the construction of nested-name-specifiers along with source-location information ...
Definition: NestedNameSpecifier.h:356
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:998
clang::DependentTemplateSpecializationTypeLoc::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2410
clang::TypeLoc::findNullabilityLoc
SourceLocation findNullabilityLoc() const
Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier),...
Definition: TypeLoc.cpp:438
clang::DependentTemplateSpecializationTypeLoc::setElaboratedKeywordLoc
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2362
clang::UnaryTransformTypeLoc::setKWLoc
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2041
clang::AutoTypeLoc
Definition: TypeLoc.h:2091
clang::AttributedTypeLoc::getModifiedLoc
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:877
clang::AutoTypeLoc::getConceptNameInfo
DeclarationNameInfo getConceptNameInfo() const
Definition: TypeLoc.cpp:613
clang::TypeLoc::TypeLoc
TypeLoc()=default
clang::DependentTemplateName
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:446
clang::ObjCTypeParamTypeLoc::setProtocolLAngleLoc
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:783
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::TemplateName::getAsQualifiedTemplateName
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Definition: TemplateName.cpp:148
clang::DependentNameTypeLoc::setQualifierLoc
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2314
clang::AutoTypeLoc::setConceptNameLoc
void setConceptNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2129
SourceLocation.h
clang::TypeLoc::getLocalSourceRange
SourceRange getLocalSourceRange() const
Get the local source range.
Definition: TypeLoc.h:158
clang::UnaryTransformTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:518
clang::AttributeCommonInfo::getRange
SourceRange getRange() const
Definition: AttributeCommonInfo.h:130
clang::ElaboratedTypeLoc::getNamedTypeLoc
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2275
clang::TypeLoc::getFullDataSize
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:163
clang::ObjCObjectTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:481
clang::AttributedTypeLoc::getLocalSourceRange
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:497
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:268
clang::TypeSpecTypeLoc
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
Definition: TypeLoc.h:513
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:190
clang::TypeLoc::getAs
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:88
clang::ElaboratedTypeLoc::setElaboratedKeywordLoc
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2246
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::TypeLoc::getType
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:132
clang::QualifiedTemplateName
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:390
clang::PackExpansionTypeLoc::getPatternLoc
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2495
clang::ObjCObjectTypeLoc::setTypeArgsRAngleLoc
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:945
clang::TST_wchar
@ TST_wchar
Definition: Specifiers.h:56
clang::TypeLoc::getLocalAlignmentForType
static unsigned getLocalAlignmentForType(QualType Ty)
Returns the alignment of type source info data block for the given type.
Definition: TypeLoc.cpp:73
clang::BuiltinType::getKind
Kind getKind() const
Definition: Type.h:2529
clang::ArrayTypeLoc
Wrapper for source info for arrays.
Definition: TypeLoc.h:1493
clang::ElaboratedTypeLoc
Definition: TypeLoc.h:2237
clang::TypeLoc::IgnoreParens
TypeLoc IgnoreParens() const
Definition: TypeLoc.h:1160
clang::PointerLikeTypeLoc::getPointeeLoc
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1217
clang::TST_char32
@ TST_char32
Definition: Specifiers.h:59
clang::AdjustedTypeLoc::getOriginalLoc
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1171
clang::TypeLoc::getTypeLocClass
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:115
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:111
clang::TemplateArgument::Type
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
clang
Definition: CalledOnceCheck.h:17
clang::TemplateArgument::Template
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:86
clang::AutoTypeLoc::setNestedNameSpecifierLoc
void setNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Definition: TypeLoc.h:2113
clang::ComparisonCategoryType::Last
@ Last
clang::TypeOfExprTypeLoc::getUnderlyingExpr
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1969
clang::TypeLoc::Qualified
@ Qualified
Definition: TypeLoc.h:112
clang::TST_char16
@ TST_char16
Definition: Specifiers.h:58
clang::ElaboratedTypeLoc::setQualifierLoc
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2255
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:41
clang::TypeLocVisitor
Definition: TypeLocVisitor.h:25
clang::TemplateSpecializationTypeLoc::initializeArgLocs
static void initializeArgLocs(ASTContext &Context, unsigned NumArgs, const TemplateArgument *Args, TemplateArgumentLocInfo *ArgInfos, SourceLocation Loc)
Definition: TypeLoc.cpp:564
clang::TemplateName::getAsDependentTemplateName
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
Definition: TemplateName.cpp:152
clang::TypeLoc::Ty
const void * Ty
Definition: TypeLoc.h:62
clang::TypeOfExprTypeLoc::getLocalSourceRange
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:316
clang::TypeLoc::findExplicitQualifierLoc
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
Definition: TypeLoc.cpp:449
clang::TypeOfTypeLoc::getUnderlyingType
QualType getUnderlyingType() const
Definition: TypeLoc.h:1982
clang::UnaryTransformTypeLoc::setRParenLoc
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2047
clang::DependentNameTypeLoc::setNameLoc
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2325
clang::TypeofLikeTypeLoc< TypeOfExprTypeLoc, TypeOfExprType, TypeOfExprTypeLocInfo >::getRParenLoc
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1937
clang::FunctionTypeLoc::getReturnLoc
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1444
clang::ObjCObjectTypeLoc::setProtocolRAngleLoc
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:975
clang::QualifiedTypeLoc::getUnqualifiedLoc
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:281
clang::TypeSpecTypeLoc::setNameLoc
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:527
clang::TypeLoc::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:152
clang::ASTContext::getTrivialTypeSourceInfo
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
Definition: ASTContext.cpp:2953
clang::ObjCObjectTypeLoc::setTypeArgsLAngleLoc
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:937
clang::InheritingConcreteTypeLoc::getTypePtr
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:502
clang::FunctionProtoTypeLoc
Definition: TypeLoc.h:1475
clang::ElaboratedTypeLoc::initializeLocal
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:527
clang::BuiltinTypeLoc::getWrittenBuiltinSpecs
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:575
GCCTypeClass::Pointer
@ Pointer
clang::TypeLoc::castAs
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition: TypeLoc.h:77
clang::AutoTypeLoc::getNamedConcept
ConceptDecl * getNamedConcept() const
Definition: TypeLoc.h:2141
clang::TypeofLikeTypeLoc< TypeOfExprTypeLoc, TypeOfExprType, TypeOfExprTypeLocInfo >::getTypeofLoc
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:1921
clang::DependentTemplateSpecializationTypeLoc::getNumArgs
unsigned getNumArgs() const
Definition: TypeLoc.h:2422
clang::ObjCObjectTypeLoc::getNumTypeArgs
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:949
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:756
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:424
clang::AutoTypeLoc::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2155
clang::TemplateArgumentLocInfo
Location information for a TemplateArgument.
Definition: TemplateBase.h:405
clang::TypeLocVisitor::Visit
RetTy Visit(TypeLoc TyLoc)
Definition: TypeLocVisitor.h:27
clang::QualType::hasLocalQualifiers
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:776
TypeLoc.h
clang::MacroQualifiedTypeLoc
Definition: TypeLoc.h:1088
clang::TemplateArgument::getAsType
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:268
clang::TemplateArgument::Pack
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:100
clang::TypeLoc::getNextTypeLoc
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
Definition: TypeLoc.h:169
clang::TypeSpecifierType
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:52
clang::AutoTypeLoc::getNumArgs
unsigned getNumArgs() const
Definition: TypeLoc.h:2167