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