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