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