clang  10.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  Last = Cur;
244  break;
245  case FunctionProto:
247  Last = TypeLoc();
248  else
249  Last = Cur;
250  break;
251  case Pointer:
252  case BlockPointer:
253  case MemberPointer:
254  case LValueReference:
255  case RValueReference:
256  case PackExpansion:
257  if (!Last)
258  Last = Cur;
259  break;
260  case Qualified:
261  case Elaborated:
262  break;
263  }
264  Cur = Cur.getNextTypeLoc();
265  }
266 }
267 
268 namespace {
269 
270 struct TSTChecker : public TypeLocVisitor<TSTChecker, bool> {
271  // Overload resolution does the real work for us.
272  static bool isTypeSpec(TypeSpecTypeLoc _) { return true; }
273  static bool isTypeSpec(TypeLoc _) { return false; }
274 
275 #define ABSTRACT_TYPELOC(CLASS, PARENT)
276 #define TYPELOC(CLASS, PARENT) \
277  bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
278  return isTypeSpec(TyLoc); \
279  }
280 #include "clang/AST/TypeLocNodes.def"
281 };
282 
283 } // namespace
284 
285 /// Determines if the given type loc corresponds to a
286 /// TypeSpecTypeLoc. Since there is not actually a TypeSpecType in
287 /// the type hierarchy, this is made somewhat complicated.
288 ///
289 /// There are a lot of types that currently use TypeSpecTypeLoc
290 /// because it's a convenient base class. Ideally we would not accept
291 /// those here, but ideally we would have better implementations for
292 /// them.
293 bool TypeSpecTypeLoc::isKind(const TypeLoc &TL) {
294  if (TL.getType().hasLocalQualifiers()) return false;
295  return TSTChecker().Visit(TL);
296 }
297 
299  TagDecl *D = getDecl();
300  return D->isCompleteDefinition() &&
301  (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
302 }
303 
304 // Reimplemented to account for GNU/C++ extension
305 // typeof unary-expression
306 // where there are no parentheses.
308  if (getRParenLoc().isValid())
309  return SourceRange(getTypeofLoc(), getRParenLoc());
310  else
311  return SourceRange(getTypeofLoc(),
312  getUnderlyingExpr()->getSourceRange().getEnd());
313 }
314 
315 
317  if (needsExtraLocalData())
318  return static_cast<TypeSpecifierType>(getWrittenBuiltinSpecs().Type);
319  switch (getTypePtr()->getKind()) {
320  case BuiltinType::Void:
321  return TST_void;
322  case BuiltinType::Bool:
323  return TST_bool;
324  case BuiltinType::Char_U:
325  case BuiltinType::Char_S:
326  return TST_char;
327  case BuiltinType::Char8:
328  return TST_char8;
329  case BuiltinType::Char16:
330  return TST_char16;
331  case BuiltinType::Char32:
332  return TST_char32;
333  case BuiltinType::WChar_S:
334  case BuiltinType::WChar_U:
335  return TST_wchar;
336  case BuiltinType::UChar:
337  case BuiltinType::UShort:
338  case BuiltinType::UInt:
339  case BuiltinType::ULong:
340  case BuiltinType::ULongLong:
341  case BuiltinType::UInt128:
342  case BuiltinType::SChar:
343  case BuiltinType::Short:
344  case BuiltinType::Int:
345  case BuiltinType::Long:
346  case BuiltinType::LongLong:
347  case BuiltinType::Int128:
348  case BuiltinType::Half:
349  case BuiltinType::Float:
350  case BuiltinType::Double:
351  case BuiltinType::LongDouble:
352  case BuiltinType::Float16:
353  case BuiltinType::Float128:
354  case BuiltinType::ShortAccum:
355  case BuiltinType::Accum:
356  case BuiltinType::LongAccum:
357  case BuiltinType::UShortAccum:
358  case BuiltinType::UAccum:
359  case BuiltinType::ULongAccum:
360  case BuiltinType::ShortFract:
361  case BuiltinType::Fract:
362  case BuiltinType::LongFract:
363  case BuiltinType::UShortFract:
364  case BuiltinType::UFract:
365  case BuiltinType::ULongFract:
366  case BuiltinType::SatShortAccum:
367  case BuiltinType::SatAccum:
368  case BuiltinType::SatLongAccum:
369  case BuiltinType::SatUShortAccum:
370  case BuiltinType::SatUAccum:
371  case BuiltinType::SatULongAccum:
372  case BuiltinType::SatShortFract:
373  case BuiltinType::SatFract:
374  case BuiltinType::SatLongFract:
375  case BuiltinType::SatUShortFract:
376  case BuiltinType::SatUFract:
377  case BuiltinType::SatULongFract:
378  llvm_unreachable("Builtin type needs extra local data!");
379  // Fall through, if the impossible happens.
380 
381  case BuiltinType::NullPtr:
382  case BuiltinType::Overload:
383  case BuiltinType::Dependent:
384  case BuiltinType::BoundMember:
385  case BuiltinType::UnknownAny:
386  case BuiltinType::ARCUnbridgedCast:
387  case BuiltinType::PseudoObject:
388  case BuiltinType::ObjCId:
389  case BuiltinType::ObjCClass:
390  case BuiltinType::ObjCSel:
391 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
392  case BuiltinType::Id:
393 #include "clang/Basic/OpenCLImageTypes.def"
394 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
395  case BuiltinType::Id:
396 #include "clang/Basic/OpenCLExtensionTypes.def"
397  case BuiltinType::OCLSampler:
398  case BuiltinType::OCLEvent:
399  case BuiltinType::OCLClkEvent:
400  case BuiltinType::OCLQueue:
401  case BuiltinType::OCLReserveID:
402 #define SVE_TYPE(Name, Id, SingletonId) \
403  case BuiltinType::Id:
404 #include "clang/Basic/AArch64SVEACLETypes.def"
405  case BuiltinType::BuiltinFn:
406  case BuiltinType::OMPArraySection:
407  return TST_unspecified;
408  }
409 
410  llvm_unreachable("Invalid BuiltinType Kind!");
411 }
412 
413 TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) {
414  while (ParenTypeLoc PTL = TL.getAs<ParenTypeLoc>())
415  TL = PTL.getInnerLoc();
416  return TL;
417 }
418 
420  if (auto ATL = getAs<AttributedTypeLoc>()) {
421  const Attr *A = ATL.getAttr();
422  if (A && (isa<TypeNullableAttr>(A) || isa<TypeNonNullAttr>(A) ||
423  isa<TypeNullUnspecifiedAttr>(A)))
424  return A->getLocation();
425  }
426 
427  return {};
428 }
429 
431  // Qualified types.
432  if (auto qual = getAs<QualifiedTypeLoc>())
433  return qual;
434 
435  TypeLoc loc = IgnoreParens();
436 
437  // Attributed types.
438  if (auto attr = loc.getAs<AttributedTypeLoc>()) {
439  if (attr.isQualifier()) return attr;
440  return attr.getModifiedLoc().findExplicitQualifierLoc();
441  }
442 
443  // C11 _Atomic types.
444  if (auto atomic = loc.getAs<AtomicTypeLoc>()) {
445  return atomic;
446  }
447 
448  return {};
449 }
450 
452  SourceLocation Loc) {
453  setNameLoc(Loc);
454  if (!getNumProtocols()) return;
455 
456  setProtocolLAngleLoc(Loc);
457  setProtocolRAngleLoc(Loc);
458  for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
459  setProtocolLoc(i, Loc);
460 }
461 
463  SourceLocation Loc) {
464  setHasBaseTypeAsWritten(true);
465  setTypeArgsLAngleLoc(Loc);
466  setTypeArgsRAngleLoc(Loc);
467  for (unsigned i = 0, e = getNumTypeArgs(); i != e; ++i) {
468  setTypeArgTInfo(i,
469  Context.getTrivialTypeSourceInfo(
470  getTypePtr()->getTypeArgsAsWritten()[i], Loc));
471  }
472  setProtocolLAngleLoc(Loc);
473  setProtocolRAngleLoc(Loc);
474  for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
475  setProtocolLoc(i, Loc);
476 }
477 
479  // Note that this does *not* include the range of the attribute
480  // enclosure, e.g.:
481  // __attribute__((foo(bar)))
482  // ^~~~~~~~~~~~~~~ ~~
483  // or
484  // [[foo(bar)]]
485  // ^~ ~~
486  // That enclosure doesn't necessarily belong to a single attribute
487  // anyway.
488  return getAttr() ? getAttr()->getRange() : SourceRange();
489 }
490 
492  SourceLocation Loc) {
494  ::initializeLocal(Context, Loc);
495  this->getLocalData()->UnderlyingTInfo = Context.getTrivialTypeSourceInfo(
496  getUnderlyingType(), Loc);
497 }
498 
500  SourceLocation Loc) {
501  setKWLoc(Loc);
502  setRParenLoc(Loc);
503  setLParenLoc(Loc);
504  this->setUnderlyingTInfo(
505  Context.getTrivialTypeSourceInfo(getTypePtr()->getBaseType(), Loc));
506 }
507 
509  SourceLocation Loc) {
510  setElaboratedKeywordLoc(Loc);
512  Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
513  setQualifierLoc(Builder.getWithLocInContext(Context));
514 }
515 
517  SourceLocation Loc) {
518  setElaboratedKeywordLoc(Loc);
520  Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
521  setQualifierLoc(Builder.getWithLocInContext(Context));
522  setNameLoc(Loc);
523 }
524 
525 void
527  SourceLocation Loc) {
528  setElaboratedKeywordLoc(Loc);
529  if (getTypePtr()->getQualifier()) {
531  Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
532  setQualifierLoc(Builder.getWithLocInContext(Context));
533  } else {
534  setQualifierLoc(NestedNameSpecifierLoc());
535  }
536  setTemplateKeywordLoc(Loc);
537  setTemplateNameLoc(Loc);
538  setLAngleLoc(Loc);
539  setRAngleLoc(Loc);
541  getTypePtr()->getArgs(),
542  getArgInfos(), Loc);
543 }
544 
546  unsigned NumArgs,
547  const TemplateArgument *Args,
548  TemplateArgumentLocInfo *ArgInfos,
549  SourceLocation Loc) {
550  for (unsigned i = 0, e = NumArgs; i != e; ++i) {
551  switch (Args[i].getKind()) {
553  llvm_unreachable("Impossible TemplateArgument");
554 
558  ArgInfos[i] = TemplateArgumentLocInfo();
559  break;
560 
562  ArgInfos[i] = TemplateArgumentLocInfo(Args[i].getAsExpr());
563  break;
564 
566  ArgInfos[i] = TemplateArgumentLocInfo(
567  Context.getTrivialTypeSourceInfo(Args[i].getAsType(),
568  Loc));
569  break;
570 
574  TemplateName Template = Args[i].getAsTemplateOrTemplatePattern();
576  Builder.MakeTrivial(Context, DTN->getQualifier(), Loc);
577  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
578  Builder.MakeTrivial(Context, QTN->getQualifier(), Loc);
579 
580  ArgInfos[i] = TemplateArgumentLocInfo(
581  Builder.getWithLocInContext(Context), Loc,
583  : Loc);
584  break;
585  }
586 
588  ArgInfos[i] = TemplateArgumentLocInfo();
589  break;
590  }
591  }
592 }
593 
595  return DeclarationNameInfo(getNamedConcept()->getDeclName(),
596  getLocalData()->ConceptNameLoc);
597 }
598 
600  setNestedNameSpecifierLoc(NestedNameSpecifierLoc());
601  setTemplateKWLoc(Loc);
602  setConceptNameLoc(Loc);
603  setFoundDecl(nullptr);
604  setRAngleLoc(Loc);
605  setLAngleLoc(Loc);
607  getTypePtr()->getArgs(),
608  getArgInfos(), Loc);
609  setNameLoc(Loc);
610 }
611 
612 
613 namespace {
614 
615  class GetContainedAutoTypeLocVisitor :
616  public TypeLocVisitor<GetContainedAutoTypeLocVisitor, TypeLoc> {
617  public:
619 
620  TypeLoc VisitAutoTypeLoc(AutoTypeLoc TL) {
621  return TL;
622  }
623 
624  // Only these types can contain the desired 'auto' type.
625 
626  TypeLoc VisitElaboratedTypeLoc(ElaboratedTypeLoc T) {
627  return Visit(T.getNamedTypeLoc());
628  }
629 
630  TypeLoc VisitQualifiedTypeLoc(QualifiedTypeLoc T) {
631  return Visit(T.getUnqualifiedLoc());
632  }
633 
634  TypeLoc VisitPointerTypeLoc(PointerTypeLoc T) {
635  return Visit(T.getPointeeLoc());
636  }
637 
638  TypeLoc VisitBlockPointerTypeLoc(BlockPointerTypeLoc T) {
639  return Visit(T.getPointeeLoc());
640  }
641 
642  TypeLoc VisitReferenceTypeLoc(ReferenceTypeLoc T) {
643  return Visit(T.getPointeeLoc());
644  }
645 
646  TypeLoc VisitMemberPointerTypeLoc(MemberPointerTypeLoc T) {
647  return Visit(T.getPointeeLoc());
648  }
649 
650  TypeLoc VisitArrayTypeLoc(ArrayTypeLoc T) {
651  return Visit(T.getElementLoc());
652  }
653 
654  TypeLoc VisitFunctionTypeLoc(FunctionTypeLoc T) {
655  return Visit(T.getReturnLoc());
656  }
657 
658  TypeLoc VisitParenTypeLoc(ParenTypeLoc T) {
659  return Visit(T.getInnerLoc());
660  }
661 
662  TypeLoc VisitAttributedTypeLoc(AttributedTypeLoc T) {
663  return Visit(T.getModifiedLoc());
664  }
665 
666  TypeLoc VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc T) {
667  return Visit(T.getInnerLoc());
668  }
669 
670  TypeLoc VisitAdjustedTypeLoc(AdjustedTypeLoc T) {
671  return Visit(T.getOriginalLoc());
672  }
673 
674  TypeLoc VisitPackExpansionTypeLoc(PackExpansionTypeLoc T) {
675  return Visit(T.getPatternLoc());
676  }
677  };
678 
679 } // namespace
680 
682  TypeLoc Res = GetContainedAutoTypeLocVisitor().Visit(*this);
683  if (Res.isNull())
684  return AutoTypeLoc();
685  return Res.getAs<AutoTypeLoc>();
686 }
Defines the clang::ASTContext interface.
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
Definition: TypeLoc.cpp:93
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1837
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:502
A (possibly-)qualified type.
Definition: Type.h:654
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
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
The template argument is an expression, and we&#39;ve not resolved it to one of the other forms yet...
Definition: TemplateBase.h:86
RetTy Visit(TypeLoc TyLoc)
Defines the C++ template declaration subclasses.
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:478
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
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1162
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:228
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3324
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:526
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1256
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Definition: TypeLoc.h:277
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:56
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:60
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2125
void * Data
Definition: TypeLoc.h:63
CharSourceRange getSourceRange(const SourceRange &Range)
Returns the token CharSourceRange corresponding to Range.
Definition: FixIt.h:32
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
Definition: TypeLoc.h:513
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:244
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:168
A C++ nested-name-specifier augmented with source location information.
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:446
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1142
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:71
bool isDefinition() const
True if the tag was defined in this type specifier.
Definition: TypeLoc.cpp:298
__DEVICE__ int max(int __a, int __b)
DeclarationNameInfo getConceptNameInfo() const
Definition: TypeLoc.cpp:594
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:508
Wrapper for source info for functions.
Definition: TypeLoc.h:1351
bool isNull() const
Definition: TypeLoc.h:120
SourceLocation findNullabilityLoc() const
Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier), if there is one.
Definition: TypeLoc.cpp:419
Class that aids in the construction of nested-name-specifiers along with source-location information ...
SourceRange getLocalSourceRange() const
Get the local source range.
Definition: TypeLoc.h:158
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
Type source information for an attributed type.
Definition: TypeLoc.h:851
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:599
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:67
__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:62
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
Represents a C++ template name within the type system.
Definition: TemplateName.h:191
Defines the clang::TypeLoc interface and its subclasses.
SourceLocation getEnd() const
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:491
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1087
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:719
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1435
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:4102
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:451
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:516
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:499
Wrapper for source info for arrays.
Definition: TypeLoc.h:1484
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:681
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2345
Encodes a location in the source.
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:462
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3219
static QualType getUnderlyingType(const SubRegion *R)
SourceLocation getLocation() const
Definition: Attr.h:92
static const unsigned TypeLocMaxDataAlign
Definition: TypeLoc.cpp:33
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
Definition: TypeLoc.cpp:430
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:163
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1517
Defines various enumerations that describe declaration and type specifiers.
Represents a template argument.
Definition: TemplateBase.h:50
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:390
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:132
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:79
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:756
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:307
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:868
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1208
static void initializeArgLocs(ASTContext &Context, unsigned NumArgs, const TemplateArgument *Args, TemplateArgumentLocInfo *ArgInfos, SourceLocation Loc)
Definition: TypeLoc.cpp:545
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:115
The template argument is a type.
Definition: TemplateBase.h:59
The template argument is actually a parameter pack.
Definition: TemplateBase.h:90
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:281
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:234
Defines the clang::SourceLocation class and associated facilities.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:75
static unsigned getLocalAlignmentForType(QualType Ty)
Returns the alignment of type source info data block for the given type.
Definition: TypeLoc.cpp:73
Location information for a TemplateArgument.
Definition: TemplateBase.h:392
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:947
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:256
void copy(TypeLoc other)
Copies the other type loc into this one.
Definition: TypeLoc.cpp:167
TypeSpecifierType getWrittenTypeSpec() const
Definition: TypeLoc.cpp:316
A trivial tuple used to represent a source range.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
Definition: TypeLoc.h:77
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
Wrapper for source info for pointers.
Definition: TypeLoc.h:1226
SourceLocation getBegin() const
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1239
Attr - This represents one attribute.
Definition: Attr.h:45
SourceLocation getLocation() const
Definition: DeclBase.h:429