clang  10.0.0svn
TypeLoc.h
Go to the documentation of this file.
1 //===- TypeLoc.h - Type Source Info Wrapper ---------------------*- C++ -*-===//
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 /// \file
10 /// Defines the clang::TypeLoc interface and its subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_TYPELOC_H
15 #define LLVM_CLANG_AST_TYPELOC_H
16 
17 #include "clang/AST/Attr.h"
18 #include "clang/AST/Decl.h"
20 #include "clang/AST/TemplateBase.h"
21 #include "clang/AST/Type.h"
22 #include "clang/Basic/LLVM.h"
24 #include "clang/Basic/Specifiers.h"
25 #include "llvm/ADT/ArrayRef.h"
26 #include "llvm/Support/Casting.h"
27 #include "llvm/Support/Compiler.h"
28 #include "llvm/Support/MathExtras.h"
29 #include <algorithm>
30 #include <cassert>
31 #include <cstdint>
32 #include <cstring>
33 
34 namespace clang {
35 
36 class ASTContext;
37 class CXXRecordDecl;
38 class Expr;
39 class ObjCInterfaceDecl;
40 class ObjCProtocolDecl;
41 class ObjCTypeParamDecl;
42 class TemplateTypeParmDecl;
43 class UnqualTypeLoc;
44 class UnresolvedUsingTypenameDecl;
45 
46 // Predeclare all the type nodes.
47 #define ABSTRACT_TYPELOC(Class, Base)
48 #define TYPELOC(Class, Base) \
49  class Class##TypeLoc;
50 #include "clang/AST/TypeLocNodes.def"
51 
52 /// Base wrapper for a particular "section" of type source info.
53 ///
54 /// A client should use the TypeLoc subclasses through castAs()/getAs()
55 /// in order to get at the actual information.
56 class TypeLoc {
57 protected:
58  // The correctness of this relies on the property that, for Type *Ty,
59  // QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty
60  const void *Ty = nullptr;
61  void *Data = nullptr;
62 
63 public:
64  TypeLoc() = default;
65  TypeLoc(QualType ty, void *opaqueData)
66  : Ty(ty.getAsOpaquePtr()), Data(opaqueData) {}
67  TypeLoc(const Type *ty, void *opaqueData)
68  : Ty(ty), Data(opaqueData) {}
69 
70  /// Convert to the specified TypeLoc type, asserting that this TypeLoc
71  /// is of the desired type.
72  ///
73  /// \pre T::isKind(*this)
74  template<typename T>
75  T castAs() const {
76  assert(T::isKind(*this));
77  T t;
78  TypeLoc& tl = t;
79  tl = *this;
80  return t;
81  }
82 
83  /// Convert to the specified TypeLoc type, returning a null TypeLoc if
84  /// this TypeLoc is not of the desired type.
85  template<typename T>
86  T getAs() const {
87  if (!T::isKind(*this))
88  return {};
89  T t;
90  TypeLoc& tl = t;
91  tl = *this;
92  return t;
93  }
94 
95  /// Convert to the specified TypeLoc type, returning a null TypeLoc if
96  /// this TypeLoc is not of the desired type. It will consider type
97  /// adjustments from a type that was written as a T to another type that is
98  /// still canonically a T (ignores parens, attributes, elaborated types, etc).
99  template <typename T>
100  T getAsAdjusted() const;
101 
102  /// The kinds of TypeLocs. Equivalent to the Type::TypeClass enum,
103  /// except it also defines a Qualified enum that corresponds to the
104  /// QualifiedLoc class.
106 #define ABSTRACT_TYPE(Class, Base)
107 #define TYPE(Class, Base) \
108  Class = Type::Class,
109 #include "clang/AST/TypeNodes.inc"
111  };
112 
114  if (getType().hasLocalQualifiers()) return Qualified;
115  return (TypeLocClass) getType()->getTypeClass();
116  }
117 
118  bool isNull() const { return !Ty; }
119  explicit operator bool() const { return Ty; }
120 
121  /// Returns the size of type source info data block for the given type.
122  static unsigned getFullDataSizeForType(QualType Ty);
123 
124  /// Returns the alignment of type source info data block for
125  /// the given type.
126  static unsigned getLocalAlignmentForType(QualType Ty);
127 
128  /// Get the type for which this source info wrapper provides
129  /// information.
130  QualType getType() const {
131  return QualType::getFromOpaquePtr(Ty);
132  }
133 
134  const Type *getTypePtr() const {
136  }
137 
138  /// Get the pointer where source information is stored.
139  void *getOpaqueData() const {
140  return Data;
141  }
142 
143  /// Get the begin source location.
144  SourceLocation getBeginLoc() const;
145 
146  /// Get the end source location.
147  SourceLocation getEndLoc() const;
148 
149  /// Get the full source range.
150  SourceRange getSourceRange() const LLVM_READONLY {
151  return SourceRange(getBeginLoc(), getEndLoc());
152  }
153 
154 
155  /// Get the local source range.
157  return getLocalSourceRangeImpl(*this);
158  }
159 
160  /// Returns the size of the type source info data block.
161  unsigned getFullDataSize() const {
163  }
164 
165  /// Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
166  /// TypeLoc is a PointerLoc and next TypeLoc is for "int".
168  return getNextTypeLocImpl(*this);
169  }
170 
171  /// Skips past any qualifiers, if this is qualified.
172  UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header
173 
174  TypeLoc IgnoreParens() const;
175 
176  /// Strips MacroDefinitionTypeLocs from a type location.
178 
179  /// Find a type with the location of an explicit type qualifier.
180  ///
181  /// The result, if non-null, will be one of:
182  /// QualifiedTypeLoc
183  /// AtomicTypeLoc
184  /// AttributedTypeLoc, for those type attributes that behave as qualifiers
186 
187  /// Initializes this to state that every location in this
188  /// type is the given location.
189  ///
190  /// This method exists to provide a simple transition for code that
191  /// relies on location-less types.
192  void initialize(ASTContext &Context, SourceLocation Loc) const {
193  initializeImpl(Context, *this, Loc);
194  }
195 
196  /// Initializes this by copying its information from another
197  /// TypeLoc of the same type.
199  assert(getType() == Other.getType());
200  copy(Other);
201  }
202 
203  /// Initializes this by copying its information from another
204  /// TypeLoc of the same type. The given size must be the full data
205  /// size.
206  void initializeFullCopy(TypeLoc Other, unsigned Size) {
207  assert(getType() == Other.getType());
208  assert(getFullDataSize() == Size);
209  copy(Other);
210  }
211 
212  /// Copies the other type loc into this one.
213  void copy(TypeLoc other);
214 
215  friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) {
216  return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data;
217  }
218 
219  friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) {
220  return !(LHS == RHS);
221  }
222 
223  /// Find the location of the nullability specifier (__nonnull,
224  /// __nullable, or __null_unspecifier), if there is one.
226 
227 private:
228  static bool isKind(const TypeLoc&) {
229  return true;
230  }
231 
232  static void initializeImpl(ASTContext &Context, TypeLoc TL,
233  SourceLocation Loc);
234  static TypeLoc getNextTypeLocImpl(TypeLoc TL);
235  static TypeLoc IgnoreParensImpl(TypeLoc TL);
236  static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
237 };
238 
239 /// Return the TypeLoc for a type source info.
241  // TODO: is this alignment already sufficient?
242  return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1)));
243 }
244 
245 /// Wrapper of type source information for a type with
246 /// no direct qualifiers.
247 class UnqualTypeLoc : public TypeLoc {
248 public:
249  UnqualTypeLoc() = default;
250  UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
251 
252  const Type *getTypePtr() const {
253  return reinterpret_cast<const Type*>(Ty);
254  }
255 
257  return (TypeLocClass) getTypePtr()->getTypeClass();
258  }
259 
260 private:
261  friend class TypeLoc;
262 
263  static bool isKind(const TypeLoc &TL) {
264  return !TL.getType().hasLocalQualifiers();
265  }
266 };
267 
268 /// Wrapper of type source information for a type with
269 /// non-trivial direct qualifiers.
270 ///
271 /// Currently, we intentionally do not provide source location for
272 /// type qualifiers.
273 class QualifiedTypeLoc : public TypeLoc {
274 public:
275  SourceRange getLocalSourceRange() const { return {}; }
276 
278  unsigned align =
280  auto dataInt = reinterpret_cast<uintptr_t>(Data);
281  dataInt = llvm::alignTo(dataInt, align);
282  return UnqualTypeLoc(getTypePtr(), reinterpret_cast<void*>(dataInt));
283  }
284 
285  /// Initializes the local data of this type source info block to
286  /// provide no information.
288  // do nothing
289  }
290 
291  void copyLocal(TypeLoc other) {
292  // do nothing
293  }
294 
296  return getUnqualifiedLoc();
297  }
298 
299  /// Returns the size of the type source info data block that is
300  /// specific to this type.
301  unsigned getLocalDataSize() const {
302  // In fact, we don't currently preserve any location information
303  // for qualifiers.
304  return 0;
305  }
306 
307  /// Returns the alignment of the type source info data block that is
308  /// specific to this type.
309  unsigned getLocalDataAlignment() const {
310  // We don't preserve any location information.
311  return 1;
312  }
313 
314 private:
315  friend class TypeLoc;
316 
317  static bool isKind(const TypeLoc &TL) {
318  return TL.getType().hasLocalQualifiers();
319  }
320 };
321 
323  if (QualifiedTypeLoc Loc = getAs<QualifiedTypeLoc>())
324  return Loc.getUnqualifiedLoc();
325  return castAs<UnqualTypeLoc>();
326 }
327 
328 /// A metaprogramming base class for TypeLoc classes which correspond
329 /// to a particular Type subclass. It is accepted for a single
330 /// TypeLoc class to correspond to multiple Type classes.
331 ///
332 /// \tparam Base a class from which to derive
333 /// \tparam Derived the class deriving from this one
334 /// \tparam TypeClass the concrete Type subclass associated with this
335 /// location type
336 /// \tparam LocalData the structure type of local location data for
337 /// this type
338 ///
339 /// TypeLocs with non-constant amounts of local data should override
340 /// getExtraLocalDataSize(); getExtraLocalData() will then point to
341 /// this extra memory.
342 ///
343 /// TypeLocs with an inner type should define
344 /// QualType getInnerType() const
345 /// and getInnerTypeLoc() will then point to this inner type's
346 /// location data.
347 ///
348 /// A word about hierarchies: this template is not designed to be
349 /// derived from multiple times in a hierarchy. It is also not
350 /// designed to be used for classes where subtypes might provide
351 /// different amounts of source information. It should be subclassed
352 /// only at the deepest portion of the hierarchy where all children
353 /// have identical source information; if that's an abstract type,
354 /// then further descendents should inherit from
355 /// InheritingConcreteTypeLoc instead.
356 template <class Base, class Derived, class TypeClass, class LocalData>
357 class ConcreteTypeLoc : public Base {
358  friend class TypeLoc;
359 
360  const Derived *asDerived() const {
361  return static_cast<const Derived*>(this);
362  }
363 
364  static bool isKind(const TypeLoc &TL) {
365  return !TL.getType().hasLocalQualifiers() &&
366  Derived::classofType(TL.getTypePtr());
367  }
368 
369  static bool classofType(const Type *Ty) {
370  return TypeClass::classof(Ty);
371  }
372 
373 public:
374  unsigned getLocalDataAlignment() const {
375  return std::max(unsigned(alignof(LocalData)),
376  asDerived()->getExtraLocalDataAlignment());
377  }
378 
379  unsigned getLocalDataSize() const {
380  unsigned size = sizeof(LocalData);
381  unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
382  size = llvm::alignTo(size, extraAlign);
383  size += asDerived()->getExtraLocalDataSize();
384  return size;
385  }
386 
387  void copyLocal(Derived other) {
388  // Some subclasses have no data to copy.
389  if (asDerived()->getLocalDataSize() == 0) return;
390 
391  // Copy the fixed-sized local data.
392  memcpy(getLocalData(), other.getLocalData(), sizeof(LocalData));
393 
394  // Copy the variable-sized local data. We need to do this
395  // separately because the padding in the source and the padding in
396  // the destination might be different.
397  memcpy(getExtraLocalData(), other.getExtraLocalData(),
398  asDerived()->getExtraLocalDataSize());
399  }
400 
402  return getNextTypeLoc(asDerived()->getInnerType());
403  }
404 
405  const TypeClass *getTypePtr() const {
406  return cast<TypeClass>(Base::getTypePtr());
407  }
408 
409 protected:
410  unsigned getExtraLocalDataSize() const {
411  return 0;
412  }
413 
414  unsigned getExtraLocalDataAlignment() const {
415  return 1;
416  }
417 
418  LocalData *getLocalData() const {
419  return static_cast<LocalData*>(Base::Data);
420  }
421 
422  /// Gets a pointer past the Info structure; useful for classes with
423  /// local data that can't be captured in the Info (e.g. because it's
424  /// of variable size).
425  void *getExtraLocalData() const {
426  unsigned size = sizeof(LocalData);
427  unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
428  size = llvm::alignTo(size, extraAlign);
429  return reinterpret_cast<char*>(Base::Data) + size;
430  }
431 
432  void *getNonLocalData() const {
433  auto data = reinterpret_cast<uintptr_t>(Base::Data);
434  data += asDerived()->getLocalDataSize();
435  data = llvm::alignTo(data, getNextTypeAlign());
436  return reinterpret_cast<void*>(data);
437  }
438 
439  struct HasNoInnerType {};
440  HasNoInnerType getInnerType() const { return HasNoInnerType(); }
441 
443  return TypeLoc(asDerived()->getInnerType(), getNonLocalData());
444  }
445 
446 private:
447  unsigned getInnerTypeSize() const {
448  return getInnerTypeSize(asDerived()->getInnerType());
449  }
450 
451  unsigned getInnerTypeSize(HasNoInnerType _) const {
452  return 0;
453  }
454 
455  unsigned getInnerTypeSize(QualType _) const {
456  return getInnerTypeLoc().getFullDataSize();
457  }
458 
459  unsigned getNextTypeAlign() const {
460  return getNextTypeAlign(asDerived()->getInnerType());
461  }
462 
463  unsigned getNextTypeAlign(HasNoInnerType _) const {
464  return 1;
465  }
466 
467  unsigned getNextTypeAlign(QualType T) const {
469  }
470 
471  TypeLoc getNextTypeLoc(HasNoInnerType _) const { return {}; }
472 
473  TypeLoc getNextTypeLoc(QualType T) const {
474  return TypeLoc(T, getNonLocalData());
475  }
476 };
477 
478 /// A metaprogramming class designed for concrete subtypes of abstract
479 /// types where all subtypes share equivalently-structured source
480 /// information. See the note on ConcreteTypeLoc.
481 template <class Base, class Derived, class TypeClass>
482 class InheritingConcreteTypeLoc : public Base {
483  friend class TypeLoc;
484 
485  static bool classofType(const Type *Ty) {
486  return TypeClass::classof(Ty);
487  }
488 
489  static bool isKind(const TypeLoc &TL) {
490  return !TL.getType().hasLocalQualifiers() &&
491  Derived::classofType(TL.getTypePtr());
492  }
493  static bool isKind(const UnqualTypeLoc &TL) {
494  return Derived::classofType(TL.getTypePtr());
495  }
496 
497 public:
498  const TypeClass *getTypePtr() const {
499  return cast<TypeClass>(Base::getTypePtr());
500  }
501 };
502 
505 };
506 
507 /// A reasonable base class for TypeLocs that correspond to
508 /// types that are written as a type-specifier.
509 class TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
510  TypeSpecTypeLoc,
511  Type,
512  TypeSpecLocInfo> {
513 public:
514  enum {
515  LocalDataSize = sizeof(TypeSpecLocInfo),
516  LocalDataAlignment = alignof(TypeSpecLocInfo)
517  };
518 
520  return this->getLocalData()->NameLoc;
521  }
522 
524  this->getLocalData()->NameLoc = Loc;
525  }
526 
528  return SourceRange(getNameLoc(), getNameLoc());
529  }
530 
532  setNameLoc(Loc);
533  }
534 
535 private:
536  friend class TypeLoc;
537 
538  static bool isKind(const TypeLoc &TL);
539 };
540 
543 };
544 
545 /// Wrapper for source info for builtin types.
546 class BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
547  BuiltinTypeLoc,
548  BuiltinType,
549  BuiltinLocInfo> {
550 public:
552  return getLocalData()->BuiltinRange.getBegin();
553  }
554 
556  getLocalData()->BuiltinRange = Loc;
557  }
558 
560  SourceRange &BuiltinRange = getLocalData()->BuiltinRange;
561  if (!BuiltinRange.getBegin().isValid()) {
562  BuiltinRange = Range;
563  } else {
564  BuiltinRange.setBegin(std::min(Range.getBegin(), BuiltinRange.getBegin()));
565  BuiltinRange.setEnd(std::max(Range.getEnd(), BuiltinRange.getEnd()));
566  }
567  }
568 
569  SourceLocation getNameLoc() const { return getBuiltinLoc(); }
570 
572  return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
573  }
575  return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
576  }
577 
578  bool needsExtraLocalData() const {
579  BuiltinType::Kind bk = getTypePtr()->getKind();
580  return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128)
581  || (bk >= BuiltinType::Short && bk <= BuiltinType::Float128)
582  || bk == BuiltinType::UChar
583  || bk == BuiltinType::SChar;
584  }
585 
586  unsigned getExtraLocalDataSize() const {
587  return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0;
588  }
589 
590  unsigned getExtraLocalDataAlignment() const {
591  return needsExtraLocalData() ? alignof(WrittenBuiltinSpecs) : 1;
592  }
593 
595  return getLocalData()->BuiltinRange;
596  }
597 
599  if (needsExtraLocalData())
600  return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign);
601  else
602  return TSS_unspecified;
603  }
604 
605  bool hasWrittenSignSpec() const {
606  return getWrittenSignSpec() != TSS_unspecified;
607  }
608 
610  if (needsExtraLocalData())
611  getWrittenBuiltinSpecs().Sign = written;
612  }
613 
615  if (needsExtraLocalData())
616  return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width);
617  else
618  return TSW_unspecified;
619  }
620 
621  bool hasWrittenWidthSpec() const {
622  return getWrittenWidthSpec() != TSW_unspecified;
623  }
624 
626  if (needsExtraLocalData())
627  getWrittenBuiltinSpecs().Width = written;
628  }
629 
630  TypeSpecifierType getWrittenTypeSpec() const;
631 
632  bool hasWrittenTypeSpec() const {
633  return getWrittenTypeSpec() != TST_unspecified;
634  }
635 
637  if (needsExtraLocalData())
638  getWrittenBuiltinSpecs().Type = written;
639  }
640 
641  bool hasModeAttr() const {
642  if (needsExtraLocalData())
643  return getWrittenBuiltinSpecs().ModeAttr;
644  else
645  return false;
646  }
647 
648  void setModeAttr(bool written) {
649  if (needsExtraLocalData())
650  getWrittenBuiltinSpecs().ModeAttr = written;
651  }
652 
654  setBuiltinLoc(Loc);
655  if (needsExtraLocalData()) {
656  WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs();
657  wbs.Sign = TSS_unspecified;
658  wbs.Width = TSW_unspecified;
659  wbs.Type = TST_unspecified;
660  wbs.ModeAttr = false;
661  }
662  }
663 };
664 
665 /// Wrapper for source info for typedefs.
666 class TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
667  TypedefTypeLoc,
668  TypedefType> {
669 public:
671  return getTypePtr()->getDecl();
672  }
673 };
674 
675 /// Wrapper for source info for injected class names of class
676 /// templates.
678  public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
679  InjectedClassNameTypeLoc,
680  InjectedClassNameType> {
681 public:
683  return getTypePtr()->getDecl();
684  }
685 };
686 
687 /// Wrapper for source info for unresolved typename using decls.
689  public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
690  UnresolvedUsingTypeLoc,
691  UnresolvedUsingType> {
692 public:
694  return getTypePtr()->getDecl();
695  }
696 };
697 
698 /// Wrapper for source info for tag types. Note that this only
699 /// records source info for the name itself; a type written 'struct foo'
700 /// should be represented as an ElaboratedTypeLoc. We currently
701 /// only do that when C++ is enabled because of the expense of
702 /// creating an ElaboratedType node for so many type references in C.
703 class TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
704  TagTypeLoc,
705  TagType> {
706 public:
707  TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
708 
709  /// True if the tag was defined in this type specifier.
710  bool isDefinition() const {
711  TagDecl *D = getDecl();
712  return D->isCompleteDefinition() &&
713  (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
714  }
715 };
716 
717 /// Wrapper for source info for record types.
718 class RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
719  RecordTypeLoc,
720  RecordType> {
721 public:
722  RecordDecl *getDecl() const { return getTypePtr()->getDecl(); }
723 };
724 
725 /// Wrapper for source info for enum types.
726 class EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
727  EnumTypeLoc,
728  EnumType> {
729 public:
730  EnumDecl *getDecl() const { return getTypePtr()->getDecl(); }
731 };
732 
733 /// Wrapper for template type parameters.
735  public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
736  TemplateTypeParmTypeLoc,
737  TemplateTypeParmType> {
738 public:
739  TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); }
740 };
741 
744 };
745 
746 /// ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for
747 /// protocol qualifiers are stored after Info.
748 class ObjCTypeParamTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
749  ObjCTypeParamTypeLoc,
750  ObjCTypeParamType,
751  ObjCTypeParamTypeLocInfo> {
752  // SourceLocations are stored after Info, one for each protocol qualifier.
753  SourceLocation *getProtocolLocArray() const {
754  return (SourceLocation*)this->getExtraLocalData() + 2;
755  }
756 
757 public:
758  ObjCTypeParamDecl *getDecl() const { return getTypePtr()->getDecl(); }
759 
761  return this->getLocalData()->NameLoc;
762  }
763 
765  this->getLocalData()->NameLoc = Loc;
766  }
767 
769  return getNumProtocols() ?
770  *((SourceLocation*)this->getExtraLocalData()) :
771  SourceLocation();
772  }
773 
775  *((SourceLocation*)this->getExtraLocalData()) = Loc;
776  }
777 
779  return getNumProtocols() ?
780  *((SourceLocation*)this->getExtraLocalData() + 1) :
781  SourceLocation();
782  }
783 
785  *((SourceLocation*)this->getExtraLocalData() + 1) = Loc;
786  }
787 
788  unsigned getNumProtocols() const {
789  return this->getTypePtr()->getNumProtocols();
790  }
791 
792  SourceLocation getProtocolLoc(unsigned i) const {
793  assert(i < getNumProtocols() && "Index is out of bounds!");
794  return getProtocolLocArray()[i];
795  }
796 
797  void setProtocolLoc(unsigned i, SourceLocation Loc) {
798  assert(i < getNumProtocols() && "Index is out of bounds!");
799  getProtocolLocArray()[i] = Loc;
800  }
801 
802  ObjCProtocolDecl *getProtocol(unsigned i) const {
803  assert(i < getNumProtocols() && "Index is out of bounds!");
804  return *(this->getTypePtr()->qual_begin() + i);
805  }
806 
808  return llvm::makeArrayRef(getProtocolLocArray(), getNumProtocols());
809  }
810 
811  void initializeLocal(ASTContext &Context, SourceLocation Loc);
812 
813  unsigned getExtraLocalDataSize() const {
814  if (!this->getNumProtocols()) return 0;
815  // When there are protocol qualifers, we have LAngleLoc and RAngleLoc
816  // as well.
817  return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ;
818  }
819 
820  unsigned getExtraLocalDataAlignment() const {
821  return alignof(SourceLocation);
822  }
823 
825  SourceLocation start = getNameLoc();
826  SourceLocation end = getProtocolRAngleLoc();
827  if (end.isInvalid()) return SourceRange(start, start);
828  return SourceRange(start, end);
829  }
830 };
831 
832 /// Wrapper for substituted template type parameters.
834  public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
835  SubstTemplateTypeParmTypeLoc,
836  SubstTemplateTypeParmType> {
837 };
838 
839  /// Wrapper for substituted template type parameters.
841  public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
842  SubstTemplateTypeParmPackTypeLoc,
843  SubstTemplateTypeParmPackType> {
844 };
845 
847  const Attr *TypeAttr;
848 };
849 
850 /// Type source information for an attributed type.
851 class AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
852  AttributedTypeLoc,
853  AttributedType,
854  AttributedLocInfo> {
855 public:
857  return getTypePtr()->getAttrKind();
858  }
859 
860  bool isQualifier() const {
861  return getTypePtr()->isQualifier();
862  }
863 
864  /// The modified type, which is generally canonically different from
865  /// the attribute type.
866  /// int main(int, char**) __attribute__((noreturn))
867  /// ~~~ ~~~~~~~~~~~~~
869  return getInnerTypeLoc();
870  }
871 
872  /// The type attribute.
873  const Attr *getAttr() const {
874  return getLocalData()->TypeAttr;
875  }
876  void setAttr(const Attr *A) {
877  getLocalData()->TypeAttr = A;
878  }
879 
880  template<typename T> const T *getAttrAs() {
881  return dyn_cast_or_null<T>(getAttr());
882  }
883 
885  // Note that this does *not* include the range of the attribute
886  // enclosure, e.g.:
887  // __attribute__((foo(bar)))
888  // ^~~~~~~~~~~~~~~ ~~
889  // or
890  // [[foo(bar)]]
891  // ^~ ~~
892  // That enclosure doesn't necessarily belong to a single attribute
893  // anyway.
894  return getAttr() ? getAttr()->getRange() : SourceRange();
895  }
896 
898  setAttr(nullptr);
899  }
900 
902  return getTypePtr()->getModifiedType();
903  }
904 };
905 
912 };
913 
914 // A helper class for defining ObjC TypeLocs that can qualified with
915 // protocols.
916 //
917 // TypeClass basically has to be either ObjCInterfaceType or
918 // ObjCObjectPointerType.
919 class ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
920  ObjCObjectTypeLoc,
921  ObjCObjectType,
922  ObjCObjectTypeLocInfo> {
923  // TypeSourceInfo*'s are stored after Info, one for each type argument.
924  TypeSourceInfo **getTypeArgLocArray() const {
925  return (TypeSourceInfo**)this->getExtraLocalData();
926  }
927 
928  // SourceLocations are stored after the type argument information, one for
929  // each Protocol.
930  SourceLocation *getProtocolLocArray() const {
931  return (SourceLocation*)(getTypeArgLocArray() + getNumTypeArgs());
932  }
933 
934 public:
936  return this->getLocalData()->TypeArgsLAngleLoc;
937  }
938 
940  this->getLocalData()->TypeArgsLAngleLoc = Loc;
941  }
942 
944  return this->getLocalData()->TypeArgsRAngleLoc;
945  }
946 
948  this->getLocalData()->TypeArgsRAngleLoc = Loc;
949  }
950 
951  unsigned getNumTypeArgs() const {
952  return this->getTypePtr()->getTypeArgsAsWritten().size();
953  }
954 
955  TypeSourceInfo *getTypeArgTInfo(unsigned i) const {
956  assert(i < getNumTypeArgs() && "Index is out of bounds!");
957  return getTypeArgLocArray()[i];
958  }
959 
960  void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo) {
961  assert(i < getNumTypeArgs() && "Index is out of bounds!");
962  getTypeArgLocArray()[i] = TInfo;
963  }
964 
966  return this->getLocalData()->ProtocolLAngleLoc;
967  }
968 
970  this->getLocalData()->ProtocolLAngleLoc = Loc;
971  }
972 
974  return this->getLocalData()->ProtocolRAngleLoc;
975  }
976 
978  this->getLocalData()->ProtocolRAngleLoc = Loc;
979  }
980 
981  unsigned getNumProtocols() const {
982  return this->getTypePtr()->getNumProtocols();
983  }
984 
985  SourceLocation getProtocolLoc(unsigned i) const {
986  assert(i < getNumProtocols() && "Index is out of bounds!");
987  return getProtocolLocArray()[i];
988  }
989 
990  void setProtocolLoc(unsigned i, SourceLocation Loc) {
991  assert(i < getNumProtocols() && "Index is out of bounds!");
992  getProtocolLocArray()[i] = Loc;
993  }
994 
995  ObjCProtocolDecl *getProtocol(unsigned i) const {
996  assert(i < getNumProtocols() && "Index is out of bounds!");
997  return *(this->getTypePtr()->qual_begin() + i);
998  }
999 
1000 
1002  return llvm::makeArrayRef(getProtocolLocArray(), getNumProtocols());
1003  }
1004 
1005  bool hasBaseTypeAsWritten() const {
1006  return getLocalData()->HasBaseTypeAsWritten;
1007  }
1008 
1009  void setHasBaseTypeAsWritten(bool HasBaseType) {
1010  getLocalData()->HasBaseTypeAsWritten = HasBaseType;
1011  }
1012 
1014  return getInnerTypeLoc();
1015  }
1016 
1018  SourceLocation start = getTypeArgsLAngleLoc();
1019  if (start.isInvalid())
1020  start = getProtocolLAngleLoc();
1021  SourceLocation end = getProtocolRAngleLoc();
1022  if (end.isInvalid())
1023  end = getTypeArgsRAngleLoc();
1024  return SourceRange(start, end);
1025  }
1026 
1027  void initializeLocal(ASTContext &Context, SourceLocation Loc);
1028 
1029  unsigned getExtraLocalDataSize() const {
1030  return this->getNumTypeArgs() * sizeof(TypeSourceInfo *)
1031  + this->getNumProtocols() * sizeof(SourceLocation);
1032  }
1033 
1034  unsigned getExtraLocalDataAlignment() const {
1035  static_assert(alignof(ObjCObjectTypeLoc) >= alignof(TypeSourceInfo *),
1036  "not enough alignment for tail-allocated data");
1037  return alignof(TypeSourceInfo *);
1038  }
1039 
1041  return getTypePtr()->getBaseType();
1042  }
1043 };
1044 
1048 };
1049 
1050 /// Wrapper for source info for ObjC interfaces.
1051 class ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc,
1052  ObjCInterfaceTypeLoc,
1053  ObjCInterfaceType,
1054  ObjCInterfaceLocInfo> {
1055 public:
1057  return getTypePtr()->getDecl();
1058  }
1059 
1061  return getLocalData()->NameLoc;
1062  }
1063 
1065  getLocalData()->NameLoc = Loc;
1066  }
1067 
1069  return SourceRange(getNameLoc(), getNameEndLoc());
1070  }
1071 
1073  return getLocalData()->NameEndLoc;
1074  }
1075 
1077  getLocalData()->NameEndLoc = Loc;
1078  }
1079 
1081  setNameLoc(Loc);
1082  setNameEndLoc(Loc);
1083  }
1084 };
1085 
1088 };
1089 
1091  : public ConcreteTypeLoc<UnqualTypeLoc, MacroQualifiedTypeLoc,
1092  MacroQualifiedType, MacroQualifiedLocInfo> {
1093 public:
1095  setExpansionLoc(Loc);
1096  }
1097 
1098  TypeLoc getInnerLoc() const { return getInnerTypeLoc(); }
1099 
1101  return getTypePtr()->getMacroIdentifier();
1102  }
1103 
1105  return this->getLocalData()->ExpansionLoc;
1106  }
1107 
1109  this->getLocalData()->ExpansionLoc = Loc;
1110  }
1111 
1112  QualType getInnerType() const { return getTypePtr()->getUnderlyingType(); }
1113 
1115  return getInnerLoc().getLocalSourceRange();
1116  }
1117 };
1118 
1122 };
1123 
1125  : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
1126  ParenLocInfo> {
1127 public:
1129  return this->getLocalData()->LParenLoc;
1130  }
1131 
1133  return this->getLocalData()->RParenLoc;
1134  }
1135 
1137  this->getLocalData()->LParenLoc = Loc;
1138  }
1139 
1141  this->getLocalData()->RParenLoc = Loc;
1142  }
1143 
1145  return SourceRange(getLParenLoc(), getRParenLoc());
1146  }
1147 
1149  setLParenLoc(Loc);
1150  setRParenLoc(Loc);
1151  }
1152 
1154  return getInnerTypeLoc();
1155  }
1156 
1158  return this->getTypePtr()->getInnerType();
1159  }
1160 };
1161 
1163  if (ParenTypeLoc::isKind(*this))
1164  return IgnoreParensImpl(*this);
1165  return *this;
1166 }
1167 
1168 struct AdjustedLocInfo {}; // Nothing.
1169 
1170 class AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc,
1171  AdjustedType, AdjustedLocInfo> {
1172 public:
1174  return getInnerTypeLoc();
1175  }
1176 
1178  // do nothing
1179  }
1180 
1182  // The inner type is the undecayed type, since that's what we have source
1183  // location information for.
1184  return getTypePtr()->getOriginalType();
1185  }
1186 
1187  SourceRange getLocalSourceRange() const { return {}; }
1188 
1189  unsigned getLocalDataSize() const {
1190  // sizeof(AdjustedLocInfo) is 1, but we don't need its address to be unique
1191  // anyway. TypeLocBuilder can't handle data sizes of 1.
1192  return 0; // No data.
1193  }
1194 };
1195 
1196 /// Wrapper for source info for pointers decayed from arrays and
1197 /// functions.
1199  AdjustedTypeLoc, DecayedTypeLoc, DecayedType> {
1200 };
1201 
1204 };
1205 
1206 /// A base class for
1207 template <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
1208 class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
1209  TypeClass, LocalData> {
1210 public:
1212  return this->getLocalData()->StarLoc;
1213  }
1214 
1216  this->getLocalData()->StarLoc = Loc;
1217  }
1218 
1220  return this->getInnerTypeLoc();
1221  }
1222 
1224  return SourceRange(getSigilLoc(), getSigilLoc());
1225  }
1226 
1228  setSigilLoc(Loc);
1229  }
1230 
1232  return this->getTypePtr()->getPointeeType();
1233  }
1234 };
1235 
1236 /// Wrapper for source info for pointers.
1237 class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
1238  PointerType> {
1239 public:
1241  return getSigilLoc();
1242  }
1243 
1245  setSigilLoc(Loc);
1246  }
1247 };
1248 
1249 /// Wrapper for source info for block pointers.
1250 class BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
1251  BlockPointerType> {
1252 public:
1254  return getSigilLoc();
1255  }
1256 
1258  setSigilLoc(Loc);
1259  }
1260 };
1261 
1264 };
1265 
1266 /// Wrapper for source info for member pointers.
1267 class MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
1268  MemberPointerType,
1269  MemberPointerLocInfo> {
1270 public:
1272  return getSigilLoc();
1273  }
1274 
1276  setSigilLoc(Loc);
1277  }
1278 
1279  const Type *getClass() const {
1280  return getTypePtr()->getClass();
1281  }
1282 
1284  return getLocalData()->ClassTInfo;
1285  }
1286 
1288  getLocalData()->ClassTInfo = TI;
1289  }
1290 
1292  setSigilLoc(Loc);
1293  setClassTInfo(nullptr);
1294  }
1295 
1297  if (TypeSourceInfo *TI = getClassTInfo())
1298  return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc());
1299  else
1300  return SourceRange(getStarLoc());
1301  }
1302 };
1303 
1304 /// Wraps an ObjCPointerType with source location information.
1306  public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
1307  ObjCObjectPointerType> {
1308 public:
1310  return getSigilLoc();
1311  }
1312 
1314  setSigilLoc(Loc);
1315  }
1316 };
1317 
1318 class ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
1319  ReferenceType> {
1320 public:
1322  return getTypePtr()->getPointeeTypeAsWritten();
1323  }
1324 };
1325 
1327  public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1328  LValueReferenceTypeLoc,
1329  LValueReferenceType> {
1330 public:
1332  return getSigilLoc();
1333  }
1334 
1336  setSigilLoc(Loc);
1337  }
1338 };
1339 
1341  public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1342  RValueReferenceTypeLoc,
1343  RValueReferenceType> {
1344 public:
1346  return getSigilLoc();
1347  }
1348 
1350  setSigilLoc(Loc);
1351  }
1352 };
1353 
1359 };
1360 
1361 /// Wrapper for source info for functions.
1362 class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1363  FunctionTypeLoc,
1364  FunctionType,
1365  FunctionLocInfo> {
1366  bool hasExceptionSpec() const {
1367  if (auto *FPT = dyn_cast<FunctionProtoType>(getTypePtr())) {
1368  return FPT->hasExceptionSpec();
1369  }
1370  return false;
1371  }
1372 
1373  SourceRange *getExceptionSpecRangePtr() const {
1374  assert(hasExceptionSpec() && "No exception spec range");
1375  // After the Info comes the ParmVarDecl array, and after that comes the
1376  // exception specification information.
1377  return (SourceRange *)(getParmArray() + getNumParams());
1378  }
1379 
1380 public:
1382  return getLocalData()->LocalRangeBegin;
1383  }
1384 
1386  getLocalData()->LocalRangeBegin = L;
1387  }
1388 
1390  return getLocalData()->LocalRangeEnd;
1391  }
1392 
1394  getLocalData()->LocalRangeEnd = L;
1395  }
1396 
1398  return this->getLocalData()->LParenLoc;
1399  }
1400 
1402  this->getLocalData()->LParenLoc = Loc;
1403  }
1404 
1406  return this->getLocalData()->RParenLoc;
1407  }
1408 
1410  this->getLocalData()->RParenLoc = Loc;
1411  }
1412 
1414  return SourceRange(getLParenLoc(), getRParenLoc());
1415  }
1416 
1418  if (hasExceptionSpec())
1419  return *getExceptionSpecRangePtr();
1420  return {};
1421  }
1422 
1424  if (hasExceptionSpec())
1425  *getExceptionSpecRangePtr() = R;
1426  }
1427 
1429  return llvm::makeArrayRef(getParmArray(), getNumParams());
1430  }
1431 
1432  // ParmVarDecls* are stored after Info, one for each parameter.
1434  return (ParmVarDecl**) getExtraLocalData();
1435  }
1436 
1437  unsigned getNumParams() const {
1438  if (isa<FunctionNoProtoType>(getTypePtr()))
1439  return 0;
1440  return cast<FunctionProtoType>(getTypePtr())->getNumParams();
1441  }
1442 
1443  ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; }
1444  void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1445 
1447  return getInnerTypeLoc();
1448  }
1449 
1451  return SourceRange(getLocalRangeBegin(), getLocalRangeEnd());
1452  }
1453 
1455  setLocalRangeBegin(Loc);
1456  setLParenLoc(Loc);
1457  setRParenLoc(Loc);
1458  setLocalRangeEnd(Loc);
1459  for (unsigned i = 0, e = getNumParams(); i != e; ++i)
1460  setParam(i, nullptr);
1461  if (hasExceptionSpec())
1462  setExceptionSpecRange(Loc);
1463  }
1464 
1465  /// Returns the size of the type source info data block that is
1466  /// specific to this type.
1467  unsigned getExtraLocalDataSize() const {
1468  unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
1469  return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
1470  }
1471 
1472  unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); }
1473 
1474  QualType getInnerType() const { return getTypePtr()->getReturnType(); }
1475 };
1476 
1478  public InheritingConcreteTypeLoc<FunctionTypeLoc,
1479  FunctionProtoTypeLoc,
1480  FunctionProtoType> {
1481 };
1482 
1484  public InheritingConcreteTypeLoc<FunctionTypeLoc,
1485  FunctionNoProtoTypeLoc,
1486  FunctionNoProtoType> {
1487 };
1488 
1492 };
1493 
1494 /// Wrapper for source info for arrays.
1495 class ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1496  ArrayTypeLoc,
1497  ArrayType,
1498  ArrayLocInfo> {
1499 public:
1501  return getLocalData()->LBracketLoc;
1502  }
1503 
1505  getLocalData()->LBracketLoc = Loc;
1506  }
1507 
1509  return getLocalData()->RBracketLoc;
1510  }
1511 
1513  getLocalData()->RBracketLoc = Loc;
1514  }
1515 
1517  return SourceRange(getLBracketLoc(), getRBracketLoc());
1518  }
1519 
1520  Expr *getSizeExpr() const {
1521  return getLocalData()->Size;
1522  }
1523 
1524  void setSizeExpr(Expr *Size) {
1525  getLocalData()->Size = Size;
1526  }
1527 
1529  return getInnerTypeLoc();
1530  }
1531 
1533  return SourceRange(getLBracketLoc(), getRBracketLoc());
1534  }
1535 
1537  setLBracketLoc(Loc);
1538  setRBracketLoc(Loc);
1539  setSizeExpr(nullptr);
1540  }
1541 
1542  QualType getInnerType() const { return getTypePtr()->getElementType(); }
1543 };
1544 
1546  public InheritingConcreteTypeLoc<ArrayTypeLoc,
1547  ConstantArrayTypeLoc,
1548  ConstantArrayType> {
1549 };
1550 
1552  public InheritingConcreteTypeLoc<ArrayTypeLoc,
1553  IncompleteArrayTypeLoc,
1554  IncompleteArrayType> {
1555 };
1556 
1558  public InheritingConcreteTypeLoc<ArrayTypeLoc,
1559  DependentSizedArrayTypeLoc,
1560  DependentSizedArrayType> {
1561 public:
1563  ArrayTypeLoc::initializeLocal(Context, Loc);
1564  setSizeExpr(getTypePtr()->getSizeExpr());
1565  }
1566 };
1567 
1569  public InheritingConcreteTypeLoc<ArrayTypeLoc,
1570  VariableArrayTypeLoc,
1571  VariableArrayType> {
1572 };
1573 
1574 // Location information for a TemplateName. Rudimentary for now.
1577 };
1578 
1583 };
1584 
1586  public ConcreteTypeLoc<UnqualTypeLoc,
1587  TemplateSpecializationTypeLoc,
1588  TemplateSpecializationType,
1589  TemplateSpecializationLocInfo> {
1590 public:
1592  return getLocalData()->TemplateKWLoc;
1593  }
1594 
1596  getLocalData()->TemplateKWLoc = Loc;
1597  }
1598 
1600  return getLocalData()->LAngleLoc;
1601  }
1602 
1604  getLocalData()->LAngleLoc = Loc;
1605  }
1606 
1608  return getLocalData()->RAngleLoc;
1609  }
1610 
1612  getLocalData()->RAngleLoc = Loc;
1613  }
1614 
1615  unsigned getNumArgs() const {
1616  return getTypePtr()->getNumArgs();
1617  }
1618 
1620  getArgInfos()[i] = AI;
1621  }
1622 
1624  return getArgInfos()[i];
1625  }
1626 
1627  TemplateArgumentLoc getArgLoc(unsigned i) const {
1628  return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
1629  }
1630 
1632  return getLocalData()->NameLoc;
1633  }
1634 
1636  getLocalData()->NameLoc = Loc;
1637  }
1638 
1639  /// - Copy the location information from the given info.
1641  unsigned size = getFullDataSize();
1642  assert(size == Loc.getFullDataSize());
1643 
1644  // We're potentially copying Expr references here. We don't
1645  // bother retaining them because TypeSourceInfos live forever, so
1646  // as long as the Expr was retained when originally written into
1647  // the TypeLoc, we're okay.
1648  memcpy(Data, Loc.Data, size);
1649  }
1650 
1652  if (getTemplateKeywordLoc().isValid())
1653  return SourceRange(getTemplateKeywordLoc(), getRAngleLoc());
1654  else
1655  return SourceRange(getTemplateNameLoc(), getRAngleLoc());
1656  }
1657 
1659  setTemplateKeywordLoc(Loc);
1660  setTemplateNameLoc(Loc);
1661  setLAngleLoc(Loc);
1662  setRAngleLoc(Loc);
1663  initializeArgLocs(Context, getNumArgs(), getTypePtr()->getArgs(),
1664  getArgInfos(), Loc);
1665  }
1666 
1667  static void initializeArgLocs(ASTContext &Context, unsigned NumArgs,
1668  const TemplateArgument *Args,
1669  TemplateArgumentLocInfo *ArgInfos,
1670  SourceLocation Loc);
1671 
1672  unsigned getExtraLocalDataSize() const {
1673  return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1674  }
1675 
1676  unsigned getExtraLocalDataAlignment() const {
1677  return alignof(TemplateArgumentLocInfo);
1678  }
1679 
1680 private:
1681  TemplateArgumentLocInfo *getArgInfos() const {
1682  return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1683  }
1684 };
1685 
1690 };
1691 
1693  : public ConcreteTypeLoc<UnqualTypeLoc,
1694  DependentAddressSpaceTypeLoc,
1695  DependentAddressSpaceType,
1696  DependentAddressSpaceLocInfo> {
1697 public:
1698  /// The location of the attribute name, i.e.
1699  /// int * __attribute__((address_space(11)))
1700  /// ^~~~~~~~~~~~~
1702  return getLocalData()->AttrLoc;
1703  }
1705  getLocalData()->AttrLoc = loc;
1706  }
1707 
1708  /// The attribute's expression operand, if it has one.
1709  /// int * __attribute__((address_space(11)))
1710  /// ^~
1712  return getLocalData()->ExprOperand;
1713  }
1715  getLocalData()->ExprOperand = e;
1716  }
1717 
1718  /// The location of the parentheses around the operand, if there is
1719  /// an operand.
1720  /// int * __attribute__((address_space(11)))
1721  /// ^ ^
1723  return getLocalData()->OperandParens;
1724  }
1726  getLocalData()->OperandParens = range;
1727  }
1728 
1730  SourceRange range(getAttrNameLoc());
1731  range.setEnd(getAttrOperandParensRange().getEnd());
1732  return range;
1733  }
1734 
1735  /// Returns the type before the address space attribute application
1736  /// area.
1737  /// int * __attribute__((address_space(11))) *
1738  /// ^ ^
1740  return this->getTypePtr()->getPointeeType();
1741  }
1742 
1744  return this->getInnerTypeLoc();
1745  }
1746 
1748  setAttrNameLoc(loc);
1749  setAttrOperandParensRange(SourceRange(loc));
1750  setAttrExprOperand(getTypePtr()->getAddrSpaceExpr());
1751  }
1752 };
1753 
1754 //===----------------------------------------------------------------------===//
1755 //
1756 // All of these need proper implementations.
1757 //
1758 //===----------------------------------------------------------------------===//
1759 
1760 // FIXME: size expression and attribute locations (or keyword if we
1761 // ever fully support altivec syntax).
1762 class VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1763  VectorTypeLoc,
1764  VectorType> {
1765 };
1766 
1767 // FIXME: size expression and attribute locations (or keyword if we
1768 // ever fully support altivec syntax).
1770  : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1771  DependentVectorTypeLoc,
1772  DependentVectorType> {};
1773 
1774 // FIXME: size expression and attribute locations.
1775 class ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc,
1776  ExtVectorTypeLoc,
1777  ExtVectorType> {
1778 };
1779 
1780 // FIXME: attribute locations.
1781 // For some reason, this isn't a subtype of VectorType.
1783  public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1784  DependentSizedExtVectorTypeLoc,
1785  DependentSizedExtVectorType> {
1786 };
1787 
1788 // FIXME: location of the '_Complex' keyword.
1789 class ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1790  ComplexTypeLoc,
1791  ComplexType> {
1792 };
1793 
1798 };
1799 
1801 };
1802 
1805 };
1806 
1807 template <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
1809  : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
1810 public:
1812  return this->getLocalData()->TypeofLoc;
1813  }
1814 
1816  this->getLocalData()->TypeofLoc = Loc;
1817  }
1818 
1820  return this->getLocalData()->LParenLoc;
1821  }
1822 
1824  this->getLocalData()->LParenLoc = Loc;
1825  }
1826 
1828  return this->getLocalData()->RParenLoc;
1829  }
1830 
1832  this->getLocalData()->RParenLoc = Loc;
1833  }
1834 
1836  return SourceRange(getLParenLoc(), getRParenLoc());
1837  }
1838 
1840  setLParenLoc(range.getBegin());
1841  setRParenLoc(range.getEnd());
1842  }
1843 
1845  return SourceRange(getTypeofLoc(), getRParenLoc());
1846  }
1847 
1849  setTypeofLoc(Loc);
1850  setLParenLoc(Loc);
1851  setRParenLoc(Loc);
1852  }
1853 };
1854 
1855 class TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
1856  TypeOfExprType,
1857  TypeOfExprTypeLocInfo> {
1858 public:
1860  return getTypePtr()->getUnderlyingExpr();
1861  }
1862 
1863  // Reimplemented to account for GNU/C++ extension
1864  // typeof unary-expression
1865  // where there are no parentheses.
1867 };
1868 
1870  : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
1871 public:
1873  return this->getTypePtr()->getUnderlyingType();
1874  }
1875 
1877  return this->getLocalData()->UnderlyingTInfo;
1878  }
1879 
1881  this->getLocalData()->UnderlyingTInfo = TI;
1882  }
1883 
1884  void initializeLocal(ASTContext &Context, SourceLocation Loc);
1885 };
1886 
1887 // FIXME: location of the 'decltype' and parens.
1888 class DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1889  DecltypeTypeLoc,
1890  DecltypeType> {
1891 public:
1892  Expr *getUnderlyingExpr() const { return getTypePtr()->getUnderlyingExpr(); }
1893 };
1894 
1896  // FIXME: While there's only one unary transform right now, future ones may
1897  // need different representations
1898  SourceLocation KWLoc, LParenLoc, RParenLoc;
1900 };
1901 
1902 class UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1903  UnaryTransformTypeLoc,
1904  UnaryTransformType,
1905  UnaryTransformTypeLocInfo> {
1906 public:
1907  SourceLocation getKWLoc() const { return getLocalData()->KWLoc; }
1908  void setKWLoc(SourceLocation Loc) { getLocalData()->KWLoc = Loc; }
1909 
1910  SourceLocation getLParenLoc() const { return getLocalData()->LParenLoc; }
1911  void setLParenLoc(SourceLocation Loc) { getLocalData()->LParenLoc = Loc; }
1912 
1913  SourceLocation getRParenLoc() const { return getLocalData()->RParenLoc; }
1914  void setRParenLoc(SourceLocation Loc) { getLocalData()->RParenLoc = Loc; }
1915 
1917  return getLocalData()->UnderlyingTInfo;
1918  }
1919 
1921  getLocalData()->UnderlyingTInfo = TInfo;
1922  }
1923 
1925  return SourceRange(getKWLoc(), getRParenLoc());
1926  }
1927 
1929  return SourceRange(getLParenLoc(), getRParenLoc());
1930  }
1931 
1933  setLParenLoc(Range.getBegin());
1934  setRParenLoc(Range.getEnd());
1935  }
1936 
1937  void initializeLocal(ASTContext &Context, SourceLocation Loc);
1938 };
1939 
1941  : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DeducedTypeLoc,
1942  DeducedType> {};
1943 
1945  : public InheritingConcreteTypeLoc<DeducedTypeLoc, AutoTypeLoc, AutoType> {
1946 };
1947 
1949  : public InheritingConcreteTypeLoc<DeducedTypeLoc,
1950  DeducedTemplateSpecializationTypeLoc,
1951  DeducedTemplateSpecializationType> {
1952 public:
1954  return getNameLoc();
1955  }
1956 
1958  setNameLoc(Loc);
1959  }
1960 };
1961 
1964 
1965  /// Data associated with the nested-name-specifier location.
1967 };
1968 
1969 class ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1970  ElaboratedTypeLoc,
1971  ElaboratedType,
1972  ElaboratedLocInfo> {
1973 public:
1975  return this->getLocalData()->ElaboratedKWLoc;
1976  }
1977 
1979  this->getLocalData()->ElaboratedKWLoc = Loc;
1980  }
1981 
1983  return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
1984  getLocalData()->QualifierData);
1985  }
1986 
1988  assert(QualifierLoc.getNestedNameSpecifier()
1989  == getTypePtr()->getQualifier() &&
1990  "Inconsistent nested-name-specifier pointer");
1991  getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
1992  }
1993 
1995  if (getElaboratedKeywordLoc().isValid())
1996  if (getQualifierLoc())
1997  return SourceRange(getElaboratedKeywordLoc(),
1998  getQualifierLoc().getEndLoc());
1999  else
2000  return SourceRange(getElaboratedKeywordLoc());
2001  else
2002  return getQualifierLoc().getSourceRange();
2003  }
2004 
2005  void initializeLocal(ASTContext &Context, SourceLocation Loc);
2006 
2008  return getInnerTypeLoc();
2009  }
2010 
2012  return getTypePtr()->getNamedType();
2013  }
2014 
2016  unsigned size = getFullDataSize();
2017  assert(size == Loc.getFullDataSize());
2018  memcpy(Data, Loc.Data, size);
2019  }
2020 };
2021 
2022 // This is exactly the structure of an ElaboratedTypeLoc whose inner
2023 // type is some sort of TypeDeclTypeLoc.
2026 };
2027 
2028 class DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2029  DependentNameTypeLoc,
2030  DependentNameType,
2031  DependentNameLocInfo> {
2032 public:
2034  return this->getLocalData()->ElaboratedKWLoc;
2035  }
2036 
2038  this->getLocalData()->ElaboratedKWLoc = Loc;
2039  }
2040 
2042  return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2043  getLocalData()->QualifierData);
2044  }
2045 
2047  assert(QualifierLoc.getNestedNameSpecifier()
2048  == getTypePtr()->getQualifier() &&
2049  "Inconsistent nested-name-specifier pointer");
2050  getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2051  }
2052 
2054  return this->getLocalData()->NameLoc;
2055  }
2056 
2058  this->getLocalData()->NameLoc = Loc;
2059  }
2060 
2062  if (getElaboratedKeywordLoc().isValid())
2063  return SourceRange(getElaboratedKeywordLoc(), getNameLoc());
2064  else
2065  return SourceRange(getQualifierLoc().getBeginLoc(), getNameLoc());
2066  }
2067 
2069  unsigned size = getFullDataSize();
2070  assert(size == Loc.getFullDataSize());
2071  memcpy(Data, Loc.Data, size);
2072  }
2073 
2074  void initializeLocal(ASTContext &Context, SourceLocation Loc);
2075 };
2076 
2081  // followed by a TemplateArgumentLocInfo[]
2082 };
2083 
2085  public ConcreteTypeLoc<UnqualTypeLoc,
2086  DependentTemplateSpecializationTypeLoc,
2087  DependentTemplateSpecializationType,
2088  DependentTemplateSpecializationLocInfo> {
2089 public:
2091  return this->getLocalData()->ElaboratedKWLoc;
2092  }
2093 
2095  this->getLocalData()->ElaboratedKWLoc = Loc;
2096  }
2097 
2099  if (!getLocalData()->QualifierData)
2100  return NestedNameSpecifierLoc();
2101 
2102  return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2103  getLocalData()->QualifierData);
2104  }
2105 
2107  if (!QualifierLoc) {
2108  // Even if we have a nested-name-specifier in the dependent
2109  // template specialization type, we won't record the nested-name-specifier
2110  // location information when this type-source location information is
2111  // part of a nested-name-specifier.
2112  getLocalData()->QualifierData = nullptr;
2113  return;
2114  }
2115 
2116  assert(QualifierLoc.getNestedNameSpecifier()
2117  == getTypePtr()->getQualifier() &&
2118  "Inconsistent nested-name-specifier pointer");
2119  getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2120  }
2121 
2123  return getLocalData()->TemplateKWLoc;
2124  }
2125 
2127  getLocalData()->TemplateKWLoc = Loc;
2128  }
2129 
2131  return this->getLocalData()->NameLoc;
2132  }
2133 
2135  this->getLocalData()->NameLoc = Loc;
2136  }
2137 
2139  return this->getLocalData()->LAngleLoc;
2140  }
2141 
2143  this->getLocalData()->LAngleLoc = Loc;
2144  }
2145 
2147  return this->getLocalData()->RAngleLoc;
2148  }
2149 
2151  this->getLocalData()->RAngleLoc = Loc;
2152  }
2153 
2154  unsigned getNumArgs() const {
2155  return getTypePtr()->getNumArgs();
2156  }
2157 
2159  getArgInfos()[i] = AI;
2160  }
2161 
2163  return getArgInfos()[i];
2164  }
2165 
2166  TemplateArgumentLoc getArgLoc(unsigned i) const {
2167  return TemplateArgumentLoc(getTypePtr()->getArg(i), getArgLocInfo(i));
2168  }
2169 
2171  if (getElaboratedKeywordLoc().isValid())
2172  return SourceRange(getElaboratedKeywordLoc(), getRAngleLoc());
2173  else if (getQualifierLoc())
2174  return SourceRange(getQualifierLoc().getBeginLoc(), getRAngleLoc());
2175  else if (getTemplateKeywordLoc().isValid())
2176  return SourceRange(getTemplateKeywordLoc(), getRAngleLoc());
2177  else
2178  return SourceRange(getTemplateNameLoc(), getRAngleLoc());
2179  }
2180 
2182  unsigned size = getFullDataSize();
2183  assert(size == Loc.getFullDataSize());
2184  memcpy(Data, Loc.Data, size);
2185  }
2186 
2187  void initializeLocal(ASTContext &Context, SourceLocation Loc);
2188 
2189  unsigned getExtraLocalDataSize() const {
2190  return getNumArgs() * sizeof(TemplateArgumentLocInfo);
2191  }
2192 
2193  unsigned getExtraLocalDataAlignment() const {
2194  return alignof(TemplateArgumentLocInfo);
2195  }
2196 
2197 private:
2198  TemplateArgumentLocInfo *getArgInfos() const {
2199  return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
2200  }
2201 };
2202 
2205 };
2206 
2208  : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
2209  PackExpansionType, PackExpansionTypeLocInfo> {
2210 public:
2212  return this->getLocalData()->EllipsisLoc;
2213  }
2214 
2216  this->getLocalData()->EllipsisLoc = Loc;
2217  }
2218 
2220  return SourceRange(getEllipsisLoc(), getEllipsisLoc());
2221  }
2222 
2224  setEllipsisLoc(Loc);
2225  }
2226 
2228  return getInnerTypeLoc();
2229  }
2230 
2232  return this->getTypePtr()->getPattern();
2233  }
2234 };
2235 
2237  SourceLocation KWLoc, LParenLoc, RParenLoc;
2238 };
2239 
2240 class AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc,
2241  AtomicType, AtomicTypeLocInfo> {
2242 public:
2244  return this->getInnerTypeLoc();
2245  }
2246 
2248  return SourceRange(getKWLoc(), getRParenLoc());
2249  }
2250 
2252  return this->getLocalData()->KWLoc;
2253  }
2254 
2256  this->getLocalData()->KWLoc = Loc;
2257  }
2258 
2260  return this->getLocalData()->LParenLoc;
2261  }
2262 
2264  this->getLocalData()->LParenLoc = Loc;
2265  }
2266 
2268  return this->getLocalData()->RParenLoc;
2269  }
2270 
2272  this->getLocalData()->RParenLoc = Loc;
2273  }
2274 
2276  return SourceRange(getLParenLoc(), getRParenLoc());
2277  }
2278 
2280  setLParenLoc(Range.getBegin());
2281  setRParenLoc(Range.getEnd());
2282  }
2283 
2285  setKWLoc(Loc);
2286  setLParenLoc(Loc);
2287  setRParenLoc(Loc);
2288  }
2289 
2291  return this->getTypePtr()->getValueType();
2292  }
2293 };
2294 
2297 };
2298 
2299 class PipeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, PipeTypeLoc, PipeType,
2300  PipeTypeLocInfo> {
2301 public:
2302  TypeLoc getValueLoc() const { return this->getInnerTypeLoc(); }
2303 
2304  SourceRange getLocalSourceRange() const { return SourceRange(getKWLoc()); }
2305 
2306  SourceLocation getKWLoc() const { return this->getLocalData()->KWLoc; }
2307  void setKWLoc(SourceLocation Loc) { this->getLocalData()->KWLoc = Loc; }
2308 
2310  setKWLoc(Loc);
2311  }
2312 
2313  QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2314 };
2315 
2316 template <typename T>
2317 inline T TypeLoc::getAsAdjusted() const {
2318  TypeLoc Cur = *this;
2319  while (!T::isKind(Cur)) {
2320  if (auto PTL = Cur.getAs<ParenTypeLoc>())
2321  Cur = PTL.getInnerLoc();
2322  else if (auto ATL = Cur.getAs<AttributedTypeLoc>())
2323  Cur = ATL.getModifiedLoc();
2324  else if (auto ETL = Cur.getAs<ElaboratedTypeLoc>())
2325  Cur = ETL.getNamedTypeLoc();
2326  else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())
2327  Cur = ATL.getOriginalLoc();
2328  else if (auto MQL = Cur.getAs<MacroQualifiedTypeLoc>())
2329  Cur = MQL.getInnerLoc();
2330  else
2331  break;
2332  }
2333  return Cur.getAs<T>();
2334 }
2335 
2336 } // namespace clang
2337 
2338 #endif // LLVM_CLANG_AST_TYPELOC_H
ObjCInterfaceDecl * getIFaceDecl() const
Definition: TypeLoc.h:1056
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:586
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1532
SourceLocation getNameLoc() const
Definition: TypeLoc.h:760
TemplateTypeParmDecl * getDecl() const
Definition: TypeLoc.h:739
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2243
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:414
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
Definition: TypeLoc.cpp:91
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1417
const Attr * TypeAttr
Definition: TypeLoc.h:847
unsigned getLocalDataSize() const
Definition: TypeLoc.h:1189
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1848
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:498
TypeSourceInfo * ClassTInfo
Definition: TypeLoc.h:1263
A (possibly-)qualified type.
Definition: Type.h:643
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1313
SourceLocation TypeArgsRAngleLoc
Definition: TypeLoc.h:908
Wrapper for source info for tag types.
Definition: TypeLoc.h:703
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:405
void setNameEndLoc(SourceLocation Loc)
Definition: TypeLoc.h:1076
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2306
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:275
SourceLocation LParenLoc
Definition: TypeLoc.h:1796
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2307
SourceLocation KWLoc
Definition: TypeLoc.h:2296
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1409
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:167
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1244
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1603
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1423
unsigned getLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition: TypeLoc.h:301
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:557
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2302
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:653
C Language Family Type Representation.
void setWrittenWidthSpec(TypeSpecifierWidth written)
Definition: TypeLoc.h:625
SourceLocation StarLoc
Definition: TypeLoc.h:1203
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:571
HasNoInnerType getInnerType() const
Definition: TypeLoc.h:440
SourceLocation ProtocolLAngleLoc
Definition: TypeLoc.h:909
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:256
The base class of the type hierarchy.
Definition: Type.h:1436
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
Definition: PrimType.h:57
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2126
Wrapper for source info for typedefs.
Definition: TypeLoc.h:666
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1173
A container of type source information.
Definition: Decl.h:86
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:410
Wrapper for source info for pointers decayed from arrays and functions.
Definition: TypeLoc.h:1198
SourceLocation LocalRangeEnd
Definition: TypeLoc.h:1358
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:226
bool hasBaseTypeAsWritten() const
Definition: TypeLoc.h:1005
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3238
void setParensRange(SourceRange range)
Definition: TypeLoc.h:1839
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1827
SourceLocation getExpansionLoc() const
Definition: TypeLoc.h:1104
RangeSelector range(RangeSelector Begin, RangeSelector End)
Selects from the start of Begin and to the end of End.
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location. ...
Definition: TypeLoc.h:192
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1267
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Definition: TypeLoc.h:273
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2304
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:60
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1240
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:1001
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2007
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1725
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:784
void setBegin(SourceLocation b)
SourceLocation RParenLoc
Definition: TypeLoc.h:1797
void * Data
Definition: TypeLoc.h:61
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1144
Expr * getAttrExprOperand() const
The attribute&#39;s expression operand, if it has one.
Definition: TypeLoc.h:1711
Represents a parameter to a function.
Definition: Decl.h:1600
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:1747
SourceLocation NameEndLoc
Definition: TypeLoc.h:1047
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1227
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:1987
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier...
Definition: TypeLoc.h:509
SourceLocation getAmpAmpLoc() const
Definition: TypeLoc.h:1345
SourceLocation NameLoc
Definition: TypeLoc.h:1046
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:960
const Type * getTypePtr() const
Definition: TypeLoc.h:134
bool needsExtraLocalData() const
Definition: TypeLoc.h:578
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:2279
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:531
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:269
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
Represents a struct/union/class.
Definition: Decl.h:3662
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2309
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:813
TypeSpecifierSign getWrittenSignSpec() const
Definition: TypeLoc.h:598
unsigned getExtraLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition: TypeLoc.h:1467
One of these records is kept for each identifier that is lexed.
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1393
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1892
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1913
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:824
SourceLocation TypeArgsLAngleLoc
Definition: TypeLoc.h:907
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1114
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:160
A C++ nested-name-specifier augmented with source location information.
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2284
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1153
void setBuiltinLoc(SourceLocation Loc)
Definition: TypeLoc.h:555
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:1619
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:48
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1876
void setRBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1512
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1068
SourceLocation RBracketLoc
Definition: TypeLoc.h:1490
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1910
SourceLocation ExpansionLoc
Definition: TypeLoc.h:1087
QualType getInnerType() const
Definition: TypeLoc.h:1474
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:965
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2041
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2037
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:973
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2223
ParmVarDecl * getParam(unsigned i) const
Definition: TypeLoc.h:1443
Wrapper for source info for unresolved typename using decls.
Definition: TypeLoc.h:688
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1405
TypeLoc getNextTypeLoc() const
Definition: TypeLoc.h:401
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:807
void copy(DependentTemplateSpecializationTypeLoc Loc)
Definition: TypeLoc.h:2181
__DEVICE__ int max(int __a, int __b)
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1920
Wrapper of type source information for a type with no direct qualifiers.
Definition: TypeLoc.h:247
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1819
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:1599
TypeSpecifierWidth getWrittenWidthSpec() const
Definition: TypeLoc.h:614
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:797
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2263
void setAttr(const Attr *A)
Definition: TypeLoc.h:876
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:523
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2259
void setExpansionLoc(SourceLocation Loc)
Definition: TypeLoc.h:1108
void setCaretLoc(SourceLocation Loc)
Definition: TypeLoc.h:1257
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2150
Wrapper for source info for injected class names of class templates.
Definition: TypeLoc.h:677
friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS)
Definition: TypeLoc.h:215
unsigned getNumProtocols() const
Definition: TypeLoc.h:788
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:985
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1211
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const Type * getClass() const
Definition: TypeLoc.h:1279
Wrapper for source info for functions.
Definition: TypeLoc.h:1362
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Initializes the local data of this type source info block to provide no information.
Definition: TypeLoc.h:287
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2033
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:840
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:833
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1397
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:590
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1831
TypeLoc(const Type *ty, void *opaqueData)
Definition: TypeLoc.h:67
void expandBuiltinRange(SourceRange Range)
Definition: TypeLoc.h:559
bool isNull() const
Definition: TypeLoc.h:118
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1450
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2122
CXXRecordDecl * getDecl() const
Definition: TypeLoc.h:682
Wrapper for source info for ObjC interfaces.
Definition: TypeLoc.h:1051
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6148
SourceRange BuiltinRange
Definition: TypeLoc.h:542
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1454
QualType getInnerType() const
Definition: TypeLoc.h:2231
QualType getInnerType() const
Returns the type before the address space attribute application area.
Definition: TypeLoc.h:1739
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:764
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2063
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1060
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:1623
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:990
QualType getInnerType() const
Definition: TypeLoc.h:1112
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:1627
bool isDefinition() const
True if the tag was defined in this type specifier.
Definition: TypeLoc.h:710
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1385
Represents an ObjC class declaration.
Definition: DeclObjC.h:1171
void copy(ElaboratedTypeLoc Loc)
Definition: TypeLoc.h:2015
SourceLocation findNullabilityLoc() const
Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier), if there is one.
Definition: TypeLoc.cpp:411
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:778
SourceLocation LocalRangeBegin
Definition: TypeLoc.h:1355
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2090
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1704
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:1908
SourceLocation getNameEndLoc() const
Definition: TypeLoc.h:1072
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1187
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:1591
void * getOpaqueData() const
Get the pointer where source information is stored.
Definition: TypeLoc.h:139
TypeLoc()=default
SourceLocation getBuiltinLoc() const
Definition: TypeLoc.h:551
TypeLoc getInnerTypeLoc() const
Definition: TypeLoc.h:442
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition: TypeLoc.h:995
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2219
void * QualifierData
Data associated with the nested-name-specifier location.
Definition: TypeLoc.h:1966
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:1932
SourceRange getLocalSourceRange() const
Get the local source range.
Definition: TypeLoc.h:156
SourceLocation getNameLoc() const
Definition: TypeLoc.h:2053
EnumDecl * getDecl() const
Definition: TypeLoc.h:730
TypeSourceInfo * UnderlyingTInfo
Definition: TypeLoc.h:1899
void setSizeExpr(Expr *Size)
Definition: TypeLoc.h:1524
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2158
QualType getInnerType() const
Definition: TypeLoc.h:1157
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2134
TagDecl * getDecl() const
Definition: TypeLoc.h:707
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:189
bool hasWrittenSignSpec() const
Definition: TypeLoc.h:605
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2130
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1916
Type source information for an attributed type.
Definition: TypeLoc.h:851
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2106
This represents one expression.
Definition: Expr.h:108
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1389
void setModeAttr(bool written)
Definition: TypeLoc.h:648
Declaration of a template type parameter.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition: TypeLoc.h:322
SourceRange getBracketsRange() const
Definition: TypeLoc.h:1516
__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:86
bool hasWrittenTypeSpec() const
Definition: TypeLoc.h:632
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1291
#define bool
Definition: stdbool.h:15
void setWrittenSignSpec(TypeSpecifierSign written)
Definition: TypeLoc.h:609
SourceLocation getCaretLoc() const
Definition: TypeLoc.h:1253
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2211
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1223
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2271
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1064
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1823
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1381
Wrapper for source info for enum types.
Definition: TypeLoc.h:726
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:768
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2215
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition: TypeLoc.h:748
SourceLocation LParenLoc
Definition: TypeLoc.h:1120
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:1009
SourceLocation getEnd() const
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1098
SourceLocation getKWLoc() const
Definition: TypeLoc.h:1907
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1844
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1911
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2046
TypeSourceInfo * UnderlyingTInfo
Definition: TypeLoc.h:1804
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:2317
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1446
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1296
SourceLocation TypeofLoc
Definition: TypeLoc.h:1795
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1275
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:2162
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:1815
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2061
Wrapper for source info for arrays.
Definition: TypeLoc.h:1495
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2247
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1953
QualType getInnerType() const
Definition: TypeLoc.h:2290
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2227
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:1029
TypeLoc IgnoreParens() const
Definition: TypeLoc.h:1162
SourceLocation LParenLoc
Definition: TypeLoc.h:1356
void * getExtraLocalData() const
Gets a pointer past the Info structure; useful for classes with local data that can&#39;t be captured in ...
Definition: TypeLoc.h:425
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2142
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:873
Encodes a location in the source.
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1309
SourceLocation RParenLoc
Definition: TypeLoc.h:1357
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1148
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:774
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3133
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:977
A metaprogramming base class for TypeLoc classes which correspond to a particular Type subclass...
Definition: TypeLoc.h:357
const T * getAttrAs()
Definition: TypeLoc.h:880
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1132
friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS)
Definition: TypeLoc.h:219
RecordDecl * getDecl() const
Definition: TypeLoc.h:722
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1177
SourceLocation ProtocolRAngleLoc
Definition: TypeLoc.h:910
SourceLocation RParenLoc
Definition: TypeLoc.h:1121
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1271
QualType getInnerType() const
Definition: TypeLoc.h:2313
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:527
UnqualTypeLoc(const Type *Ty, void *Data)
Definition: TypeLoc.h:250
bool hasWrittenWidthSpec() const
Definition: TypeLoc.h:621
SourceLocation NameLoc
Definition: TypeLoc.h:504
TypeLocClass
The kinds of TypeLocs.
Definition: TypeLoc.h:105
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2094
QualType getInnerType() const
Definition: TypeLoc.h:1231
void setWrittenTypeSpec(TypeSpecifierType written)
Definition: TypeLoc.h:636
void setAmpLoc(SourceLocation Loc)
Definition: TypeLoc.h:1335
void setLBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1504
SourceLocation ElaboratedKWLoc
Definition: TypeLoc.h:1963
TypeClass getTypeClass() const
Definition: Type.h:1851
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:820
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:1607
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
Definition: TypeLoc.cpp:422
A metaprogramming class designed for concrete subtypes of abstract types where all subtypes share equ...
Definition: TypeLoc.h:482
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1428
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:161
const void * Ty
Definition: TypeLoc.h:60
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:690
QualType getInnerType() const
Definition: TypeLoc.h:901
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1528
Defines various enumerations that describe declaration and type specifiers.
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1401
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1595
TypeLoc(QualType ty, void *opaqueData)
Definition: TypeLoc.h:65
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:939
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2985
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:1811
Represents a template argument.
Definition: TemplateBase.h:50
unsigned getLocalDataAlignment() const
Definition: TypeLoc.h:374
ParmVarDecl ** getParmArray() const
Definition: TypeLoc.h:1433
TypeSourceInfo * getClassTInfo() const
Definition: TypeLoc.h:1283
void setClassTInfo(TypeSourceInfo *TI)
Definition: TypeLoc.h:1287
const Type * getTypePtr() const
Definition: TypeLoc.h:252
QualType getInnerType() const
Definition: TypeLoc.h:2011
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:897
Dataflow Directional Tag Classes.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
void setAmpAmpLoc(SourceLocation Loc)
Definition: TypeLoc.h:1349
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1536
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:130
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:594
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:2166
QualType getInnerType() const
Definition: TypeLoc.h:1542
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:745
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3590
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:558
void * getNonLocalData() const
Definition: TypeLoc.h:432
LocalData * getLocalData() const
Definition: TypeLoc.h:418
Represents an enum.
Definition: Decl.h:3395
SourceLocation NameLoc
Definition: TypeLoc.h:1576
void setSigilLoc(SourceLocation Loc)
Definition: TypeLoc.h:1215
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:868
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1017
ObjCTypeParamDecl * getDecl() const
Definition: TypeLoc.h:758
bool hasModeAttr() const
Definition: TypeLoc.h:641
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:1982
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:1974
unsigned getNumParams() const
Definition: TypeLoc.h:1437
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2057
SourceLocation getRBracketLoc() const
Definition: TypeLoc.h:1508
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:150
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1034
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1219
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:449
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1994
static bool classof(const OMPClause *T)
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition: TypeLoc.h:955
TypedefNameDecl * getTypedefNameDecl() const
Definition: TypeLoc.h:670
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1631
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2251
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2267
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1957
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
Definition: TypeLoc.h:574
unsigned getLocalDataSize() const
Definition: TypeLoc.h:379
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:792
Expr * getSizeExpr() const
Definition: TypeLoc.h:1520
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:113
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:947
Wrapper for source info for record types.
Definition: TypeLoc.h:718
UnresolvedUsingTypenameDecl * getDecl() const
Definition: TypeLoc.h:693
SourceLocation getLBracketLoc() const
Definition: TypeLoc.h:1500
void copy(TemplateSpecializationTypeLoc Loc)
Definition: TypeLoc.h:1640
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1305
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1658
QualType getInnerType() const
Definition: TypeLoc.h:1321
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1128
TypeLoc getBaseLoc() const
Definition: TypeLoc.h:1013
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:103
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:277
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:240
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
SourceLocation getTypeArgsLAngleLoc() const
Definition: TypeLoc.h:935
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2255
SourceLocation NameLoc
Definition: TypeLoc.h:2025
QualType getInnerType() const
Definition: TypeLoc.h:1181
SourceRange getParensRange() const
Definition: TypeLoc.h:1835
Defines the clang::SourceLocation class and associated facilities.
void setEnd(SourceLocation e)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:40
TypeLoc IgnoreMacroDefinitions() const
Strips MacroDefinitionTypeLocs from a type location.
QualType getInnerType() const
Definition: TypeLoc.h:1040
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1444
void copyLocal(TypeLoc other)
Definition: TypeLoc.h:291
static unsigned getLocalAlignmentForType(QualType Ty)
Returns the alignment of type source info data block for the given type.
Definition: TypeLoc.cpp:71
TypeLoc getNextTypeLoc() const
Definition: TypeLoc.h:295
void copyLocal(Derived other)
Definition: TypeLoc.h:387
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1651
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1472
unsigned getNumProtocols() const
Definition: TypeLoc.h:981
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1136
SourceLocation RParenLoc
Definition: TypeLoc.h:2237
Location information for a TemplateArgument.
Definition: TemplateBase.h:392
SourceRange getParensRange() const
Definition: TypeLoc.h:1928
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1080
bool isQualifier() const
Definition: TypeLoc.h:860
const IdentifierInfo * getMacroIdentifier() const
Definition: TypeLoc.h:1100
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:1672
__DEVICE__ int min(int __a, int __b)
SourceLocation getNameLoc() const
Definition: TypeLoc.h:519
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1914
QualType getUnderlyingType() const
Definition: TypeLoc.h:1872
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1611
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:1722
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:951
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition: TypeLoc.h:802
SourceLocation getAmpLoc() const
Definition: TypeLoc.h:1331
void copy(TypeLoc other)
Copies the other type loc into this one.
Definition: TypeLoc.cpp:165
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:969
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1701
attr::Kind getAttrKind() const
Definition: TypeLoc.h:856
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
Definition: TypeLoc.h:198
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1676
Wrapper for source info for builtin types.
Definition: TypeLoc.h:546
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1140
Wrapper for template type parameters.
Definition: TypeLoc.h:734
A trivial tuple used to represent a source range.
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1924
void copy(DependentNameTypeLoc Loc)
Definition: TypeLoc.h:2068
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
Definition: TypeLoc.h:75
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1635
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2098
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1859
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1562
A base class for.
Definition: TypeLoc.h:1208
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:884
void initializeFullCopy(TypeLoc Other, unsigned Size)
Initializes this by copying its information from another TypeLoc of the same type.
Definition: TypeLoc.h:206
SourceRange getParensRange() const
Definition: TypeLoc.h:2275
SourceLocation getNameLoc() const
Definition: TypeLoc.h:569
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1729
Wrapper for source info for pointers.
Definition: TypeLoc.h:1237
SourceLocation getBegin() const
unsigned getLocalDataAlignment() const
Returns the alignment of the type source info data block that is specific to this type...
Definition: TypeLoc.h:309
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1250
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1978
Attr - This represents one attribute.
Definition: Attr.h:45
SourceLocation getLocation() const
Definition: DeclBase.h:429
SourceLocation getTypeArgsRAngleLoc() const
Definition: TypeLoc.h:943
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1094
void setUnderlyingTInfo(TypeSourceInfo *TI) const
Definition: TypeLoc.h:1880
SourceRange getParensRange() const
Definition: TypeLoc.h:1413