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