clang 17.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
20#include "clang/AST/Type.h"
21#include "clang/Basic/LLVM.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
33namespace clang {
34
35class Attr;
36class ASTContext;
37class CXXRecordDecl;
38class ConceptDecl;
39class Expr;
40class ObjCInterfaceDecl;
41class ObjCProtocolDecl;
42class ObjCTypeParamDecl;
43class ParmVarDecl;
44class TemplateTypeParmDecl;
45class UnqualTypeLoc;
46class 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.
58class TypeLoc {
59protected:
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
65public:
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.
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.
147
148 /// Get the end source location.
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
231private:
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
243inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) {
244 // Init data attached to the object. See getTypeLoc.
245 memset(this + 1, 0, DataSize);
246}
247
248/// Return the TypeLoc for a type source info.
250 // TODO: is this alignment already sufficient?
251 return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1)));
252}
253
254/// Wrapper of type source information for a type with
255/// no direct qualifiers.
256class UnqualTypeLoc : public TypeLoc {
257public:
258 UnqualTypeLoc() = default;
259 UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
260
261 const Type *getTypePtr() const {
262 return reinterpret_cast<const Type*>(Ty);
263 }
264
267 }
268
269private:
270 friend class TypeLoc;
271
272 static bool isKind(const TypeLoc &TL) {
273 return !TL.getType().hasLocalQualifiers();
274 }
275};
276
277/// Wrapper of type source information for a type with
278/// non-trivial direct qualifiers.
279///
280/// Currently, we intentionally do not provide source location for
281/// type qualifiers.
282class QualifiedTypeLoc : public TypeLoc {
283public:
284 SourceRange getLocalSourceRange() const { return {}; }
285
287 unsigned align =
289 auto dataInt = reinterpret_cast<uintptr_t>(Data);
290 dataInt = llvm::alignTo(dataInt, align);
291 return UnqualTypeLoc(getTypePtr(), reinterpret_cast<void*>(dataInt));
292 }
293
294 /// Initializes the local data of this type source info block to
295 /// provide no information.
297 // do nothing
298 }
299
300 void copyLocal(TypeLoc other) {
301 // do nothing
302 }
303
305 return getUnqualifiedLoc();
306 }
307
308 /// Returns the size of the type source info data block that is
309 /// specific to this type.
310 unsigned getLocalDataSize() const {
311 // In fact, we don't currently preserve any location information
312 // for qualifiers.
313 return 0;
314 }
315
316 /// Returns the alignment of the type source info data block that is
317 /// specific to this type.
318 unsigned getLocalDataAlignment() const {
319 // We don't preserve any location information.
320 return 1;
321 }
322
323private:
324 friend class TypeLoc;
325
326 static bool isKind(const TypeLoc &TL) {
327 return TL.getType().hasLocalQualifiers();
328 }
329};
330
332 if (QualifiedTypeLoc Loc = getAs<QualifiedTypeLoc>())
333 return Loc.getUnqualifiedLoc();
334 return castAs<UnqualTypeLoc>();
335}
336
337/// A metaprogramming base class for TypeLoc classes which correspond
338/// to a particular Type subclass. It is accepted for a single
339/// TypeLoc class to correspond to multiple Type classes.
340///
341/// \tparam Base a class from which to derive
342/// \tparam Derived the class deriving from this one
343/// \tparam TypeClass the concrete Type subclass associated with this
344/// location type
345/// \tparam LocalData the structure type of local location data for
346/// this type
347///
348/// TypeLocs with non-constant amounts of local data should override
349/// getExtraLocalDataSize(); getExtraLocalData() will then point to
350/// this extra memory.
351///
352/// TypeLocs with an inner type should define
353/// QualType getInnerType() const
354/// and getInnerTypeLoc() will then point to this inner type's
355/// location data.
356///
357/// A word about hierarchies: this template is not designed to be
358/// derived from multiple times in a hierarchy. It is also not
359/// designed to be used for classes where subtypes might provide
360/// different amounts of source information. It should be subclassed
361/// only at the deepest portion of the hierarchy where all children
362/// have identical source information; if that's an abstract type,
363/// then further descendents should inherit from
364/// InheritingConcreteTypeLoc instead.
365template <class Base, class Derived, class TypeClass, class LocalData>
366class ConcreteTypeLoc : public Base {
367 friend class TypeLoc;
368
369 const Derived *asDerived() const {
370 return static_cast<const Derived*>(this);
371 }
372
373 static bool isKind(const TypeLoc &TL) {
374 return !TL.getType().hasLocalQualifiers() &&
375 Derived::classofType(TL.getTypePtr());
376 }
377
378 static bool classofType(const Type *Ty) {
379 return TypeClass::classof(Ty);
380 }
381
382public:
383 unsigned getLocalDataAlignment() const {
384 return std::max(unsigned(alignof(LocalData)),
385 asDerived()->getExtraLocalDataAlignment());
386 }
387
388 unsigned getLocalDataSize() const {
389 unsigned size = sizeof(LocalData);
390 unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
391 size = llvm::alignTo(size, extraAlign);
392 size += asDerived()->getExtraLocalDataSize();
393 return size;
394 }
395
396 void copyLocal(Derived other) {
397 // Some subclasses have no data to copy.
398 if (asDerived()->getLocalDataSize() == 0) return;
399
400 // Copy the fixed-sized local data.
401 memcpy(getLocalData(), other.getLocalData(), sizeof(LocalData));
402
403 // Copy the variable-sized local data. We need to do this
404 // separately because the padding in the source and the padding in
405 // the destination might be different.
406 memcpy(getExtraLocalData(), other.getExtraLocalData(),
407 asDerived()->getExtraLocalDataSize());
408 }
409
411 return getNextTypeLoc(asDerived()->getInnerType());
412 }
413
414 const TypeClass *getTypePtr() const {
415 return cast<TypeClass>(Base::getTypePtr());
416 }
417
418protected:
419 unsigned getExtraLocalDataSize() const {
420 return 0;
421 }
422
423 unsigned getExtraLocalDataAlignment() const {
424 return 1;
425 }
426
427 LocalData *getLocalData() const {
428 return static_cast<LocalData*>(Base::Data);
429 }
430
431 /// Gets a pointer past the Info structure; useful for classes with
432 /// local data that can't be captured in the Info (e.g. because it's
433 /// of variable size).
434 void *getExtraLocalData() const {
435 unsigned size = sizeof(LocalData);
436 unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
437 size = llvm::alignTo(size, extraAlign);
438 return reinterpret_cast<char *>(Base::Data) + size;
439 }
440
441 void *getNonLocalData() const {
442 auto data = reinterpret_cast<uintptr_t>(Base::Data);
443 data += asDerived()->getLocalDataSize();
444 data = llvm::alignTo(data, getNextTypeAlign());
445 return reinterpret_cast<void*>(data);
446 }
447
448 struct HasNoInnerType {};
450
452 return TypeLoc(asDerived()->getInnerType(), getNonLocalData());
453 }
454
455private:
456 unsigned getInnerTypeSize() const {
457 return getInnerTypeSize(asDerived()->getInnerType());
458 }
459
460 unsigned getInnerTypeSize(HasNoInnerType _) const {
461 return 0;
462 }
463
464 unsigned getInnerTypeSize(QualType _) const {
466 }
467
468 unsigned getNextTypeAlign() const {
469 return getNextTypeAlign(asDerived()->getInnerType());
470 }
471
472 unsigned getNextTypeAlign(HasNoInnerType _) const {
473 return 1;
474 }
475
476 unsigned getNextTypeAlign(QualType T) const {
478 }
479
480 TypeLoc getNextTypeLoc(HasNoInnerType _) const { return {}; }
481
482 TypeLoc getNextTypeLoc(QualType T) const {
483 return TypeLoc(T, getNonLocalData());
484 }
485};
486
487/// A metaprogramming class designed for concrete subtypes of abstract
488/// types where all subtypes share equivalently-structured source
489/// information. See the note on ConcreteTypeLoc.
490template <class Base, class Derived, class TypeClass>
492 friend class TypeLoc;
493
494 static bool classofType(const Type *Ty) {
495 return TypeClass::classof(Ty);
496 }
497
498 static bool isKind(const TypeLoc &TL) {
499 return !TL.getType().hasLocalQualifiers() &&
500 Derived::classofType(TL.getTypePtr());
501 }
502 static bool isKind(const UnqualTypeLoc &TL) {
503 return Derived::classofType(TL.getTypePtr());
504 }
505
506public:
507 const TypeClass *getTypePtr() const {
508 return cast<TypeClass>(Base::getTypePtr());
509 }
510};
511
514};
515
516/// A reasonable base class for TypeLocs that correspond to
517/// types that are written as a type-specifier.
518class TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
519 TypeSpecTypeLoc,
520 Type,
521 TypeSpecLocInfo> {
522public:
523 enum {
526 };
527
529 return this->getLocalData()->NameLoc;
530 }
531
533 this->getLocalData()->NameLoc = Loc;
534 }
535
537 return SourceRange(getNameLoc(), getNameLoc());
538 }
539
541 setNameLoc(Loc);
542 }
543
544private:
545 friend class TypeLoc;
546
547 static bool isKind(const TypeLoc &TL);
548};
549
552};
553
554/// Wrapper for source info for builtin types.
555class BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
556 BuiltinTypeLoc,
557 BuiltinType,
558 BuiltinLocInfo> {
559public:
562 }
563
565 getLocalData()->BuiltinRange = Loc;
566 }
567
569 SourceRange &BuiltinRange = getLocalData()->BuiltinRange;
570 if (!BuiltinRange.getBegin().isValid()) {
571 BuiltinRange = Range;
572 } else {
573 BuiltinRange.setBegin(std::min(Range.getBegin(), BuiltinRange.getBegin()));
574 BuiltinRange.setEnd(std::max(Range.getEnd(), BuiltinRange.getEnd()));
575 }
576 }
577
579
581 return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
582 }
584 return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
585 }
586
587 bool needsExtraLocalData() const {
589 return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) ||
590 (bk >= BuiltinType::Short && bk <= BuiltinType::Ibm128) ||
591 bk == BuiltinType::UChar || bk == BuiltinType::SChar;
592 }
593
594 unsigned getExtraLocalDataSize() const {
595 return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0;
596 }
597
598 unsigned getExtraLocalDataAlignment() const {
599 return needsExtraLocalData() ? alignof(WrittenBuiltinSpecs) : 1;
600 }
601
603 return getLocalData()->BuiltinRange;
604 }
605
608 return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign);
609 else
611 }
612
613 bool hasWrittenSignSpec() const {
615 }
616
619 getWrittenBuiltinSpecs().Sign = static_cast<unsigned>(written);
620 }
621
624 return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width);
625 else
627 }
628
629 bool hasWrittenWidthSpec() const {
631 }
632
635 getWrittenBuiltinSpecs().Width = static_cast<unsigned>(written);
636 }
637
639
640 bool hasWrittenTypeSpec() const {
642 }
643
646 getWrittenBuiltinSpecs().Type = written;
647 }
648
649 bool hasModeAttr() const {
652 else
653 return false;
654 }
655
656 void setModeAttr(bool written) {
659 }
660
662 setBuiltinLoc(Loc);
663 if (needsExtraLocalData()) {
665 wbs.Sign = static_cast<unsigned>(TypeSpecifierSign::Unspecified);
666 wbs.Width = static_cast<unsigned>(TypeSpecifierWidth::Unspecified);
667 wbs.Type = TST_unspecified;
668 wbs.ModeAttr = false;
669 }
670 }
671};
672
673/// Wrapper for source info for types used via transparent aliases.
674class UsingTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
675 UsingTypeLoc, UsingType> {
676public:
678 return getTypePtr()->getUnderlyingType();
679 }
681};
682
683/// Wrapper for source info for typedefs.
684class TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
685 TypedefTypeLoc,
686 TypedefType> {
687public:
689 return getTypePtr()->getDecl();
690 }
691};
692
693/// Wrapper for source info for injected class names of class
694/// templates.
696 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
697 InjectedClassNameTypeLoc,
698 InjectedClassNameType> {
699public:
701 return getTypePtr()->getDecl();
702 }
703};
704
705/// Wrapper for source info for unresolved typename using decls.
707 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
708 UnresolvedUsingTypeLoc,
709 UnresolvedUsingType> {
710public:
712 return getTypePtr()->getDecl();
713 }
714};
715
716/// Wrapper for source info for tag types. Note that this only
717/// records source info for the name itself; a type written 'struct foo'
718/// should be represented as an ElaboratedTypeLoc. We currently
719/// only do that when C++ is enabled because of the expense of
720/// creating an ElaboratedType node for so many type references in C.
721class TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
722 TagTypeLoc,
723 TagType> {
724public:
725 TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
726
727 /// True if the tag was defined in this type specifier.
728 bool isDefinition() const;
729};
730
731/// Wrapper for source info for record types.
732class RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
733 RecordTypeLoc,
734 RecordType> {
735public:
736 RecordDecl *getDecl() const { return getTypePtr()->getDecl(); }
737};
738
739/// Wrapper for source info for enum types.
740class EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
741 EnumTypeLoc,
742 EnumType> {
743public:
744 EnumDecl *getDecl() const { return getTypePtr()->getDecl(); }
745};
746
747/// Wrapper for template type parameters.
749 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
750 TemplateTypeParmTypeLoc,
751 TemplateTypeParmType> {
752public:
754};
755
758};
759
760/// ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for
761/// protocol qualifiers are stored after Info.
762class ObjCTypeParamTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
763 ObjCTypeParamTypeLoc,
764 ObjCTypeParamType,
765 ObjCTypeParamTypeLocInfo> {
766 // SourceLocations are stored after Info, one for each protocol qualifier.
767 SourceLocation *getProtocolLocArray() const {
768 return (SourceLocation*)this->getExtraLocalData() + 2;
769 }
770
771public:
772 ObjCTypeParamDecl *getDecl() const { return getTypePtr()->getDecl(); }
773
775 return this->getLocalData()->NameLoc;
776 }
777
779 this->getLocalData()->NameLoc = Loc;
780 }
781
783 return getNumProtocols() ?
784 *((SourceLocation*)this->getExtraLocalData()) :
786 }
787
789 *((SourceLocation*)this->getExtraLocalData()) = Loc;
790 }
791
793 return getNumProtocols() ?
794 *((SourceLocation*)this->getExtraLocalData() + 1) :
796 }
797
799 *((SourceLocation*)this->getExtraLocalData() + 1) = Loc;
800 }
801
802 unsigned getNumProtocols() const {
803 return this->getTypePtr()->getNumProtocols();
804 }
805
806 SourceLocation getProtocolLoc(unsigned i) const {
807 assert(i < getNumProtocols() && "Index is out of bounds!");
808 return getProtocolLocArray()[i];
809 }
810
811 void setProtocolLoc(unsigned i, SourceLocation Loc) {
812 assert(i < getNumProtocols() && "Index is out of bounds!");
813 getProtocolLocArray()[i] = Loc;
814 }
815
816 ObjCProtocolDecl *getProtocol(unsigned i) const {
817 assert(i < getNumProtocols() && "Index is out of bounds!");
818 return *(this->getTypePtr()->qual_begin() + i);
819 }
820
822 return llvm::ArrayRef(getProtocolLocArray(), getNumProtocols());
823 }
824
825 void initializeLocal(ASTContext &Context, SourceLocation Loc);
826
827 unsigned getExtraLocalDataSize() const {
828 if (!this->getNumProtocols()) return 0;
829 // When there are protocol qualifers, we have LAngleLoc and RAngleLoc
830 // as well.
831 return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ;
832 }
833
834 unsigned getExtraLocalDataAlignment() const {
835 return alignof(SourceLocation);
836 }
837
839 SourceLocation start = getNameLoc();
841 if (end.isInvalid()) return SourceRange(start, start);
842 return SourceRange(start, end);
843 }
844};
845
846/// Wrapper for substituted template type parameters.
848 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
849 SubstTemplateTypeParmTypeLoc,
850 SubstTemplateTypeParmType> {
851};
852
853 /// Wrapper for substituted template type parameters.
855 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
856 SubstTemplateTypeParmPackTypeLoc,
857 SubstTemplateTypeParmPackType> {
858};
859
862};
863
864/// Type source information for an attributed type.
865class AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
866 AttributedTypeLoc,
867 AttributedType,
868 AttributedLocInfo> {
869public:
871 return getTypePtr()->getAttrKind();
872 }
873
874 bool isQualifier() const {
875 return getTypePtr()->isQualifier();
876 }
877
878 /// The modified type, which is generally canonically different from
879 /// the attribute type.
880 /// int main(int, char**) __attribute__((noreturn))
881 /// ~~~ ~~~~~~~~~~~~~
883 return getInnerTypeLoc();
884 }
885
886 /// The type attribute.
887 const Attr *getAttr() const {
888 return getLocalData()->TypeAttr;
889 }
890 void setAttr(const Attr *A) {
891 getLocalData()->TypeAttr = A;
892 }
893
894 template<typename T> const T *getAttrAs() {
895 return dyn_cast_or_null<T>(getAttr());
896 }
897
899
901 setAttr(nullptr);
902 }
903
905 return getTypePtr()->getModifiedType();
906 }
907};
908
909struct BTFTagAttributedLocInfo {}; // Nothing.
910
911/// Type source information for an btf_tag attributed type.
913 : public ConcreteTypeLoc<UnqualTypeLoc, BTFTagAttributedTypeLoc,
914 BTFTagAttributedType, BTFTagAttributedLocInfo> {
915public:
917
918 /// The btf_type_tag attribute.
919 const BTFTypeTagAttr *getAttr() const { return getTypePtr()->getAttr(); }
920
921 template <typename T> T *getAttrAs() {
922 return dyn_cast_or_null<T>(getAttr());
923 }
924
926
928
930};
931
938};
939
940// A helper class for defining ObjC TypeLocs that can qualified with
941// protocols.
942//
943// TypeClass basically has to be either ObjCInterfaceType or
944// ObjCObjectPointerType.
945class ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
946 ObjCObjectTypeLoc,
947 ObjCObjectType,
948 ObjCObjectTypeLocInfo> {
949 // TypeSourceInfo*'s are stored after Info, one for each type argument.
950 TypeSourceInfo **getTypeArgLocArray() const {
951 return (TypeSourceInfo**)this->getExtraLocalData();
952 }
953
954 // SourceLocations are stored after the type argument information, one for
955 // each Protocol.
956 SourceLocation *getProtocolLocArray() const {
957 return (SourceLocation*)(getTypeArgLocArray() + getNumTypeArgs());
958 }
959
960public:
962 return this->getLocalData()->TypeArgsLAngleLoc;
963 }
964
966 this->getLocalData()->TypeArgsLAngleLoc = Loc;
967 }
968
970 return this->getLocalData()->TypeArgsRAngleLoc;
971 }
972
974 this->getLocalData()->TypeArgsRAngleLoc = Loc;
975 }
976
977 unsigned getNumTypeArgs() const {
978 return this->getTypePtr()->getTypeArgsAsWritten().size();
979 }
980
981 TypeSourceInfo *getTypeArgTInfo(unsigned i) const {
982 assert(i < getNumTypeArgs() && "Index is out of bounds!");
983 return getTypeArgLocArray()[i];
984 }
985
986 void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo) {
987 assert(i < getNumTypeArgs() && "Index is out of bounds!");
988 getTypeArgLocArray()[i] = TInfo;
989 }
990
992 return this->getLocalData()->ProtocolLAngleLoc;
993 }
994
996 this->getLocalData()->ProtocolLAngleLoc = Loc;
997 }
998
1000 return this->getLocalData()->ProtocolRAngleLoc;
1001 }
1002
1004 this->getLocalData()->ProtocolRAngleLoc = Loc;
1005 }
1006
1007 unsigned getNumProtocols() const {
1008 return this->getTypePtr()->getNumProtocols();
1009 }
1010
1011 SourceLocation getProtocolLoc(unsigned i) const {
1012 assert(i < getNumProtocols() && "Index is out of bounds!");
1013 return getProtocolLocArray()[i];
1014 }
1015
1016 void setProtocolLoc(unsigned i, SourceLocation Loc) {
1017 assert(i < getNumProtocols() && "Index is out of bounds!");
1018 getProtocolLocArray()[i] = Loc;
1019 }
1020
1021 ObjCProtocolDecl *getProtocol(unsigned i) const {
1022 assert(i < getNumProtocols() && "Index is out of bounds!");
1023 return *(this->getTypePtr()->qual_begin() + i);
1024 }
1025
1026
1028 return llvm::ArrayRef(getProtocolLocArray(), getNumProtocols());
1029 }
1030
1033 }
1034
1035 void setHasBaseTypeAsWritten(bool HasBaseType) {
1036 getLocalData()->HasBaseTypeAsWritten = HasBaseType;
1037 }
1038
1040 return getInnerTypeLoc();
1041 }
1042
1045 if (start.isInvalid())
1046 start = getProtocolLAngleLoc();
1048 if (end.isInvalid())
1049 end = getTypeArgsRAngleLoc();
1050 return SourceRange(start, end);
1051 }
1052
1053 void initializeLocal(ASTContext &Context, SourceLocation Loc);
1054
1055 unsigned getExtraLocalDataSize() const {
1056 return this->getNumTypeArgs() * sizeof(TypeSourceInfo *)
1057 + this->getNumProtocols() * sizeof(SourceLocation);
1058 }
1059
1061 static_assert(alignof(ObjCObjectTypeLoc) >= alignof(TypeSourceInfo *),
1062 "not enough alignment for tail-allocated data");
1063 return alignof(TypeSourceInfo *);
1064 }
1065
1067 return getTypePtr()->getBaseType();
1068 }
1069};
1070
1074};
1075
1076/// Wrapper for source info for ObjC interfaces.
1077class ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc,
1078 ObjCInterfaceTypeLoc,
1079 ObjCInterfaceType,
1080 ObjCInterfaceLocInfo> {
1081public:
1083 return getTypePtr()->getDecl();
1084 }
1085
1087 return getLocalData()->NameLoc;
1088 }
1089
1091 getLocalData()->NameLoc = Loc;
1092 }
1093
1096 }
1097
1099 return getLocalData()->NameEndLoc;
1100 }
1101
1103 getLocalData()->NameEndLoc = Loc;
1104 }
1105
1107 setNameLoc(Loc);
1108 setNameEndLoc(Loc);
1109 }
1110};
1111
1114};
1115
1117 : public ConcreteTypeLoc<UnqualTypeLoc, MacroQualifiedTypeLoc,
1118 MacroQualifiedType, MacroQualifiedLocInfo> {
1119public:
1121 setExpansionLoc(Loc);
1122 }
1123
1125
1127 return getTypePtr()->getMacroIdentifier();
1128 }
1129
1131 return this->getLocalData()->ExpansionLoc;
1132 }
1133
1135 this->getLocalData()->ExpansionLoc = Loc;
1136 }
1137
1139
1142 }
1143};
1144
1148};
1149
1151 : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
1152 ParenLocInfo> {
1153public:
1155 return this->getLocalData()->LParenLoc;
1156 }
1157
1159 return this->getLocalData()->RParenLoc;
1160 }
1161
1163 this->getLocalData()->LParenLoc = Loc;
1164 }
1165
1167 this->getLocalData()->RParenLoc = Loc;
1168 }
1169
1172 }
1173
1175 setLParenLoc(Loc);
1176 setRParenLoc(Loc);
1177 }
1178
1180 return getInnerTypeLoc();
1181 }
1182
1184 return this->getTypePtr()->getInnerType();
1185 }
1186};
1187
1189 if (ParenTypeLoc::isKind(*this))
1190 return IgnoreParensImpl(*this);
1191 return *this;
1192}
1193
1194struct AdjustedLocInfo {}; // Nothing.
1195
1196class AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc,
1197 AdjustedType, AdjustedLocInfo> {
1198public:
1200 return getInnerTypeLoc();
1201 }
1202
1204 // do nothing
1205 }
1206
1208 // The inner type is the undecayed type, since that's what we have source
1209 // location information for.
1210 return getTypePtr()->getOriginalType();
1211 }
1212
1213 SourceRange getLocalSourceRange() const { return {}; }
1214
1215 unsigned getLocalDataSize() const {
1216 // sizeof(AdjustedLocInfo) is 1, but we don't need its address to be unique
1217 // anyway. TypeLocBuilder can't handle data sizes of 1.
1218 return 0; // No data.
1219 }
1220};
1221
1222/// Wrapper for source info for pointers decayed from arrays and
1223/// functions.
1225 AdjustedTypeLoc, DecayedTypeLoc, DecayedType> {
1226};
1227
1230};
1231
1232/// A base class for
1233template <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
1234class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
1235 TypeClass, LocalData> {
1236public:
1238 return this->getLocalData()->StarLoc;
1239 }
1240
1242 this->getLocalData()->StarLoc = Loc;
1243 }
1244
1246 return this->getInnerTypeLoc();
1247 }
1248
1250 return SourceRange(getSigilLoc(), getSigilLoc());
1251 }
1252
1254 setSigilLoc(Loc);
1255 }
1256
1258 return this->getTypePtr()->getPointeeType();
1259 }
1260};
1261
1262/// Wrapper for source info for pointers.
1263class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
1264 PointerType> {
1265public:
1267 return getSigilLoc();
1268 }
1269
1271 setSigilLoc(Loc);
1272 }
1273};
1274
1275/// Wrapper for source info for block pointers.
1276class BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
1277 BlockPointerType> {
1278public:
1280 return getSigilLoc();
1281 }
1282
1284 setSigilLoc(Loc);
1285 }
1286};
1287
1290};
1291
1292/// Wrapper for source info for member pointers.
1293class MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
1294 MemberPointerType,
1295 MemberPointerLocInfo> {
1296public:
1298 return getSigilLoc();
1299 }
1300
1302 setSigilLoc(Loc);
1303 }
1304
1305 const Type *getClass() const {
1306 return getTypePtr()->getClass();
1307 }
1308
1310 return getLocalData()->ClassTInfo;
1311 }
1312
1314 getLocalData()->ClassTInfo = TI;
1315 }
1316
1318 setSigilLoc(Loc);
1319 setClassTInfo(nullptr);
1320 }
1321
1323 if (TypeSourceInfo *TI = getClassTInfo())
1324 return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc());
1325 else
1326 return SourceRange(getStarLoc());
1327 }
1328};
1329
1330/// Wraps an ObjCPointerType with source location information.
1332 public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
1333 ObjCObjectPointerType> {
1334public:
1336 return getSigilLoc();
1337 }
1338
1340 setSigilLoc(Loc);
1341 }
1342};
1343
1344class ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
1345 ReferenceType> {
1346public:
1348 return getTypePtr()->getPointeeTypeAsWritten();
1349 }
1350};
1351
1353 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1354 LValueReferenceTypeLoc,
1355 LValueReferenceType> {
1356public:
1358 return getSigilLoc();
1359 }
1360
1362 setSigilLoc(Loc);
1363 }
1364};
1365
1367 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1368 RValueReferenceTypeLoc,
1369 RValueReferenceType> {
1370public:
1372 return getSigilLoc();
1373 }
1374
1376 setSigilLoc(Loc);
1377 }
1378};
1379
1385};
1386
1387/// Wrapper for source info for functions.
1388class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1389 FunctionTypeLoc,
1390 FunctionType,
1391 FunctionLocInfo> {
1392 bool hasExceptionSpec() const {
1393 if (auto *FPT = dyn_cast<FunctionProtoType>(getTypePtr())) {
1394 return FPT->hasExceptionSpec();
1395 }
1396 return false;
1397 }
1398
1399 SourceRange *getExceptionSpecRangePtr() const {
1400 assert(hasExceptionSpec() && "No exception spec range");
1401 // After the Info comes the ParmVarDecl array, and after that comes the
1402 // exception specification information.
1403 return (SourceRange *)(getParmArray() + getNumParams());
1404 }
1405
1406public:
1408 return getLocalData()->LocalRangeBegin;
1409 }
1410
1413 }
1414
1416 return getLocalData()->LocalRangeEnd;
1417 }
1418
1421 }
1422
1424 return this->getLocalData()->LParenLoc;
1425 }
1426
1428 this->getLocalData()->LParenLoc = Loc;
1429 }
1430
1432 return this->getLocalData()->RParenLoc;
1433 }
1434
1436 this->getLocalData()->RParenLoc = Loc;
1437 }
1438
1441 }
1442
1444 if (hasExceptionSpec())
1445 return *getExceptionSpecRangePtr();
1446 return {};
1447 }
1448
1450 if (hasExceptionSpec())
1451 *getExceptionSpecRangePtr() = R;
1452 }
1453
1456 }
1457
1458 // ParmVarDecls* are stored after Info, one for each parameter.
1460 return (ParmVarDecl**) getExtraLocalData();
1461 }
1462
1463 unsigned getNumParams() const {
1464 if (isa<FunctionNoProtoType>(getTypePtr()))
1465 return 0;
1466 return cast<FunctionProtoType>(getTypePtr())->getNumParams();
1467 }
1468
1469 ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; }
1470 void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1471
1473 return getInnerTypeLoc();
1474 }
1475
1478 }
1479
1481 setLocalRangeBegin(Loc);
1482 setLParenLoc(Loc);
1483 setRParenLoc(Loc);
1484 setLocalRangeEnd(Loc);
1485 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
1486 setParam(i, nullptr);
1487 if (hasExceptionSpec())
1489 }
1490
1491 /// Returns the size of the type source info data block that is
1492 /// specific to this type.
1493 unsigned getExtraLocalDataSize() const {
1494 unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
1495 return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
1496 }
1497
1498 unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); }
1499
1501};
1502
1504 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1505 FunctionProtoTypeLoc,
1506 FunctionProtoType> {
1507};
1508
1510 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1511 FunctionNoProtoTypeLoc,
1512 FunctionNoProtoType> {
1513};
1514
1518};
1519
1520/// Wrapper for source info for arrays.
1521class ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1522 ArrayTypeLoc,
1523 ArrayType,
1524 ArrayLocInfo> {
1525public:
1527 return getLocalData()->LBracketLoc;
1528 }
1529
1531 getLocalData()->LBracketLoc = Loc;
1532 }
1533
1535 return getLocalData()->RBracketLoc;
1536 }
1537
1539 getLocalData()->RBracketLoc = Loc;
1540 }
1541
1544 }
1545
1547 return getLocalData()->Size;
1548 }
1549
1550 void setSizeExpr(Expr *Size) {
1551 getLocalData()->Size = Size;
1552 }
1553
1555 return getInnerTypeLoc();
1556 }
1557
1560 }
1561
1563 setLBracketLoc(Loc);
1564 setRBracketLoc(Loc);
1565 setSizeExpr(nullptr);
1566 }
1567
1569};
1570
1572 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1573 ConstantArrayTypeLoc,
1574 ConstantArrayType> {
1575};
1576
1578 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1579 IncompleteArrayTypeLoc,
1580 IncompleteArrayType> {
1581};
1582
1584 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1585 DependentSizedArrayTypeLoc,
1586 DependentSizedArrayType> {
1587public:
1589 ArrayTypeLoc::initializeLocal(Context, Loc);
1591 }
1592};
1593
1595 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1596 VariableArrayTypeLoc,
1597 VariableArrayType> {
1598};
1599
1600// Location information for a TemplateName. Rudimentary for now.
1603};
1604
1609};
1610
1612 public ConcreteTypeLoc<UnqualTypeLoc,
1613 TemplateSpecializationTypeLoc,
1614 TemplateSpecializationType,
1615 TemplateSpecializationLocInfo> {
1616public:
1618 return getLocalData()->TemplateKWLoc;
1619 }
1620
1622 getLocalData()->TemplateKWLoc = Loc;
1623 }
1624
1626 return getLocalData()->LAngleLoc;
1627 }
1628
1630 getLocalData()->LAngleLoc = Loc;
1631 }
1632
1634 return getLocalData()->RAngleLoc;
1635 }
1636
1638 getLocalData()->RAngleLoc = Loc;
1639 }
1640
1641 unsigned getNumArgs() const {
1642 return getTypePtr()->template_arguments().size();
1643 }
1644
1646 getArgInfos()[i] = AI;
1647 }
1648
1650 return getArgInfos()[i];
1651 }
1652
1653 TemplateArgumentLoc getArgLoc(unsigned i) const {
1654 return TemplateArgumentLoc(getTypePtr()->template_arguments()[i],
1655 getArgLocInfo(i));
1656 }
1657
1659 return getLocalData()->NameLoc;
1660 }
1661
1663 getLocalData()->NameLoc = Loc;
1664 }
1665
1666 /// - Copy the location information from the given info.
1668 unsigned size = getFullDataSize();
1669 assert(size == Loc.getFullDataSize());
1670
1671 // We're potentially copying Expr references here. We don't
1672 // bother retaining them because TypeSourceInfos live forever, so
1673 // as long as the Expr was retained when originally written into
1674 // the TypeLoc, we're okay.
1675 memcpy(Data, Loc.Data, size);
1676 }
1677
1679 if (getTemplateKeywordLoc().isValid())
1681 else
1683 }
1684
1687 setTemplateNameLoc(Loc);
1688 setLAngleLoc(Loc);
1689 setRAngleLoc(Loc);
1690 initializeArgLocs(Context, getTypePtr()->template_arguments(),
1691 getArgInfos(), Loc);
1692 }
1693
1694 static void initializeArgLocs(ASTContext &Context,
1696 TemplateArgumentLocInfo *ArgInfos,
1697 SourceLocation Loc);
1698
1699 unsigned getExtraLocalDataSize() const {
1700 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1701 }
1702
1704 return alignof(TemplateArgumentLocInfo);
1705 }
1706
1707private:
1708 TemplateArgumentLocInfo *getArgInfos() const {
1709 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1710 }
1711};
1712
1717};
1718
1720 : public ConcreteTypeLoc<UnqualTypeLoc,
1721 DependentAddressSpaceTypeLoc,
1722 DependentAddressSpaceType,
1723 DependentAddressSpaceLocInfo> {
1724public:
1725 /// The location of the attribute name, i.e.
1726 /// int * __attribute__((address_space(11)))
1727 /// ^~~~~~~~~~~~~
1729 return getLocalData()->AttrLoc;
1730 }
1732 getLocalData()->AttrLoc = loc;
1733 }
1734
1735 /// The attribute's expression operand, if it has one.
1736 /// int * __attribute__((address_space(11)))
1737 /// ^~
1739 return getLocalData()->ExprOperand;
1740 }
1743 }
1744
1745 /// The location of the parentheses around the operand, if there is
1746 /// an operand.
1747 /// int * __attribute__((address_space(11)))
1748 /// ^ ^
1750 return getLocalData()->OperandParens;
1751 }
1753 getLocalData()->OperandParens = range;
1754 }
1755
1757 SourceRange range(getAttrNameLoc());
1758 range.setEnd(getAttrOperandParensRange().getEnd());
1759 return range;
1760 }
1761
1762 /// Returns the type before the address space attribute application
1763 /// area.
1764 /// int * __attribute__((address_space(11))) *
1765 /// ^ ^
1767 return this->getTypePtr()->getPointeeType();
1768 }
1769
1771 return this->getInnerTypeLoc();
1772 }
1773
1775 setAttrNameLoc(loc);
1778 setAttrExprOperand(getTypePtr()->getAddrSpaceExpr());
1779 }
1780};
1781
1782//===----------------------------------------------------------------------===//
1783//
1784// All of these need proper implementations.
1785//
1786//===----------------------------------------------------------------------===//
1787
1788// FIXME: size expression and attribute locations (or keyword if we
1789// ever fully support altivec syntax).
1792};
1793
1794class VectorTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, VectorTypeLoc,
1795 VectorType, VectorTypeLocInfo> {
1796public:
1797 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1798
1799 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1800
1802 return SourceRange(getNameLoc(), getNameLoc());
1803 }
1804
1806 setNameLoc(Loc);
1807 }
1808
1810
1811 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1812};
1813
1814// FIXME: size expression and attribute locations (or keyword if we
1815// ever fully support altivec syntax).
1817 : public ConcreteTypeLoc<UnqualTypeLoc, DependentVectorTypeLoc,
1818 DependentVectorType, VectorTypeLocInfo> {
1819public:
1820 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1821
1822 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1823
1825 return SourceRange(getNameLoc(), getNameLoc());
1826 }
1827
1829 setNameLoc(Loc);
1830 }
1831
1833
1834 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1835};
1836
1837// FIXME: size expression and attribute locations.
1839 : public InheritingConcreteTypeLoc<VectorTypeLoc, ExtVectorTypeLoc,
1840 ExtVectorType> {};
1841
1842// FIXME: attribute locations.
1843// For some reason, this isn't a subtype of VectorType.
1845 : public ConcreteTypeLoc<UnqualTypeLoc, DependentSizedExtVectorTypeLoc,
1846 DependentSizedExtVectorType, VectorTypeLocInfo> {
1847public:
1848 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1849
1850 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1851
1853 return SourceRange(getNameLoc(), getNameLoc());
1854 }
1855
1857 setNameLoc(Loc);
1858 }
1859
1861
1862 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1863};
1864
1870};
1871
1872class MatrixTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, MatrixTypeLoc,
1873 MatrixType, MatrixTypeLocInfo> {
1874public:
1875 /// The location of the attribute name, i.e.
1876 /// float __attribute__((matrix_type(4, 2)))
1877 /// ^~~~~~~~~~~~~~~~~
1880
1881 /// The attribute's row operand, if it has one.
1882 /// float __attribute__((matrix_type(4, 2)))
1883 /// ^
1886
1887 /// The attribute's column operand, if it has one.
1888 /// float __attribute__((matrix_type(4, 2)))
1889 /// ^
1892
1893 /// The location of the parentheses around the operand, if there is
1894 /// an operand.
1895 /// float __attribute__((matrix_type(4, 2)))
1896 /// ^ ^
1898 return getLocalData()->OperandParens;
1899 }
1901 getLocalData()->OperandParens = range;
1902 }
1903
1905 SourceRange range(getAttrNameLoc());
1906 range.setEnd(getAttrOperandParensRange().getEnd());
1907 return range;
1908 }
1909
1911 setAttrNameLoc(loc);
1913 setAttrRowOperand(nullptr);
1914 setAttrColumnOperand(nullptr);
1915 }
1916};
1917
1919 : public InheritingConcreteTypeLoc<MatrixTypeLoc, ConstantMatrixTypeLoc,
1920 ConstantMatrixType> {};
1921
1923 : public InheritingConcreteTypeLoc<MatrixTypeLoc,
1924 DependentSizedMatrixTypeLoc,
1925 DependentSizedMatrixType> {};
1926
1927// FIXME: location of the '_Complex' keyword.
1928class ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1929 ComplexTypeLoc,
1930 ComplexType> {
1931};
1932
1937};
1938
1940};
1941
1944};
1945
1946template <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
1948 : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
1949public:
1951 return this->getLocalData()->TypeofLoc;
1952 }
1953
1955 this->getLocalData()->TypeofLoc = Loc;
1956 }
1957
1959 return this->getLocalData()->LParenLoc;
1960 }
1961
1963 this->getLocalData()->LParenLoc = Loc;
1964 }
1965
1967 return this->getLocalData()->RParenLoc;
1968 }
1969
1971 this->getLocalData()->RParenLoc = Loc;
1972 }
1973
1976 }
1977
1979 setLParenLoc(range.getBegin());
1980 setRParenLoc(range.getEnd());
1981 }
1982
1985 }
1986
1988 setTypeofLoc(Loc);
1989 setLParenLoc(Loc);
1990 setRParenLoc(Loc);
1991 }
1992};
1993
1994class TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
1995 TypeOfExprType,
1996 TypeOfExprTypeLocInfo> {
1997public:
1999 return getTypePtr()->getUnderlyingExpr();
2000 }
2001
2002 // Reimplemented to account for GNU/C++ extension
2003 // typeof unary-expression
2004 // where there are no parentheses.
2006};
2007
2009 : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
2010public:
2012 return this->getTypePtr()->getUnmodifiedType();
2013 }
2014
2016 return this->getLocalData()->UnmodifiedTInfo;
2017 }
2018
2020 this->getLocalData()->UnmodifiedTInfo = TI;
2021 }
2022
2023 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2024};
2025
2026// decltype(expression) abc;
2027// ~~~~~~~~ DecltypeLoc
2028// ~ RParenLoc
2029// FIXME: add LParenLoc, it is tricky to support due to the limitation of
2030// annotated-decltype token.
2034};
2036 : public ConcreteTypeLoc<UnqualTypeLoc, DecltypeTypeLoc, DecltypeType,
2037 DecltypeTypeLocInfo> {
2038public:
2040
2043
2046
2049 }
2050
2052 setDecltypeLoc(Loc);
2053 setRParenLoc(Loc);
2054 }
2055};
2056
2058 // FIXME: While there's only one unary transform right now, future ones may
2059 // need different representations
2062};
2063
2064class UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2065 UnaryTransformTypeLoc,
2066 UnaryTransformType,
2067 UnaryTransformTypeLocInfo> {
2068public:
2071
2074
2077
2079 return getLocalData()->UnderlyingTInfo;
2080 }
2081
2083 getLocalData()->UnderlyingTInfo = TInfo;
2084 }
2085
2087 return SourceRange(getKWLoc(), getRParenLoc());
2088 }
2089
2092 }
2093
2095 setLParenLoc(Range.getBegin());
2096 setRParenLoc(Range.getEnd());
2097 }
2098
2099 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2100};
2101
2103 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DeducedTypeLoc,
2104 DeducedType> {};
2105
2113
2114 // For decltype(auto).
2116
2117 // Followed by a TemplateArgumentLocInfo[]
2118};
2119
2121 : public ConcreteTypeLoc<DeducedTypeLoc,
2122 AutoTypeLoc,
2123 AutoType,
2124 AutoTypeLocInfo> {
2125public:
2127 return getTypePtr()->getKeyword();
2128 }
2129
2130 bool isDecltypeAuto() const { return getTypePtr()->isDecltypeAuto(); }
2133
2134 bool isConstrained() const {
2135 return getTypePtr()->isConstrained();
2136 }
2137
2139 return getLocalData()->NestedNameSpec;
2140 }
2141
2144 }
2145
2147 return getLocalData()->TemplateKWLoc;
2148 }
2149
2151 getLocalData()->TemplateKWLoc = Loc;
2152 }
2153
2155 return getLocalData()->ConceptNameLoc;
2156 }
2157
2160 }
2161
2163 return getLocalData()->FoundDecl;
2164 }
2165
2167 getLocalData()->FoundDecl = D;
2168 }
2169
2172 }
2173
2175
2177 return getLocalData()->LAngleLoc.isValid();
2178 }
2179
2181 return this->getLocalData()->LAngleLoc;
2182 }
2183
2185 this->getLocalData()->LAngleLoc = Loc;
2186 }
2187
2189 return this->getLocalData()->RAngleLoc;
2190 }
2191
2193 this->getLocalData()->RAngleLoc = Loc;
2194 }
2195
2196 unsigned getNumArgs() const {
2197 return getTypePtr()->getTypeConstraintArguments().size();
2198 }
2199
2201 getArgInfos()[i] = AI;
2202 }
2203
2205 return getArgInfos()[i];
2206 }
2207
2208 TemplateArgumentLoc getArgLoc(unsigned i) const {
2209 return TemplateArgumentLoc(getTypePtr()->getTypeConstraintArguments()[i],
2210 getArgLocInfo(i));
2211 }
2212
2214 return {isConstrained()
2218 : getConceptNameLoc()))
2219 : getNameLoc(),
2221 }
2222
2223 void copy(AutoTypeLoc Loc) {
2224 unsigned size = getFullDataSize();
2225 assert(size == Loc.getFullDataSize());
2226 memcpy(Data, Loc.Data, size);
2227 }
2228
2229 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2230
2231 unsigned getExtraLocalDataSize() const {
2232 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
2233 }
2234
2236 return alignof(TemplateArgumentLocInfo);
2237 }
2238
2239private:
2240 TemplateArgumentLocInfo *getArgInfos() const {
2241 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
2242 }
2243};
2244
2246 : public InheritingConcreteTypeLoc<DeducedTypeLoc,
2247 DeducedTemplateSpecializationTypeLoc,
2248 DeducedTemplateSpecializationType> {
2249public:
2251 return getNameLoc();
2252 }
2253
2255 setNameLoc(Loc);
2256 }
2257};
2258
2261
2262 /// Data associated with the nested-name-specifier location.
2264};
2265
2266class ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2267 ElaboratedTypeLoc,
2268 ElaboratedType,
2269 ElaboratedLocInfo> {
2270public:
2273 }
2274
2276 if (isEmpty()) {
2277 assert(Loc.isInvalid());
2278 return;
2279 }
2281 }
2282
2284 return !isEmpty() ? NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2285 getLocalData()->QualifierData)
2287 }
2288
2290 assert(QualifierLoc.getNestedNameSpecifier() ==
2291 getTypePtr()->getQualifier() &&
2292 "Inconsistent nested-name-specifier pointer");
2293 if (isEmpty()) {
2294 assert(!QualifierLoc.hasQualifier());
2295 return;
2296 }
2297 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2298 }
2299
2301 if (getElaboratedKeywordLoc().isValid())
2302 if (getQualifierLoc())
2305 else
2307 else
2309 }
2310
2311 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2312
2314
2316
2317 bool isEmpty() const {
2320 }
2321
2322 unsigned getLocalDataAlignment() const {
2323 // FIXME: We want to return 1 here in the empty case, but
2324 // there are bugs in how alignment is handled in TypeLocs
2325 // that prevent this from working.
2327 }
2328
2329 unsigned getLocalDataSize() const {
2331 }
2332
2334 unsigned size = getFullDataSize();
2335 assert(size == Loc.getFullDataSize());
2336 memcpy(Data, Loc.Data, size);
2337 }
2338};
2339
2340// This is exactly the structure of an ElaboratedTypeLoc whose inner
2341// type is some sort of TypeDeclTypeLoc.
2344};
2345
2346class DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2347 DependentNameTypeLoc,
2348 DependentNameType,
2349 DependentNameLocInfo> {
2350public:
2352 return this->getLocalData()->ElaboratedKWLoc;
2353 }
2354
2356 this->getLocalData()->ElaboratedKWLoc = Loc;
2357 }
2358
2360 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2361 getLocalData()->QualifierData);
2362 }
2363
2365 assert(QualifierLoc.getNestedNameSpecifier()
2366 == getTypePtr()->getQualifier() &&
2367 "Inconsistent nested-name-specifier pointer");
2368 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2369 }
2370
2372 return this->getLocalData()->NameLoc;
2373 }
2374
2376 this->getLocalData()->NameLoc = Loc;
2377 }
2378
2380 if (getElaboratedKeywordLoc().isValid())
2382 else
2384 }
2385
2387 unsigned size = getFullDataSize();
2388 assert(size == Loc.getFullDataSize());
2389 memcpy(Data, Loc.Data, size);
2390 }
2391
2392 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2393};
2394
2399 // followed by a TemplateArgumentLocInfo[]
2400};
2401
2403 public ConcreteTypeLoc<UnqualTypeLoc,
2404 DependentTemplateSpecializationTypeLoc,
2405 DependentTemplateSpecializationType,
2406 DependentTemplateSpecializationLocInfo> {
2407public:
2409 return this->getLocalData()->ElaboratedKWLoc;
2410 }
2411
2413 this->getLocalData()->ElaboratedKWLoc = Loc;
2414 }
2415
2417 if (!getLocalData()->QualifierData)
2418 return NestedNameSpecifierLoc();
2419
2420 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2421 getLocalData()->QualifierData);
2422 }
2423
2425 if (!QualifierLoc) {
2426 // Even if we have a nested-name-specifier in the dependent
2427 // template specialization type, we won't record the nested-name-specifier
2428 // location information when this type-source location information is
2429 // part of a nested-name-specifier.
2430 getLocalData()->QualifierData = nullptr;
2431 return;
2432 }
2433
2434 assert(QualifierLoc.getNestedNameSpecifier()
2435 == getTypePtr()->getQualifier() &&
2436 "Inconsistent nested-name-specifier pointer");
2437 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2438 }
2439
2441 return getLocalData()->TemplateKWLoc;
2442 }
2443
2445 getLocalData()->TemplateKWLoc = Loc;
2446 }
2447
2449 return this->getLocalData()->NameLoc;
2450 }
2451
2453 this->getLocalData()->NameLoc = Loc;
2454 }
2455
2457 return this->getLocalData()->LAngleLoc;
2458 }
2459
2461 this->getLocalData()->LAngleLoc = Loc;
2462 }
2463
2465 return this->getLocalData()->RAngleLoc;
2466 }
2467
2469 this->getLocalData()->RAngleLoc = Loc;
2470 }
2471
2472 unsigned getNumArgs() const {
2473 return getTypePtr()->template_arguments().size();
2474 }
2475
2477 getArgInfos()[i] = AI;
2478 }
2479
2481 return getArgInfos()[i];
2482 }
2483
2484 TemplateArgumentLoc getArgLoc(unsigned i) const {
2485 return TemplateArgumentLoc(getTypePtr()->template_arguments()[i],
2486 getArgLocInfo(i));
2487 }
2488
2490 if (getElaboratedKeywordLoc().isValid())
2492 else if (getQualifierLoc())
2494 else if (getTemplateKeywordLoc().isValid())
2496 else
2498 }
2499
2501 unsigned size = getFullDataSize();
2502 assert(size == Loc.getFullDataSize());
2503 memcpy(Data, Loc.Data, size);
2504 }
2505
2506 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2507
2508 unsigned getExtraLocalDataSize() const {
2509 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
2510 }
2511
2513 return alignof(TemplateArgumentLocInfo);
2514 }
2515
2516private:
2517 TemplateArgumentLocInfo *getArgInfos() const {
2518 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
2519 }
2520};
2521
2524};
2525
2527 : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
2528 PackExpansionType, PackExpansionTypeLocInfo> {
2529public:
2531 return this->getLocalData()->EllipsisLoc;
2532 }
2533
2535 this->getLocalData()->EllipsisLoc = Loc;
2536 }
2537
2540 }
2541
2543 setEllipsisLoc(Loc);
2544 }
2545
2547 return getInnerTypeLoc();
2548 }
2549
2551 return this->getTypePtr()->getPattern();
2552 }
2553};
2554
2557};
2558
2559class AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc,
2560 AtomicType, AtomicTypeLocInfo> {
2561public:
2563 return this->getInnerTypeLoc();
2564 }
2565
2567 return SourceRange(getKWLoc(), getRParenLoc());
2568 }
2569
2571 return this->getLocalData()->KWLoc;
2572 }
2573
2575 this->getLocalData()->KWLoc = Loc;
2576 }
2577
2579 return this->getLocalData()->LParenLoc;
2580 }
2581
2583 this->getLocalData()->LParenLoc = Loc;
2584 }
2585
2587 return this->getLocalData()->RParenLoc;
2588 }
2589
2591 this->getLocalData()->RParenLoc = Loc;
2592 }
2593
2596 }
2597
2599 setLParenLoc(Range.getBegin());
2600 setRParenLoc(Range.getEnd());
2601 }
2602
2604 setKWLoc(Loc);
2605 setLParenLoc(Loc);
2606 setRParenLoc(Loc);
2607 }
2608
2610 return this->getTypePtr()->getValueType();
2611 }
2612};
2613
2616};
2617
2618class PipeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, PipeTypeLoc, PipeType,
2619 PipeTypeLocInfo> {
2620public:
2621 TypeLoc getValueLoc() const { return this->getInnerTypeLoc(); }
2622
2624
2625 SourceLocation getKWLoc() const { return this->getLocalData()->KWLoc; }
2626 void setKWLoc(SourceLocation Loc) { this->getLocalData()->KWLoc = Loc; }
2627
2629 setKWLoc(Loc);
2630 }
2631
2632 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2633};
2634
2635template <typename T>
2636inline T TypeLoc::getAsAdjusted() const {
2637 TypeLoc Cur = *this;
2638 while (!T::isKind(Cur)) {
2639 if (auto PTL = Cur.getAs<ParenTypeLoc>())
2640 Cur = PTL.getInnerLoc();
2641 else if (auto ATL = Cur.getAs<AttributedTypeLoc>())
2642 Cur = ATL.getModifiedLoc();
2643 else if (auto ATL = Cur.getAs<BTFTagAttributedTypeLoc>())
2644 Cur = ATL.getWrappedLoc();
2645 else if (auto ETL = Cur.getAs<ElaboratedTypeLoc>())
2646 Cur = ETL.getNamedTypeLoc();
2647 else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())
2648 Cur = ATL.getOriginalLoc();
2649 else if (auto MQL = Cur.getAs<MacroQualifiedTypeLoc>())
2650 Cur = MQL.getInnerLoc();
2651 else
2652 break;
2653 }
2654 return Cur.getAs<T>();
2655}
2656class BitIntTypeLoc final
2657 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, BitIntTypeLoc,
2658 BitIntType> {};
2660 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentBitIntTypeLoc,
2661 DependentBitIntType> {};
2662
2664 ObjCProtocolDecl *Protocol = nullptr;
2666
2667public:
2669 : Protocol(protocol), Loc(loc) {}
2670 ObjCProtocolDecl *getProtocol() const { return Protocol; }
2671 SourceLocation getLocation() const { return Loc; }
2672
2673 /// The source range is just the protocol name.
2674 SourceRange getSourceRange() const LLVM_READONLY {
2675 return SourceRange(Loc, Loc);
2676 }
2677};
2678
2679} // namespace clang
2680
2681#endif // LLVM_CLANG_AST_TYPELOC_H
MatchType Type
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
const char * Data
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
QualType getInnerType() const
Definition: TypeLoc.h:1207
unsigned getLocalDataSize() const
Definition: TypeLoc.h:1215
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1199
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1203
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1213
QualType getOriginalType() const
Definition: Type.h:2842
Wrapper for source info for arrays.
Definition: TypeLoc.h:1524
SourceLocation getLBracketLoc() const
Definition: TypeLoc.h:1526
Expr * getSizeExpr() const
Definition: TypeLoc.h:1546
void setLBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1530
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1554
void setRBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1538
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1562
SourceLocation getRBracketLoc() const
Definition: TypeLoc.h:1534
SourceRange getBracketsRange() const
Definition: TypeLoc.h:1542
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1558
QualType getInnerType() const
Definition: TypeLoc.h:1568
void setSizeExpr(Expr *Size)
Definition: TypeLoc.h:1550
QualType getElementType() const
Definition: Type.h:3064
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2586
QualType getInnerType() const
Definition: TypeLoc.h:2609
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2566
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2590
SourceRange getParensRange() const
Definition: TypeLoc.h:2594
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2562
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2582
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2574
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2603
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2570
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2578
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:2598
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:6493
Attr - This represents one attribute.
Definition: Attr.h:40
Type source information for an attributed type.
Definition: TypeLoc.h:868
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:887
QualType getInnerType() const
Definition: TypeLoc.h:904
const T * getAttrAs()
Definition: TypeLoc.h:894
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:882
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:900
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:505
void setAttr(const Attr *A)
Definition: TypeLoc.h:890
attr::Kind getAttrKind() const
Definition: TypeLoc.h:870
bool isQualifier() const
Definition: TypeLoc.h:874
QualType getModifiedType() const
Definition: Type.h:4927
Kind getAttrKind() const
Definition: Type.h:4923
bool isQualifier() const
Does this attribute behave like a type qualifier?
Definition: Type.cpp:3737
bool hasExplicitTemplateArgs() const
Definition: TypeLoc.h:2176
DeclarationNameInfo getConceptNameInfo() const
Definition: TypeLoc.cpp:624
SourceLocation getTemplateKWLoc() const
Definition: TypeLoc.h:2146
void setConceptNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2158
AutoTypeKeyword getAutoKeyword() const
Definition: TypeLoc.h:2126
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:2188
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2131
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:629
void setFoundDecl(NamedDecl *D)
Definition: TypeLoc.h:2166
ConceptDecl * getNamedConcept() const
Definition: TypeLoc.h:2170
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2213
void setTemplateKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2150
void copy(AutoTypeLoc Loc)
Definition: TypeLoc.h:2223
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2200
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:2204
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:2180
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:2235
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
Definition: TypeLoc.h:2138
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2184
SourceLocation getConceptNameLoc() const
Definition: TypeLoc.h:2154
NamedDecl * getFoundDecl() const
Definition: TypeLoc.h:2162
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:2208
bool isDecltypeAuto() const
Definition: TypeLoc.h:2130
void setNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Definition: TypeLoc.h:2142
bool isConstrained() const
Definition: TypeLoc.h:2134
unsigned getNumArgs() const
Definition: TypeLoc.h:2196
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:2231
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2192
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2132
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
Definition: Type.h:5292
bool isDecltypeAuto() const
Definition: Type.h:5305
ConceptDecl * getTypeConstraintConcept() const
Definition: Type.h:5297
AutoTypeKeyword getKeyword() const
Definition: Type.h:5313
bool isConstrained() const
Definition: Type.h:5301
Type source information for an btf_tag attributed type.
Definition: TypeLoc.h:914
QualType getInnerType() const
Definition: TypeLoc.h:929
TypeLoc getWrappedLoc() const
Definition: TypeLoc.h:916
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:927
const BTFTypeTagAttr * getAttr() const
The btf_type_tag attribute.
Definition: TypeLoc.h:919
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:518
const BTFTypeTagAttr * getAttr() const
Definition: Type.h:5018
QualType getWrappedType() const
Definition: Type.h:5017
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1277
SourceLocation getCaretLoc() const
Definition: TypeLoc.h:1279
void setCaretLoc(SourceLocation Loc)
Definition: TypeLoc.h:1283
Wrapper for source info for builtin types.
Definition: TypeLoc.h:558
SourceLocation getBuiltinLoc() const
Definition: TypeLoc.h:560
TypeSpecifierType getWrittenTypeSpec() const
Definition: TypeLoc.cpp:331
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:661
TypeSpecifierWidth getWrittenWidthSpec() const
Definition: TypeLoc.h:622
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:602
void setWrittenTypeSpec(TypeSpecifierType written)
Definition: TypeLoc.h:644
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
Definition: TypeLoc.h:583
bool needsExtraLocalData() const
Definition: TypeLoc.h:587
bool hasWrittenWidthSpec() const
Definition: TypeLoc.h:629
void setModeAttr(bool written)
Definition: TypeLoc.h:656
void setBuiltinLoc(SourceLocation Loc)
Definition: TypeLoc.h:564
void setWrittenWidthSpec(TypeSpecifierWidth written)
Definition: TypeLoc.h:633
SourceLocation getNameLoc() const
Definition: TypeLoc.h:578
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:598
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:580
void setWrittenSignSpec(TypeSpecifierSign written)
Definition: TypeLoc.h:617
bool hasWrittenSignSpec() const
Definition: TypeLoc.h:613
bool hasModeAttr() const
Definition: TypeLoc.h:649
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:594
bool hasWrittenTypeSpec() const
Definition: TypeLoc.h:640
TypeSpecifierSign getWrittenSignSpec() const
Definition: TypeLoc.h:606
void expandBuiltinRange(SourceRange Range)
Definition: TypeLoc.h:568
Kind getKind() const
Definition: Type.h:2684
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
Declaration of a C++20 concept.
A metaprogramming base class for TypeLoc classes which correspond to a particular Type subclass.
Definition: TypeLoc.h:366
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:414
friend class TypeLoc
Definition: TypeLoc.h:367
TypeLoc getInnerTypeLoc() const
Definition: TypeLoc.h:451
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:423
HasNoInnerType getInnerType() const
Definition: TypeLoc.h:449
void * getExtraLocalData() const
Gets a pointer past the Info structure; useful for classes with local data that can't be captured in ...
Definition: TypeLoc.h:434
LocalData * getLocalData() const
Definition: TypeLoc.h:427
unsigned getLocalDataAlignment() const
Definition: TypeLoc.h:383
void * getNonLocalData() const
Definition: TypeLoc.h:441
TypeLoc getNextTypeLoc() const
Definition: TypeLoc.h:410
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:419
void copyLocal(Derived other)
Definition: TypeLoc.h:396
unsigned getLocalDataSize() const
Definition: TypeLoc.h:388
Wrapper for source info for pointers decayed from arrays and functions.
Definition: TypeLoc.h:1225
SourceLocation getDecltypeLoc() const
Definition: TypeLoc.h:2041
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2051
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:2039
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2044
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2045
void setDecltypeLoc(SourceLocation Loc)
Definition: TypeLoc.h:2042
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2047
Expr * getUnderlyingExpr() const
Definition: Type.h:4734
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2250
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2254
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1731
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1756
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1752
QualType getInnerType() const
Returns the type before the address space attribute application area.
Definition: TypeLoc.h:1766
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
Definition: TypeLoc.h:1738
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:1774
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:1749
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1728
QualType getPointeeType() const
Definition: Type.h:3321
void copy(DependentNameTypeLoc Loc)
Definition: TypeLoc.h:2386
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2359
SourceLocation getNameLoc() const
Definition: TypeLoc.h:2371
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:549
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2379
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2351
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2375
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2355
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2364
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1588
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1848
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1852
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1850
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1856
QualType getElementType() const
Definition: Type.h:3365
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2424
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:559
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2448
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2444
void copy(DependentTemplateSpecializationTypeLoc Loc)
Definition: TypeLoc.h:2500
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2440
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2412
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2468
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:2484
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:2480
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2408
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2460
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2476
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2452
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2416
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:5827
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1820
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1824
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1828
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1832
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1822
QualType getInnerType() const
Definition: TypeLoc.h:1834
QualType getElementType() const
Definition: Type.h:3485
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:539
bool isEmpty() const
Definition: TypeLoc.h:2317
unsigned getLocalDataAlignment() const
Definition: TypeLoc.h:2322
QualType getInnerType() const
Definition: TypeLoc.h:2315
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2271
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2283
void copy(ElaboratedTypeLoc Loc)
Definition: TypeLoc.h:2333
unsigned getLocalDataSize() const
Definition: TypeLoc.h:2329
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2300
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2275
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2313
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2289
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5709
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:5712
Represents an enum.
Definition: Decl.h:3734
Wrapper for source info for enum types.
Definition: TypeLoc.h:742
EnumDecl * getDecl() const
Definition: TypeLoc.h:744
EnumDecl * getDecl() const
Definition: Type.h:4883
This represents one expression.
Definition: Expr.h:110
Wrapper for source info for functions.
Definition: TypeLoc.h:1391
ParmVarDecl ** getParmArray() const
Definition: TypeLoc.h:1459
QualType getInnerType() const
Definition: TypeLoc.h:1500
unsigned getNumParams() const
Definition: TypeLoc.h:1463
ParmVarDecl * getParam(unsigned i) const
Definition: TypeLoc.h:1469
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1415
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1411
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1427
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1443
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1470
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1454
SourceRange getParensRange() const
Definition: TypeLoc.h:1439
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1435
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1498
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1419
unsigned getExtraLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition: TypeLoc.h:1493
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1449
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1472
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1407
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1476
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1423
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1431
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1480
QualType getReturnType() const
Definition: Type.h:3974
One of these records is kept for each identifier that is lexed.
A metaprogramming class designed for concrete subtypes of abstract types where all subtypes share equ...
Definition: TypeLoc.h:491
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:507
Wrapper for source info for injected class names of class templates.
Definition: TypeLoc.h:698
CXXRecordDecl * getDecl() const
Definition: TypeLoc.h:700
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3805
void setAmpLoc(SourceLocation Loc)
Definition: TypeLoc.h:1361
SourceLocation getAmpLoc() const
Definition: TypeLoc.h:1357
const IdentifierInfo * getMacroIdentifier() const
Definition: TypeLoc.h:1126
SourceLocation getExpansionLoc() const
Definition: TypeLoc.h:1130
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1124
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1120
void setExpansionLoc(SourceLocation Loc)
Definition: TypeLoc.h:1134
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1140
QualType getInnerType() const
Definition: TypeLoc.h:1138
QualType getUnderlyingType() const
Definition: Type.h:4621
const IdentifierInfo * getMacroIdentifier() const
Definition: Type.h:4620
Expr * getAttrColumnOperand() const
The attribute's column operand, if it has one.
Definition: TypeLoc.h:1890
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:1897
void setAttrRowOperand(Expr *e)
Definition: TypeLoc.h:1885
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1904
void setAttrColumnOperand(Expr *e)
Definition: TypeLoc.h:1891
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1900
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1879
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1878
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:1910
Expr * getAttrRowOperand() const
The attribute's row operand, if it has one.
Definition: TypeLoc.h:1884
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1295
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1317
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1301
TypeSourceInfo * getClassTInfo() const
Definition: TypeLoc.h:1309
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1322
void setClassTInfo(TypeSourceInfo *TI)
Definition: TypeLoc.h:1313
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1297
const Type * getClass() const
Definition: TypeLoc.h:1305
This represents a decl that may have a name.
Definition: Decl.h:247
A C++ nested-name-specifier augmented with source location information.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is empty.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents an ObjC class declaration.
Definition: DeclObjC.h:1147
Wrapper for source info for ObjC interfaces.
Definition: TypeLoc.h:1080
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1090
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1094
void setNameEndLoc(SourceLocation Loc)
Definition: TypeLoc.h:1102
ObjCInterfaceDecl * getIFaceDecl() const
Definition: TypeLoc.h:1082
SourceLocation getNameEndLoc() const
Definition: TypeLoc.h:1098
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1086
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1106
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition: Type.cpp:829
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1333
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1335
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1339
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1060
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:973
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition: TypeLoc.h:1021
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:1055
bool hasBaseTypeAsWritten() const
Definition: TypeLoc.h:1031
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:489
SourceLocation getTypeArgsLAngleLoc() const
Definition: TypeLoc.h:961
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:977
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:1027
unsigned getNumProtocols() const
Definition: TypeLoc.h:1007
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:965
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1043
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition: TypeLoc.h:981
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:986
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:995
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1003
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:999
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:1011
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:1035
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:1016
TypeLoc getBaseLoc() const
Definition: TypeLoc.h:1039
QualType getInnerType() const
Definition: TypeLoc.h:1066
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:991
SourceLocation getTypeArgsRAngleLoc() const
Definition: TypeLoc.h:969
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
Definition: Type.h:6168
QualType getBaseType() const
Gets the base type of this object type.
Definition: Type.h:6120
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2069
SourceLocation getLocation() const
Definition: TypeLoc.h:2671
ObjCProtocolLoc(ObjCProtocolDecl *protocol, SourceLocation loc)
Definition: TypeLoc.h:2668
ObjCProtocolDecl * getProtocol() const
Definition: TypeLoc.h:2670
SourceRange getSourceRange() const LLVM_READONLY
The source range is just the protocol name.
Definition: TypeLoc.h:2674
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
Definition: Type.h:5964
qual_iterator qual_begin() const
Definition: Type.h:5957
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:579
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition: TypeLoc.h:765
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:834
ObjCTypeParamDecl * getDecl() const
Definition: TypeLoc.h:772
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:838
unsigned getNumProtocols() const
Definition: TypeLoc.h:802
SourceLocation getNameLoc() const
Definition: TypeLoc.h:774
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition: TypeLoc.h:816
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:806
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:821
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:811
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:788
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:827
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:478
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:782
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:798
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:778
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:792
ObjCTypeParamDecl * getDecl() const
Definition: Type.h:6026
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2538
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2534
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2530
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2546
QualType getInnerType() const
Definition: TypeLoc.h:2550
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2542
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:5894
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1166
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1174
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1158
QualType getInnerType() const
Definition: TypeLoc.h:1183
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1154
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1170
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1179
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1162
QualType getInnerType() const
Definition: Type.h:2783
Represents a parameter to a function.
Definition: Decl.h:1722
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2621
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2628
QualType getInnerType() const
Definition: TypeLoc.h:2632
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2626
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2623
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2625
QualType getElementType() const
Definition: Type.h:6523
A base class for.
Definition: TypeLoc.h:1235
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1253
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1249
void setSigilLoc(SourceLocation Loc)
Definition: TypeLoc.h:1241
QualType getInnerType() const
Definition: TypeLoc.h:1257
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1245
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1237
Wrapper for source info for pointers.
Definition: TypeLoc.h:1264
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1266
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1270
A (possibly-)qualified type.
Definition: Type.h:736
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:843
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6664
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:785
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition: TypeLoc.h:282
TypeLoc getNextTypeLoc() const
Definition: TypeLoc.h:304
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Initializes the local data of this type source info block to provide no information.
Definition: TypeLoc.h:296
unsigned getLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition: TypeLoc.h:310
unsigned getLocalDataAlignment() const
Returns the alignment of the type source info data block that is specific to this type.
Definition: TypeLoc.h:318
void copyLocal(TypeLoc other)
Definition: TypeLoc.h:300
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:284
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:286
void setAmpAmpLoc(SourceLocation Loc)
Definition: TypeLoc.h:1375
SourceLocation getAmpAmpLoc() const
Definition: TypeLoc.h:1371
Represents a struct/union/class.
Definition: Decl.h:4012
Wrapper for source info for record types.
Definition: TypeLoc.h:734
RecordDecl * getDecl() const
Definition: TypeLoc.h:736
RecordDecl * getDecl() const
Definition: Type.h:4860
QualType getInnerType() const
Definition: TypeLoc.h:1347
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:857
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:850
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3454
Wrapper for source info for tag types.
Definition: TypeLoc.h:723
TagDecl * getDecl() const
Definition: TypeLoc.h:725
bool isDefinition() const
True if the tag was defined in this type specifier.
Definition: TypeLoc.cpp:313
TagDecl * getDecl() const
Definition: Type.cpp:3707
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:484
static void initializeArgLocs(ASTContext &Context, ArrayRef< TemplateArgument > Args, TemplateArgumentLocInfo *ArgInfos, SourceLocation Loc)
Definition: TypeLoc.cpp:577
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:1645
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:1625
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:1649
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1621
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:1653
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1678
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:1633
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1662
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1629
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1658
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1685
void copy(TemplateSpecializationTypeLoc Loc)
Definition: TypeLoc.h:1667
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1703
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:1617
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1637
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:1699
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:5460
Declaration of a template type parameter.
Wrapper for template type parameters.
Definition: TypeLoc.h:751
TemplateTypeParmDecl * getDecl() const
Definition: TypeLoc.h:753
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:5083
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
SourceLocation findNullabilityLoc() const
Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier),...
Definition: TypeLoc.cpp:446
TypeLoc()=default
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition: TypeLoc.h:331
static unsigned getLocalAlignmentForType(QualType Ty)
Returns the alignment of type source info data block for the given type.
Definition: TypeLoc.cpp:73
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
Definition: TypeLoc.cpp:457
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:132
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
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
friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS)
Definition: TypeLoc.h:219
TypeLoc IgnoreParens() const
Definition: TypeLoc.h:1188
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition: TypeLoc.h:77
TypeLoc(QualType ty, void *opaqueData)
Definition: TypeLoc.h:67
void * Data
Definition: TypeLoc.h:63
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
Definition: TypeLoc.h:202
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:152
SourceRange getLocalSourceRange() const
Get the local source range.
Definition: TypeLoc.h:158
void initializeFullCopy(TypeLoc Other, unsigned Size)
Initializes this by copying its information from another TypeLoc of the same type.
Definition: TypeLoc.h:210
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:163
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:715
TypeLoc(const Type *ty, void *opaqueData)
Definition: TypeLoc.h:69
void * getOpaqueData() const
Get the pointer where source information is stored.
Definition: TypeLoc.h:141
TypeLocClass
The kinds of TypeLocs.
Definition: TypeLoc.h:107
const void * Ty
Definition: TypeLoc.h:62
void copy(TypeLoc other)
Copies the other type loc into this one.
Definition: TypeLoc.cpp:167
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:115
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
Definition: TypeLoc.cpp:93
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
bool isNull() const
Definition: TypeLoc.h:120
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:234
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:2636
friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS)
Definition: TypeLoc.h:223
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
const Type * getTypePtr() const
Definition: TypeLoc.h:136
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:322
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1998
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:522
void setUnmodifiedTInfo(TypeSourceInfo *TI) const
Definition: TypeLoc.h:2019
TypeSourceInfo * getUnmodifiedTInfo() const
Definition: TypeLoc.h:2015
QualType getUnmodifiedType() const
Definition: TypeLoc.h:2011
A container of type source information.
Definition: Type.h:6635
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:249
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
Definition: TypeLoc.h:521
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:540
SourceLocation getNameLoc() const
Definition: TypeLoc.h:528
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:532
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:536
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:5632
The base class of the type hierarchy.
Definition: Type.h:1568
TypeClass getTypeClass() const
Definition: Type.h:1987
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3304
Wrapper for source info for typedefs.
Definition: TypeLoc.h:686
TypedefNameDecl * getTypedefNameDecl() const
Definition: TypeLoc.h:688
TypedefNameDecl * getDecl() const
Definition: Type.h:4580
void setParensRange(SourceRange range)
Definition: TypeLoc.h:1978
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1983
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1958
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1966
SourceRange getParensRange() const
Definition: TypeLoc.h:1974
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1962
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:1950
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:1954
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1970
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1987
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2076
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:2094
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:530
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2086
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2070
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2069
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2075
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:2078
SourceRange getParensRange() const
Definition: TypeLoc.h:2090
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:2082
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2073
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2072
Wrapper of type source information for a type with no direct qualifiers.
Definition: TypeLoc.h:256
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:265
UnqualTypeLoc(const Type *Ty, void *Data)
Definition: TypeLoc.h:259
const Type * getTypePtr() const
Definition: TypeLoc.h:261
Wrapper for source info for unresolved typename using decls.
Definition: TypeLoc.h:709
UnresolvedUsingTypenameDecl * getDecl() const
Definition: TypeLoc.h:711
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:4517
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3912
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3274
Wrapper for source info for types used via transparent aliases.
Definition: TypeLoc.h:675
QualType getUnderlyingType() const
Definition: TypeLoc.h:677
UsingShadowDecl * getFoundDecl() const
Definition: TypeLoc.h:680
UsingShadowDecl * getFoundDecl() const
Definition: Type.h:4546
QualType getUnderlyingType() const
Definition: Type.cpp:3598
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1809
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1799
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1805
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1801
QualType getInnerType() const
Definition: TypeLoc.h:1811
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1797
QualType getElementType() const
Definition: Type.h:3433
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:55
@ TST_unspecified
Definition: Specifiers.h:56
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition: Type.h:1531
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:47
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:50
@ ETK_None
No keyword precedes the qualified type name.
Definition: Type.h:5616
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
#define bool
Definition: stdbool.h:20
SourceLocation LBracketLoc
Definition: TypeLoc.h:1516
SourceLocation RBracketLoc
Definition: TypeLoc.h:1516
SourceLocation KWLoc
Definition: TypeLoc.h:2556
SourceLocation RParenLoc
Definition: TypeLoc.h:2556
SourceLocation LParenLoc
Definition: TypeLoc.h:2556
const Attr * TypeAttr
Definition: TypeLoc.h:861
SourceLocation TemplateKWLoc
Definition: TypeLoc.h:2108
SourceLocation RAngleLoc
Definition: TypeLoc.h:2112
SourceLocation LAngleLoc
Definition: TypeLoc.h:2111
NestedNameSpecifierLoc NestedNameSpec
Definition: TypeLoc.h:2107
SourceLocation ConceptNameLoc
Definition: TypeLoc.h:2109
NamedDecl * FoundDecl
Definition: TypeLoc.h:2110
SourceLocation RParenLoc
Definition: TypeLoc.h:2115
SourceRange BuiltinRange
Definition: TypeLoc.h:551
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation RParenLoc
Definition: TypeLoc.h:2033
SourceLocation DecltypeLoc
Definition: TypeLoc.h:2032
SourceLocation NameLoc
Definition: TypeLoc.h:2343
SourceLocation ElaboratedKWLoc
Definition: TypeLoc.h:2260
void * QualifierData
Data associated with the nested-name-specifier location.
Definition: TypeLoc.h:2263
SourceLocation LParenLoc
Definition: TypeLoc.h:1382
SourceLocation RParenLoc
Definition: TypeLoc.h:1383
SourceLocation LocalRangeEnd
Definition: TypeLoc.h:1384
SourceLocation LocalRangeBegin
Definition: TypeLoc.h:1381
SourceLocation ExpansionLoc
Definition: TypeLoc.h:1113
SourceLocation AttrLoc
Definition: TypeLoc.h:1866
SourceRange OperandParens
Definition: TypeLoc.h:1867
TypeSourceInfo * ClassTInfo
Definition: TypeLoc.h:1289
SourceLocation NameEndLoc
Definition: TypeLoc.h:1073
SourceLocation NameLoc
Definition: TypeLoc.h:1072
SourceLocation TypeArgsLAngleLoc
Definition: TypeLoc.h:933
SourceLocation ProtocolLAngleLoc
Definition: TypeLoc.h:935
SourceLocation TypeArgsRAngleLoc
Definition: TypeLoc.h:934
SourceLocation ProtocolRAngleLoc
Definition: TypeLoc.h:936
SourceLocation LParenLoc
Definition: TypeLoc.h:1146
SourceLocation RParenLoc
Definition: TypeLoc.h:1147
SourceLocation KWLoc
Definition: TypeLoc.h:2615
SourceLocation StarLoc
Definition: TypeLoc.h:1229
Location information for a TemplateArgument.
Definition: TemplateBase.h:432
SourceLocation NameLoc
Definition: TypeLoc.h:1602
TypeSourceInfo * UnmodifiedTInfo
Definition: TypeLoc.h:1943
SourceLocation NameLoc
Definition: TypeLoc.h:513
SourceLocation RParenLoc
Definition: TypeLoc.h:1936
SourceLocation LParenLoc
Definition: TypeLoc.h:1935
SourceLocation TypeofLoc
Definition: TypeLoc.h:1934
TypeSourceInfo * UnderlyingTInfo
Definition: TypeLoc.h:2061
SourceLocation NameLoc
Definition: TypeLoc.h:1791
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:104