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