clang 23.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
21#include "clang/AST/TypeBase.h"
22#include "clang/Basic/LLVM.h"
25#include "llvm/ADT/ArrayRef.h"
26#include "llvm/Support/Casting.h"
27#include "llvm/Support/Compiler.h"
28#include "llvm/Support/MathExtras.h"
29#include <algorithm>
30#include <cassert>
31#include <cstdint>
32#include <cstring>
33
34namespace clang {
35
36class Attr;
37class ASTContext;
38class CXXRecordDecl;
39class ConceptDecl;
40class Expr;
44class ParmVarDecl;
46class UnqualTypeLoc;
48
49// Predeclare all the type nodes.
50#define ABSTRACT_TYPELOC(Class, Base)
51#define TYPELOC(Class, Base) \
52 class Class##TypeLoc;
53#include "clang/AST/TypeLocNodes.def"
54
55/// Base wrapper for a particular "section" of type source info.
56///
57/// A client should use the TypeLoc subclasses through castAs()/getAs()
58/// in order to get at the actual information.
59class TypeLoc {
60protected:
61 // The correctness of this relies on the property that, for Type *Ty,
62 // QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty
63 const void *Ty = nullptr;
64 void *Data = nullptr;
65
66public:
67 TypeLoc() = default;
68 TypeLoc(QualType ty, void *opaqueData)
69 : Ty(ty.getAsOpaquePtr()), Data(opaqueData) {}
70 TypeLoc(const Type *ty, void *opaqueData)
71 : Ty(ty), Data(opaqueData) {}
72
73 /// Convert to the specified TypeLoc type, asserting that this TypeLoc
74 /// is of the desired type.
75 ///
76 /// \pre T::isKind(*this)
77 template<typename T>
78 T castAs() const {
79 assert(T::isKind(*this));
80 T t;
81 TypeLoc& tl = t;
82 tl = *this;
83 return t;
84 }
85
86 /// Convert to the specified TypeLoc type, returning a null TypeLoc if
87 /// this TypeLoc is not of the desired type.
88 template<typename T>
89 T getAs() const {
90 if (!T::isKind(*this))
91 return {};
92 T t;
93 TypeLoc& tl = t;
94 tl = *this;
95 return t;
96 }
97
98 /// Convert to the specified TypeLoc type, returning a null TypeLoc if
99 /// this TypeLoc is not of the desired type. It will consider type
100 /// adjustments from a type that was written as a T to another type that is
101 /// still canonically a T (ignores parens, attributes, elaborated types, etc).
102 template <typename T>
103 T getAsAdjusted() const;
104
105 /// The kinds of TypeLocs. Equivalent to the Type::TypeClass enum,
106 /// except it also defines a Qualified enum that corresponds to the
107 /// QualifiedLoc class.
109#define ABSTRACT_TYPE(Class, Base)
110#define TYPE(Class, Base) \
111 Class = Type::Class,
112#include "clang/AST/TypeNodes.inc"
114 };
115
117 if (getType().hasLocalQualifiers()) return Qualified;
118 return (TypeLocClass) getType()->getTypeClass();
119 }
120
121 bool isNull() const { return !Ty; }
122 explicit operator bool() const { return Ty; }
123
124 /// Returns the size of type source info data block for the given type.
125 static unsigned getFullDataSizeForType(QualType Ty);
126
127 /// Returns the alignment of type source info data block for
128 /// the given type.
129 static unsigned getLocalAlignmentForType(QualType Ty);
130
131 /// Get the type for which this source info wrapper provides
132 /// information.
135 }
136
137 const Type *getTypePtr() const {
139 }
140
141 /// Get the pointer where source information is stored.
142 // FIXME: This should provide a type-safe interface.
143 void *getOpaqueData() const {
144 return Data;
145 }
146
147 /// Get the begin source location.
149
150 /// Get the end source location.
152
153 /// Get the full source range.
154 SourceRange getSourceRange() const LLVM_READONLY {
155 return SourceRange(getBeginLoc(), getEndLoc());
156 }
157
158
159 /// Get the local source range.
161 return getLocalSourceRangeImpl(*this);
162 }
163
164 /// Returns the size of the type source info data block.
165 unsigned getFullDataSize() const {
167 }
168
169 /// Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
170 /// TypeLoc is a PointerLoc and next TypeLoc is for "int".
172 return getNextTypeLocImpl(*this);
173 }
174
175 /// Skips past any qualifiers, if this is qualified.
176 UnqualTypeLoc getUnqualifiedLoc() const; // implemented in this header
177
178 TypeLoc IgnoreParens() const;
179
180 /// Find a type with the location of an explicit type qualifier.
181 ///
182 /// The result, if non-null, will be one of:
183 /// QualifiedTypeLoc
184 /// AtomicTypeLoc
185 /// AttributedTypeLoc, for those type attributes that behave as qualifiers
187
188 /// Get the typeloc of an AutoType whose type will be deduced for a variable
189 /// with an initializer of this type. This looks through declarators like
190 /// pointer types, but not through decltype or typedefs.
192
193 /// Get the SourceLocation of the template keyword (if any).
195
196 /// If this type represents a qualified-id, this returns it's nested name
197 /// specifier. For example, for the qualified-id "foo::bar::baz", this returns
198 /// "foo::bar". Returns null if this type represents an unqualified-id.
200
201 /// This returns the position of the type after any elaboration, such as the
202 /// 'struct' keyword. This may be the position of the name qualifiers,
203 /// 'template' keyword, or the name location otherwise.
205
206 /// Initializes this to state that every location in this
207 /// type is the given location.
208 ///
209 /// This method exists to provide a simple transition for code that
210 /// relies on location-less types.
211 void initialize(ASTContext &Context, SourceLocation Loc) const {
212 initializeImpl(Context, *this, Loc);
213 }
214
215 /// Initializes this by copying its information from another
216 /// TypeLoc of the same type.
218 assert(getType() == Other.getType());
219 copy(Other);
220 }
221
222 /// Initializes this by copying its information from another
223 /// TypeLoc of the same type. The given size must be the full data
224 /// size.
225 void initializeFullCopy(TypeLoc Other, unsigned Size) {
226 assert(getType() == Other.getType());
227 assert(getFullDataSize() == Size);
228 copy(Other);
229 }
230
231 /// Copies the other type loc into this one.
232 void copy(TypeLoc other);
233
234 friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS) {
235 return LHS.Ty == RHS.Ty && LHS.Data == RHS.Data;
236 }
237
238 friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS) {
239 return !(LHS == RHS);
240 }
241
242 /// Find the location of the nullability specifier (__nonnull,
243 /// __nullable, or __null_unspecifier), if there is one.
245
246 void dump() const;
247 void dump(llvm::raw_ostream &, const ASTContext &) const;
248
249private:
250 static bool isKind(const TypeLoc&) {
251 return true;
252 }
253
254 static void initializeImpl(ASTContext &Context, TypeLoc TL,
255 SourceLocation Loc);
256 static TypeLoc getNextTypeLocImpl(TypeLoc TL);
257 static TypeLoc IgnoreParensImpl(TypeLoc TL);
258 static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
259};
260
261inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) {
262 // Init data attached to the object. See getTypeLoc.
263 memset(static_cast<void *>(this + 1), 0, DataSize);
264}
265
266/// Return the TypeLoc for a type source info.
268 // TODO: is this alignment already sufficient?
269 return TypeLoc(Ty, const_cast<void*>(static_cast<const void*>(this + 1)));
270}
271
272/// Wrapper of type source information for a type with
273/// no direct qualifiers.
274class UnqualTypeLoc : public TypeLoc {
275public:
276 UnqualTypeLoc() = default;
277 UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
278
279 const Type *getTypePtr() const {
280 return reinterpret_cast<const Type*>(Ty);
281 }
282
286
287private:
288 friend class TypeLoc;
289
290 static bool isKind(const TypeLoc &TL) {
291 return !TL.getType().hasLocalQualifiers();
292 }
293};
294
295/// Wrapper of type source information for a type with
296/// non-trivial direct qualifiers.
297///
298/// Currently, we intentionally do not provide source location for
299/// type qualifiers.
300class QualifiedTypeLoc : public TypeLoc {
301public:
302 SourceRange getLocalSourceRange() const { return {}; }
303
305 unsigned align =
307 auto dataInt = reinterpret_cast<uintptr_t>(Data);
308 dataInt = llvm::alignTo(dataInt, align);
309 return UnqualTypeLoc(getTypePtr(), reinterpret_cast<void*>(dataInt));
310 }
311
312 /// Initializes the local data of this type source info block to
313 /// provide no information.
315 // do nothing
316 }
317
318 void copyLocal(TypeLoc other) {
319 // do nothing
320 }
321
323 return getUnqualifiedLoc();
324 }
325
326 /// Returns the size of the type source info data block that is
327 /// specific to this type.
328 unsigned getLocalDataSize() const {
329 // In fact, we don't currently preserve any location information
330 // for qualifiers.
331 return 0;
332 }
333
334 /// Returns the alignment of the type source info data block that is
335 /// specific to this type.
336 unsigned getLocalDataAlignment() const {
337 // We don't preserve any location information.
338 return 1;
339 }
340
341private:
342 friend class TypeLoc;
343
344 static bool isKind(const TypeLoc &TL) {
345 return TL.getType().hasLocalQualifiers();
346 }
347};
348
354
355/// A metaprogramming base class for TypeLoc classes which correspond
356/// to a particular Type subclass. It is accepted for a single
357/// TypeLoc class to correspond to multiple Type classes.
358///
359/// \tparam Base a class from which to derive
360/// \tparam Derived the class deriving from this one
361/// \tparam TypeClass the concrete Type subclass associated with this
362/// location type
363/// \tparam LocalData the structure type of local location data for
364/// this type
365///
366/// TypeLocs with non-constant amounts of local data should override
367/// getExtraLocalDataSize(); getExtraLocalData() will then point to
368/// this extra memory.
369///
370/// TypeLocs with an inner type should define
371/// QualType getInnerType() const
372/// and getInnerTypeLoc() will then point to this inner type's
373/// location data.
374///
375/// A word about hierarchies: this template is not designed to be
376/// derived from multiple times in a hierarchy. It is also not
377/// designed to be used for classes where subtypes might provide
378/// different amounts of source information. It should be subclassed
379/// only at the deepest portion of the hierarchy where all children
380/// have identical source information; if that's an abstract type,
381/// then further descendents should inherit from
382/// InheritingConcreteTypeLoc instead.
383template <class Base, class Derived, class TypeClass, class LocalData>
384class ConcreteTypeLoc : public Base {
385 friend class TypeLoc;
386
387 const Derived *asDerived() const {
388 return static_cast<const Derived*>(this);
389 }
390
391 static bool isKind(const TypeLoc &TL) {
392 return !TL.getType().hasLocalQualifiers() &&
393 Derived::classofType(TL.getTypePtr());
394 }
395
396 static bool classofType(const Type *Ty) {
397 return TypeClass::classof(Ty);
398 }
399
400public:
401 unsigned getLocalDataAlignment() const {
402 return std::max(unsigned(alignof(LocalData)),
403 asDerived()->getExtraLocalDataAlignment());
404 }
405
406 unsigned getLocalDataSize() const {
407 unsigned size = sizeof(LocalData);
408 unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
409 size = llvm::alignTo(size, extraAlign);
410 size += asDerived()->getExtraLocalDataSize();
411 size = llvm::alignTo(size, asDerived()->getLocalDataAlignment());
412 return size;
413 }
414
415 void copyLocal(Derived other) {
416 // Some subclasses have no data to copy.
417 if (asDerived()->getLocalDataSize() == 0) return;
418
419 // Copy the fixed-sized local data.
420 memcpy(getLocalData(), other.getLocalData(), sizeof(LocalData));
421
422 // Copy the variable-sized local data. We need to do this
423 // separately because the padding in the source and the padding in
424 // the destination might be different.
425 memcpy(getExtraLocalData(), other.getExtraLocalData(),
426 asDerived()->getExtraLocalDataSize());
427 }
428
430 return getNextTypeLoc(asDerived()->getInnerType());
431 }
432
433 const TypeClass *getTypePtr() const {
434 return cast<TypeClass>(Base::getTypePtr());
435 }
436
437protected:
438 unsigned getExtraLocalDataSize() const {
439 return 0;
440 }
441
442 unsigned getExtraLocalDataAlignment() const {
443 return 1;
444 }
445
446 LocalData *getLocalData() const {
447 return static_cast<LocalData*>(Base::Data);
448 }
449
450 /// Gets a pointer past the Info structure; useful for classes with
451 /// local data that can't be captured in the Info (e.g. because it's
452 /// of variable size).
453 void *getExtraLocalData() const {
454 unsigned size = sizeof(LocalData);
455 unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
456 size = llvm::alignTo(size, extraAlign);
457 return reinterpret_cast<char *>(Base::Data) + size;
458 }
459
460 void *getNonLocalData() const {
461 auto data = reinterpret_cast<uintptr_t>(Base::Data);
462 data += asDerived()->getLocalDataSize();
463 data = llvm::alignTo(data, getNextTypeAlign());
464 return reinterpret_cast<void*>(data);
465 }
466
467 struct HasNoInnerType {};
469
471 return TypeLoc(asDerived()->getInnerType(), getNonLocalData());
472 }
473
474private:
475 unsigned getInnerTypeSize() const {
476 return getInnerTypeSize(asDerived()->getInnerType());
477 }
478
479 unsigned getInnerTypeSize(HasNoInnerType _) const {
480 return 0;
481 }
482
483 unsigned getInnerTypeSize(QualType _) const {
485 }
486
487 unsigned getNextTypeAlign() const {
488 return getNextTypeAlign(asDerived()->getInnerType());
489 }
490
491 unsigned getNextTypeAlign(HasNoInnerType _) const {
492 return 1;
493 }
494
495 unsigned getNextTypeAlign(QualType T) const {
497 }
498
499 TypeLoc getNextTypeLoc(HasNoInnerType _) const { return {}; }
500
501 TypeLoc getNextTypeLoc(QualType T) const {
502 return TypeLoc(T, getNonLocalData());
503 }
504};
505
506/// A metaprogramming class designed for concrete subtypes of abstract
507/// types where all subtypes share equivalently-structured source
508/// information. See the note on ConcreteTypeLoc.
509template <class Base, class Derived, class TypeClass>
511 friend class TypeLoc;
512
513 static bool classofType(const Type *Ty) {
514 return TypeClass::classof(Ty);
515 }
516
517 static bool isKind(const TypeLoc &TL) {
518 return !TL.getType().hasLocalQualifiers() &&
519 Derived::classofType(TL.getTypePtr());
520 }
521 static bool isKind(const UnqualTypeLoc &TL) {
522 return Derived::classofType(TL.getTypePtr());
523 }
524
525public:
526 const TypeClass *getTypePtr() const {
527 return cast<TypeClass>(Base::getTypePtr());
528 }
529};
530
534
535/// A reasonable base class for TypeLocs that correspond to
536/// types that are written as a type-specifier.
537class TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
538 TypeSpecTypeLoc,
539 Type,
540 TypeSpecLocInfo> {
541public:
542 enum {
545 };
546
548 return this->getLocalData()->NameLoc;
549 }
550
552 this->getLocalData()->NameLoc = Loc;
553 }
554
558
560 setNameLoc(Loc);
561 }
562
563private:
564 friend class TypeLoc;
565
566 static bool isKind(const TypeLoc &TL);
567};
568
572
573/// Wrapper for source info for builtin types.
574class BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
575 BuiltinTypeLoc,
576 BuiltinType,
577 BuiltinLocInfo> {
578public:
582
584 getLocalData()->BuiltinRange = Loc;
585 }
586
588 SourceRange &BuiltinRange = getLocalData()->BuiltinRange;
589 if (!BuiltinRange.getBegin().isValid()) {
590 BuiltinRange = Range;
591 } else {
592 BuiltinRange.setBegin(std::min(Range.getBegin(), BuiltinRange.getBegin()));
593 BuiltinRange.setEnd(std::max(Range.getEnd(), BuiltinRange.getEnd()));
594 }
595 }
596
598
603 return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
604 }
605
606 bool needsExtraLocalData() const {
608 return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) ||
609 (bk >= BuiltinType::Short && bk <= BuiltinType::Ibm128) ||
610 bk == BuiltinType::UChar || bk == BuiltinType::SChar;
611 }
612
613 unsigned getExtraLocalDataSize() const {
614 return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0;
615 }
616
617 unsigned getExtraLocalDataAlignment() const {
618 return needsExtraLocalData() ? alignof(WrittenBuiltinSpecs) : 1;
619 }
620
624
631
635
638 getWrittenBuiltinSpecs().Sign = static_cast<unsigned>(written);
639 }
640
647
651
654 getWrittenBuiltinSpecs().Width = static_cast<unsigned>(written);
655 }
656
658
659 bool hasWrittenTypeSpec() const {
661 }
662
665 getWrittenBuiltinSpecs().Type = written;
666 }
667
668 bool hasModeAttr() const {
671 else
672 return false;
673 }
674
675 void setModeAttr(bool written) {
678 }
679
681 setBuiltinLoc(Loc);
682 if (needsExtraLocalData()) {
684 wbs.Sign = static_cast<unsigned>(TypeSpecifierSign::Unspecified);
685 wbs.Width = static_cast<unsigned>(TypeSpecifierWidth::Unspecified);
686 wbs.Type = TST_unspecified;
687 wbs.ModeAttr = false;
688 }
689 }
690};
691
695
703 NestedNameSpecifier Qualifier, SourceLocation Loc)
704 : NameLoc(Loc),
707 QualifierData(getTrivialQualifierData(Context, Qualifier, Loc)) {}
708
710 assert(!Qualifier == !QualifierData);
711 return NestedNameSpecifierLoc(Qualifier, QualifierData);
712 }
713
716 if (NestedNameSpecifierLoc QualifierLoc = getQualifierLoc(Qualifier);
717 BeginLoc.isInvalid() && Qualifier)
718 BeginLoc = QualifierLoc.getBeginLoc();
719 if (BeginLoc.isInvalid())
720 BeginLoc = NameLoc;
721 return SourceRange(BeginLoc, NameLoc);
722 }
723
724private:
725 void *QualifierData;
726
727 static void *getTrivialQualifierData(ASTContext &Context,
728 NestedNameSpecifier Qualifier,
729 SourceLocation Loc) {
730 if (!Qualifier)
731 return nullptr;
733 Builder.MakeTrivial(Context, Qualifier, Loc);
734 return Builder.getWithLocInContext(Context).getOpaqueData();
735 }
736};
737
738template <class TL, class T>
740 : public ConcreteTypeLoc<UnqualTypeLoc, TL, T, ElaboratedNameLocInfo> {
741public:
742 auto *getDecl() const { return this->getTypePtr()->getDecl(); }
743
744 void set(SourceLocation ElaboratedKeywordLoc,
745 NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc) {
746 assert(QualifierLoc.getNestedNameSpecifier() ==
747 this->getTypePtr()->getQualifier());
748 *this->getLocalData() =
749 ElaboratedNameLocInfo(ElaboratedKeywordLoc, QualifierLoc, NameLoc);
750 }
751
755
757 return this->getLocalData()->getQualifierLoc(
758 this->getTypePtr()->getQualifier());
759 }
760
761 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
762
764 return this->getLocalData()->getLocalSourceRange(
765 this->getTypePtr()->getQualifier());
766 }
767
769 const auto *Ptr = this->getTypePtr();
770 *this->getLocalData() = ElaboratedNameLocInfo(Context, Ptr->getKeyword(),
771 Ptr->getQualifier(), Loc);
772 }
773};
774
775/// Wrapper for source info for typedefs.
777 : public ElaboratedNameTypeLoc<TypedefTypeLoc, TypedefType> {};
778
779/// Wrapper for source info for unresolved typename using decls.
781 : public ElaboratedNameTypeLoc<UnresolvedUsingTypeLoc,
782 UnresolvedUsingType> {};
783
784/// Wrapper for source info for types used via transparent aliases.
785class UsingTypeLoc : public ElaboratedNameTypeLoc<UsingTypeLoc, UsingType> {};
786
792
793class TagTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, TagTypeLoc, TagType,
794 TagTypeLocInfo> {
795public:
796 TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
797
798 /// True if the tag was defined in this type specifier.
799 bool isDefinition() const;
800
804
808
810 NestedNameSpecifier Qualifier = getTypePtr()->getQualifier();
811 void *QualifierData = getLocalData()->QualifierData;
812 assert(!Qualifier == !QualifierData);
813 return NestedNameSpecifierLoc(Qualifier, QualifierData);
814 }
815
817 assert(QualifierLoc.getNestedNameSpecifier() ==
818 getTypePtr()->getQualifier());
819 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
820 }
821
823
825
828 if (NestedNameSpecifierLoc Qualifier = getQualifierLoc();
829 BeginLoc.isInvalid() && Qualifier)
830 BeginLoc = Qualifier.getBeginLoc();
831 if (BeginLoc.isInvalid())
832 BeginLoc = getNameLoc();
833 return SourceRange(BeginLoc, getNameLoc());
834 }
835
837 setElaboratedKeywordLoc(getTypePtr()->getKeyword() !=
839 ? Loc
840 : SourceLocation());
841 if (NestedNameSpecifier Qualifier = getTypePtr()->getQualifier()) {
843 Builder.MakeTrivial(Context, Qualifier, Loc);
844 setQualifierLoc(Builder.getWithLocInContext(Context));
845 } else {
846 getLocalData()->QualifierData = nullptr;
847 }
848 setNameLoc(Loc);
849 }
850};
851
852/// Wrapper for source info for record types.
853class RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
854 RecordTypeLoc,
855 RecordType> {
856public:
857 RecordDecl *getDecl() const { return getTypePtr()->getDecl(); }
858};
859
860/// Wrapper for source info for enum types.
861class EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
862 EnumTypeLoc,
863 EnumType> {
864public:
865 EnumDecl *getDecl() const { return getTypePtr()->getDecl(); }
866};
867
868/// Wrapper for source info for injected class names of class
869/// templates.
871 : public InheritingConcreteTypeLoc<TagTypeLoc, InjectedClassNameTypeLoc,
872 InjectedClassNameType> {
873public:
874 CXXRecordDecl *getDecl() const { return getTypePtr()->getDecl(); }
875};
876
877/// Wrapper for template type parameters.
879 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
880 TemplateTypeParmTypeLoc,
881 TemplateTypeParmType> {
882public:
883 TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); }
884};
885
889
890/// ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for
891/// protocol qualifiers are stored after Info.
892class ObjCTypeParamTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
893 ObjCTypeParamTypeLoc,
894 ObjCTypeParamType,
895 ObjCTypeParamTypeLocInfo> {
896 // SourceLocations are stored after Info, one for each protocol qualifier.
897 SourceLocation *getProtocolLocArray() const {
898 return (SourceLocation*)this->getExtraLocalData() + 2;
899 }
900
901public:
902 ObjCTypeParamDecl *getDecl() const { return getTypePtr()->getDecl(); }
903
905 return this->getLocalData()->NameLoc;
906 }
907
909 this->getLocalData()->NameLoc = Loc;
910 }
911
917
919 *((SourceLocation*)this->getExtraLocalData()) = Loc;
920 }
921
923 return getNumProtocols() ?
924 *((SourceLocation*)this->getExtraLocalData() + 1) :
926 }
927
929 *((SourceLocation*)this->getExtraLocalData() + 1) = Loc;
930 }
931
932 unsigned getNumProtocols() const {
933 return this->getTypePtr()->getNumProtocols();
934 }
935
936 SourceLocation getProtocolLoc(unsigned i) const {
937 assert(i < getNumProtocols() && "Index is out of bounds!");
938 return getProtocolLocArray()[i];
939 }
940
941 void setProtocolLoc(unsigned i, SourceLocation Loc) {
942 assert(i < getNumProtocols() && "Index is out of bounds!");
943 getProtocolLocArray()[i] = Loc;
944 }
945
946 ObjCProtocolDecl *getProtocol(unsigned i) const {
947 assert(i < getNumProtocols() && "Index is out of bounds!");
948 return *(this->getTypePtr()->qual_begin() + i);
949 }
950
952 return {getProtocolLocArray(), getNumProtocols()};
953 }
954
955 void initializeLocal(ASTContext &Context, SourceLocation Loc);
956
957 unsigned getExtraLocalDataSize() const {
958 if (!this->getNumProtocols()) return 0;
959 // When there are protocol qualifers, we have LAngleLoc and RAngleLoc
960 // as well.
961 return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ;
962 }
963
964 unsigned getExtraLocalDataAlignment() const {
965 return alignof(SourceLocation);
966 }
967
969 SourceLocation start = getNameLoc();
971 if (end.isInvalid()) return SourceRange(start, start);
972 return SourceRange(start, end);
973 }
974};
975
976/// Wrapper for substituted template type parameters.
978 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
979 SubstTemplateTypeParmTypeLoc,
980 SubstTemplateTypeParmType> {
981};
982
983/// Abstract type representing delayed type pack expansions.
985 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, SubstPackTypeLoc,
986 SubstPackType> {};
987
988/// Wrapper for substituted template type parameters.
990 : public InheritingConcreteTypeLoc<SubstPackTypeLoc,
991 SubstTemplateTypeParmPackTypeLoc,
992 SubstTemplateTypeParmPackType> {};
993
994/// Wrapper for substituted template type parameters.
996 : public InheritingConcreteTypeLoc<SubstPackTypeLoc,
997 SubstBuiltinTemplatePackTypeLoc,
998 SubstBuiltinTemplatePackType> {};
999
1002};
1003
1004/// Type source information for an attributed type.
1005class AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1006 AttributedTypeLoc,
1007 AttributedType,
1008 AttributedLocInfo> {
1009public:
1011 return getTypePtr()->getAttrKind();
1012 }
1013
1014 bool isQualifier() const {
1015 return getTypePtr()->isQualifier();
1016 }
1017
1018 /// The modified type, which is generally canonically different from
1019 /// the attribute type.
1020 /// int main(int, char**) __attribute__((noreturn))
1021 /// ~~~ ~~~~~~~~~~~~~
1023 return getInnerTypeLoc();
1024 }
1025
1027 return TypeLoc(getTypePtr()->getEquivalentType(), getNonLocalData());
1028 }
1029
1030 /// The type attribute.
1031 const Attr *getAttr() const {
1032 return getLocalData()->TypeAttr;
1033 }
1034 void setAttr(const Attr *A) {
1035 getLocalData()->TypeAttr = A;
1036 }
1037
1038 template<typename T> const T *getAttrAs() {
1039 return dyn_cast_or_null<T>(getAttr());
1040 }
1041
1043
1045 setAttr(nullptr);
1046 }
1047
1049 return getTypePtr()->getModifiedType();
1050 }
1051};
1052
1053struct BTFTagAttributedLocInfo {}; // Nothing.
1054
1055/// Type source information for an btf_tag attributed type.
1057 : public ConcreteTypeLoc<UnqualTypeLoc, BTFTagAttributedTypeLoc,
1058 BTFTagAttributedType, BTFTagAttributedLocInfo> {
1059public:
1061
1062 /// The btf_type_tag attribute.
1063 const BTFTypeTagAttr *getAttr() const { return getTypePtr()->getAttr(); }
1064
1065 template <typename T> T *getAttrAs() {
1066 return dyn_cast_or_null<T>(getAttr());
1067 }
1068
1070
1072
1073 QualType getInnerType() const { return getTypePtr()->getWrappedType(); }
1074};
1075
1080
1081/// Type source information for HLSL attributed resource type.
1083 : public ConcreteTypeLoc<UnqualTypeLoc, HLSLAttributedResourceTypeLoc,
1084 HLSLAttributedResourceType,
1085 HLSLAttributedResourceLocInfo> {
1086public:
1088
1095
1102 QualType getInnerType() const { return getTypePtr()->getWrappedType(); }
1103 unsigned getLocalDataSize() const {
1104 return sizeof(HLSLAttributedResourceLocInfo);
1105 }
1106};
1107
1111
1113 : public ConcreteTypeLoc<UnqualTypeLoc, HLSLInlineSpirvTypeLoc,
1114 HLSLInlineSpirvType, HLSLInlineSpirvTypeLocInfo> {
1115public:
1117 void setSpirvTypeLoc(SourceLocation loc) const { getLocalData()->Loc = loc; }
1118
1123 setSpirvTypeLoc(loc);
1124 }
1125};
1126
1134
1135// A helper class for defining ObjC TypeLocs that can qualified with
1136// protocols.
1137//
1138// TypeClass basically has to be either ObjCInterfaceType or
1139// ObjCObjectPointerType.
1140class ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1141 ObjCObjectTypeLoc,
1142 ObjCObjectType,
1143 ObjCObjectTypeLocInfo> {
1144 // TypeSourceInfo*'s are stored after Info, one for each type argument.
1145 TypeSourceInfo **getTypeArgLocArray() const {
1146 return (TypeSourceInfo**)this->getExtraLocalData();
1147 }
1148
1149 // SourceLocations are stored after the type argument information, one for
1150 // each Protocol.
1151 SourceLocation *getProtocolLocArray() const {
1152 return (SourceLocation*)(getTypeArgLocArray() + getNumTypeArgs());
1153 }
1154
1155public:
1159
1163
1167
1171
1172 unsigned getNumTypeArgs() const {
1173 return this->getTypePtr()->getTypeArgsAsWritten().size();
1174 }
1175
1176 TypeSourceInfo *getTypeArgTInfo(unsigned i) const {
1177 assert(i < getNumTypeArgs() && "Index is out of bounds!");
1178 return getTypeArgLocArray()[i];
1179 }
1180
1181 void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo) {
1182 assert(i < getNumTypeArgs() && "Index is out of bounds!");
1183 getTypeArgLocArray()[i] = TInfo;
1184 }
1185
1189
1193
1197
1201
1202 unsigned getNumProtocols() const {
1203 return this->getTypePtr()->getNumProtocols();
1204 }
1205
1206 SourceLocation getProtocolLoc(unsigned i) const {
1207 assert(i < getNumProtocols() && "Index is out of bounds!");
1208 return getProtocolLocArray()[i];
1209 }
1210
1211 void setProtocolLoc(unsigned i, SourceLocation Loc) {
1212 assert(i < getNumProtocols() && "Index is out of bounds!");
1213 getProtocolLocArray()[i] = Loc;
1214 }
1215
1216 ObjCProtocolDecl *getProtocol(unsigned i) const {
1217 assert(i < getNumProtocols() && "Index is out of bounds!");
1218 return *(this->getTypePtr()->qual_begin() + i);
1219 }
1220
1221
1223 return {getProtocolLocArray(), getNumProtocols()};
1224 }
1225
1228 }
1229
1230 void setHasBaseTypeAsWritten(bool HasBaseType) {
1231 getLocalData()->HasBaseTypeAsWritten = HasBaseType;
1232 }
1233
1235 return getInnerTypeLoc();
1236 }
1237
1240 if (start.isInvalid())
1241 start = getProtocolLAngleLoc();
1243 if (end.isInvalid())
1244 end = getTypeArgsRAngleLoc();
1245 return SourceRange(start, end);
1246 }
1247
1248 void initializeLocal(ASTContext &Context, SourceLocation Loc);
1249
1250 unsigned getExtraLocalDataSize() const {
1251 return this->getNumTypeArgs() * sizeof(TypeSourceInfo *)
1252 + this->getNumProtocols() * sizeof(SourceLocation);
1253 }
1254
1256 static_assert(alignof(ObjCObjectTypeLoc) >= alignof(TypeSourceInfo *),
1257 "not enough alignment for tail-allocated data");
1258 return alignof(TypeSourceInfo *);
1259 }
1260
1262 return getTypePtr()->getBaseType();
1263 }
1264};
1265
1270
1271/// Wrapper for source info for ObjC interfaces.
1272class ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc,
1273 ObjCInterfaceTypeLoc,
1274 ObjCInterfaceType,
1275 ObjCInterfaceLocInfo> {
1276public:
1278 return getTypePtr()->getDecl();
1279 }
1280
1282 return getLocalData()->NameLoc;
1283 }
1284
1286 getLocalData()->NameLoc = Loc;
1287 }
1288
1292
1294 return getLocalData()->NameEndLoc;
1295 }
1296
1298 getLocalData()->NameEndLoc = Loc;
1299 }
1300
1302 setNameLoc(Loc);
1303 setNameEndLoc(Loc);
1304 }
1305};
1306
1309 : public ConcreteTypeLoc<UnqualTypeLoc, BoundsAttributedTypeLoc,
1310 BoundsAttributedType, BoundsAttributedLocInfo> {
1311public:
1313 QualType getInnerType() const { return getTypePtr()->desugar(); }
1315 // nothing to do
1316 }
1317 // LocalData is empty and TypeLocBuilder doesn't handle DataSize 1.
1318 unsigned getLocalDataSize() const { return 0; }
1319};
1320
1322 : public InheritingConcreteTypeLoc<BoundsAttributedTypeLoc,
1323 CountAttributedTypeLoc,
1324 CountAttributedType> {
1325public:
1326 Expr *getCountExpr() const { return getTypePtr()->getCountExpr(); }
1327 bool isCountInBytes() const { return getTypePtr()->isCountInBytes(); }
1328 bool isOrNull() const { return getTypePtr()->isOrNull(); }
1329
1331};
1332
1336
1338 : public ConcreteTypeLoc<UnqualTypeLoc, MacroQualifiedTypeLoc,
1339 MacroQualifiedType, MacroQualifiedLocInfo> {
1340public:
1342 setExpansionLoc(Loc);
1343 }
1344
1346
1348 return getTypePtr()->getMacroIdentifier();
1349 }
1350
1352 return this->getLocalData()->ExpansionLoc;
1353 }
1354
1356 this->getLocalData()->ExpansionLoc = Loc;
1357 }
1358
1360
1364};
1365
1370
1372 : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
1373 ParenLocInfo> {
1374public:
1376 return this->getLocalData()->LParenLoc;
1377 }
1378
1380 return this->getLocalData()->RParenLoc;
1381 }
1382
1384 this->getLocalData()->LParenLoc = Loc;
1385 }
1386
1388 this->getLocalData()->RParenLoc = Loc;
1389 }
1390
1394
1396 setLParenLoc(Loc);
1397 setRParenLoc(Loc);
1398 }
1399
1401 return getInnerTypeLoc();
1402 }
1403
1405 return this->getTypePtr()->getInnerType();
1406 }
1407};
1408
1410 if (ParenTypeLoc::isKind(*this))
1411 return IgnoreParensImpl(*this);
1412 return *this;
1413}
1414
1415struct AdjustedLocInfo {}; // Nothing.
1416
1417class AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc,
1418 AdjustedType, AdjustedLocInfo> {
1419public:
1421 return getInnerTypeLoc();
1422 }
1423
1425 // do nothing
1426 }
1427
1429 // The inner type is the undecayed type, since that's what we have source
1430 // location information for.
1431 return getTypePtr()->getOriginalType();
1432 }
1433
1434 SourceRange getLocalSourceRange() const { return {}; }
1435
1436 unsigned getLocalDataSize() const {
1437 // sizeof(AdjustedLocInfo) is 1, but we don't need its address to be unique
1438 // anyway. TypeLocBuilder can't handle data sizes of 1.
1439 return 0; // No data.
1440 }
1441};
1442
1443/// Wrapper for source info for pointers decayed from arrays and
1444/// functions.
1446 AdjustedTypeLoc, DecayedTypeLoc, DecayedType> {
1447};
1448
1452
1453/// A base class for
1454template <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
1455class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
1456 TypeClass, LocalData> {
1457public:
1459 return this->getLocalData()->StarLoc;
1460 }
1461
1463 this->getLocalData()->StarLoc = Loc;
1464 }
1465
1467 return this->getInnerTypeLoc();
1468 }
1469
1473
1475 setSigilLoc(Loc);
1476 }
1477
1479 return this->getTypePtr()->getPointeeType();
1480 }
1481};
1482
1483/// Wrapper for source info for pointers.
1484class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
1485 PointerType> {
1486public:
1488 return getSigilLoc();
1489 }
1490
1492 setSigilLoc(Loc);
1493 }
1494};
1495
1496/// Wrapper for source info for block pointers.
1497class BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
1498 BlockPointerType> {
1499public:
1501 return getSigilLoc();
1502 }
1503
1505 setSigilLoc(Loc);
1506 }
1507};
1508
1510 void *QualifierData = nullptr;
1511};
1512
1513/// Wrapper for source info for member pointers.
1514class MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
1515 MemberPointerType,
1516 MemberPointerLocInfo> {
1517public:
1519 return getSigilLoc();
1520 }
1521
1523 setSigilLoc(Loc);
1524 }
1525
1527 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
1528 getLocalData()->QualifierData);
1529 }
1530
1532 assert(QualifierLoc.getNestedNameSpecifier() ==
1533 getTypePtr()->getQualifier() &&
1534 "Inconsistent nested-name-specifier pointer");
1535 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
1536 }
1537
1539 setSigilLoc(Loc);
1540 if (NestedNameSpecifier Qualifier = getTypePtr()->getQualifier()) {
1542 Builder.MakeTrivial(Context, Qualifier, Loc);
1543 setQualifierLoc(Builder.getWithLocInContext(Context));
1544 } else
1545 getLocalData()->QualifierData = nullptr;
1546 }
1547
1550 return SourceRange(QL.getBeginLoc(), getStarLoc());
1551 return SourceRange(getStarLoc());
1552 }
1553};
1554
1555/// Wraps an ObjCPointerType with source location information.
1557 public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
1558 ObjCObjectPointerType> {
1559public:
1561 return getSigilLoc();
1562 }
1563
1565 setSigilLoc(Loc);
1566 }
1567};
1568
1569class ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
1570 ReferenceType> {
1571public:
1574 }
1575};
1576
1578 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1579 LValueReferenceTypeLoc,
1580 LValueReferenceType> {
1581public:
1583 return getSigilLoc();
1584 }
1585
1587 setSigilLoc(Loc);
1588 }
1589};
1590
1592 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1593 RValueReferenceTypeLoc,
1594 RValueReferenceType> {
1595public:
1597 return getSigilLoc();
1598 }
1599
1601 setSigilLoc(Loc);
1602 }
1603};
1604
1611
1612/// Wrapper for source info for functions.
1613class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1614 FunctionTypeLoc,
1615 FunctionType,
1616 FunctionLocInfo> {
1617 bool hasExceptionSpec() const {
1618 if (auto *FPT = dyn_cast<FunctionProtoType>(getTypePtr())) {
1619 return FPT->hasExceptionSpec();
1620 }
1621 return false;
1622 }
1623
1624 SourceRange *getExceptionSpecRangePtr() const {
1625 assert(hasExceptionSpec() && "No exception spec range");
1626 // After the Info comes the ParmVarDecl array, and after that comes the
1627 // exception specification information.
1628 return (SourceRange *)(getParmArray() + getNumParams());
1629 }
1630
1631public:
1635
1639
1643
1647
1649 return this->getLocalData()->LParenLoc;
1650 }
1651
1653 this->getLocalData()->LParenLoc = Loc;
1654 }
1655
1657 return this->getLocalData()->RParenLoc;
1658 }
1659
1661 this->getLocalData()->RParenLoc = Loc;
1662 }
1663
1667
1669 if (hasExceptionSpec())
1670 return *getExceptionSpecRangePtr();
1671 return {};
1672 }
1673
1675 if (hasExceptionSpec())
1676 *getExceptionSpecRangePtr() = R;
1677 }
1678
1680 return {getParmArray(), getNumParams()};
1681 }
1682
1683 // ParmVarDecls* are stored after Info, one for each parameter.
1685 return (ParmVarDecl**) getExtraLocalData();
1686 }
1687
1688 unsigned getNumParams() const {
1690 return 0;
1691 return cast<FunctionProtoType>(getTypePtr())->getNumParams();
1692 }
1693
1694 ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; }
1695 void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1696
1698 return getInnerTypeLoc();
1699 }
1700
1704
1706 setLocalRangeBegin(Loc);
1707 setLParenLoc(Loc);
1708 setRParenLoc(Loc);
1709 setLocalRangeEnd(Loc);
1710 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
1711 setParam(i, nullptr);
1712 if (hasExceptionSpec())
1714 }
1715
1716 /// Returns the size of the type source info data block that is
1717 /// specific to this type.
1718 unsigned getExtraLocalDataSize() const {
1719 unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
1720 return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
1721 }
1722
1723 unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); }
1724
1726};
1727
1729 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1730 FunctionProtoTypeLoc,
1731 FunctionProtoType> {
1732};
1733
1735 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1736 FunctionNoProtoTypeLoc,
1737 FunctionNoProtoType> {
1738};
1739
1744
1745/// Wrapper for source info for arrays.
1746class ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1747 ArrayTypeLoc,
1748 ArrayType,
1749 ArrayLocInfo> {
1750public:
1752 return getLocalData()->LBracketLoc;
1753 }
1754
1756 getLocalData()->LBracketLoc = Loc;
1757 }
1758
1760 return getLocalData()->RBracketLoc;
1761 }
1762
1764 getLocalData()->RBracketLoc = Loc;
1765 }
1766
1770
1772 return getLocalData()->Size;
1773 }
1774
1775 void setSizeExpr(Expr *Size) {
1776 getLocalData()->Size = Size;
1777 }
1778
1780 return getInnerTypeLoc();
1781 }
1782
1786
1788 setLBracketLoc(Loc);
1789 setRBracketLoc(Loc);
1790 setSizeExpr(nullptr);
1791 }
1792
1794};
1795
1797 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1798 ConstantArrayTypeLoc,
1799 ConstantArrayType> {
1800};
1801
1802/// Wrapper for source info for array parameter types.
1805 ConstantArrayTypeLoc, ArrayParameterTypeLoc, ArrayParameterType> {};
1806
1808 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1809 IncompleteArrayTypeLoc,
1810 IncompleteArrayType> {
1811};
1812
1814 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1815 DependentSizedArrayTypeLoc,
1816 DependentSizedArrayType> {
1817public:
1822};
1823
1825 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1826 VariableArrayTypeLoc,
1827 VariableArrayType> {
1828};
1829
1830// Location information for a TemplateName. Rudimentary for now.
1834
1842
1844 public ConcreteTypeLoc<UnqualTypeLoc,
1845 TemplateSpecializationTypeLoc,
1846 TemplateSpecializationType,
1847 TemplateSpecializationLocInfo> {
1848public:
1849 void set(SourceLocation ElaboratedKeywordLoc,
1850 NestedNameSpecifierLoc QualifierLoc,
1851 SourceLocation TemplateKeywordLoc, SourceLocation NameLoc,
1852 SourceLocation LAngleLoc, SourceLocation RAngleLoc);
1853
1854 void set(SourceLocation ElaboratedKeywordLoc,
1855 NestedNameSpecifierLoc QualifierLoc,
1856 SourceLocation TemplateKeywordLoc, SourceLocation NameLoc,
1857 const TemplateArgumentListInfo &TAL);
1858
1862
1864 if (!getLocalData()->QualifierData)
1865 return NestedNameSpecifierLoc();
1866
1867 NestedNameSpecifier Qualifier =
1868 getTypePtr()->getTemplateName().getQualifier();
1869 assert(Qualifier && "missing qualification");
1870 return NestedNameSpecifierLoc(Qualifier, getLocalData()->QualifierData);
1871 }
1872
1876
1878
1880
1881 unsigned getNumArgs() const {
1882 return getTypePtr()->template_arguments().size();
1883 }
1884
1886 return {getArgInfos(), getNumArgs()};
1887 }
1888
1889 TemplateArgumentLoc getArgLoc(unsigned i) const {
1890 return TemplateArgumentLoc(getTypePtr()->template_arguments()[i],
1891 getArgInfos()[i]);
1892 }
1893
1895
1896 /// - Copy the location information from the given info.
1898 unsigned size = getFullDataSize();
1899 assert(size == Loc.getFullDataSize());
1900
1901 // We're potentially copying Expr references here. We don't
1902 // bother retaining them because TypeSourceInfos live forever, so
1903 // as long as the Expr was retained when originally written into
1904 // the TypeLoc, we're okay.
1905 memcpy(Data, Loc.Data, size);
1906 }
1907
1909
1910 void initializeLocal(ASTContext &Context, SourceLocation Loc);
1911
1912 static void initializeArgLocs(ASTContext &Context,
1914 TemplateArgumentLocInfo *ArgInfos,
1915 SourceLocation Loc);
1916
1917 unsigned getExtraLocalDataSize() const {
1918 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1919 }
1920
1922 return alignof(TemplateArgumentLocInfo);
1923 }
1924
1925private:
1926 TemplateArgumentLocInfo *getArgInfos() const {
1927 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1928 }
1929};
1930
1936
1938 : public ConcreteTypeLoc<UnqualTypeLoc,
1939 DependentAddressSpaceTypeLoc,
1940 DependentAddressSpaceType,
1941 DependentAddressSpaceLocInfo> {
1942public:
1943 /// The location of the attribute name, i.e.
1944 /// int * __attribute__((address_space(11)))
1945 /// ^~~~~~~~~~~~~
1947 return getLocalData()->AttrLoc;
1948 }
1950 getLocalData()->AttrLoc = loc;
1951 }
1952
1953 /// The attribute's expression operand, if it has one.
1954 /// int * __attribute__((address_space(11)))
1955 /// ^~
1957 return getLocalData()->ExprOperand;
1958 }
1961 }
1962
1963 /// The location of the parentheses around the operand, if there is
1964 /// an operand.
1965 /// int * __attribute__((address_space(11)))
1966 /// ^ ^
1973
1975 SourceRange range(getAttrNameLoc());
1976 range.setEnd(getAttrOperandParensRange().getEnd());
1977 return range;
1978 }
1979
1980 /// Returns the type before the address space attribute application
1981 /// area.
1982 /// int * __attribute__((address_space(11))) *
1983 /// ^ ^
1985 return this->getTypePtr()->getPointeeType();
1986 }
1987
1989 return this->getInnerTypeLoc();
1990 }
1991
1993 setAttrNameLoc(loc);
1996 setAttrExprOperand(getTypePtr()->getAddrSpaceExpr());
1997 }
1998};
1999
2000//===----------------------------------------------------------------------===//
2001//
2002// All of these need proper implementations.
2003//
2004//===----------------------------------------------------------------------===//
2005
2006// FIXME: size expression and attribute locations (or keyword if we
2007// ever fully support altivec syntax).
2011
2012class VectorTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, VectorTypeLoc,
2013 VectorType, VectorTypeLocInfo> {
2014public:
2015 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
2016
2017 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
2018
2022
2024 setNameLoc(Loc);
2025 }
2026
2028
2029 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2030};
2031
2032// FIXME: size expression and attribute locations (or keyword if we
2033// ever fully support altivec syntax).
2035 : public ConcreteTypeLoc<UnqualTypeLoc, DependentVectorTypeLoc,
2036 DependentVectorType, VectorTypeLocInfo> {
2037public:
2038 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
2039
2040 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
2041
2045
2047 setNameLoc(Loc);
2048 }
2049
2051
2052 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2053};
2054
2055// FIXME: size expression and attribute locations.
2057 : public InheritingConcreteTypeLoc<VectorTypeLoc, ExtVectorTypeLoc,
2058 ExtVectorType> {};
2059
2060// FIXME: attribute locations.
2061// For some reason, this isn't a subtype of VectorType.
2063 : public ConcreteTypeLoc<UnqualTypeLoc, DependentSizedExtVectorTypeLoc,
2064 DependentSizedExtVectorType, VectorTypeLocInfo> {
2065public:
2066 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
2067
2068 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
2069
2073
2075 setNameLoc(Loc);
2076 }
2077
2079
2080 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2081};
2082
2089
2090class MatrixTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, MatrixTypeLoc,
2091 MatrixType, MatrixTypeLocInfo> {
2092public:
2093 /// The location of the attribute name, i.e.
2094 /// float __attribute__((matrix_type(4, 2)))
2095 /// ^~~~~~~~~~~~~~~~~
2098
2099 /// The attribute's row operand, if it has one.
2100 /// float __attribute__((matrix_type(4, 2)))
2101 /// ^
2104
2105 /// The attribute's column operand, if it has one.
2106 /// float __attribute__((matrix_type(4, 2)))
2107 /// ^
2110
2111 /// The location of the parentheses around the operand, if there is
2112 /// an operand.
2113 /// float __attribute__((matrix_type(4, 2)))
2114 /// ^ ^
2121
2123 SourceRange range(getAttrNameLoc());
2124 range.setEnd(getAttrOperandParensRange().getEnd());
2125 return range;
2126 }
2127
2129 setAttrNameLoc(loc);
2131 setAttrRowOperand(nullptr);
2132 setAttrColumnOperand(nullptr);
2133 }
2134};
2135
2137 : public InheritingConcreteTypeLoc<MatrixTypeLoc, ConstantMatrixTypeLoc,
2138 ConstantMatrixType> {};
2139
2141 : public InheritingConcreteTypeLoc<MatrixTypeLoc,
2142 DependentSizedMatrixTypeLoc,
2143 DependentSizedMatrixType> {};
2144
2145// FIXME: location of the '_Complex' keyword.
2146class ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
2147 ComplexTypeLoc,
2148 ComplexType> {
2149};
2150
2156
2158};
2159
2163
2164template <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
2166 : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
2167public:
2169 return this->getLocalData()->TypeofLoc;
2170 }
2171
2173 this->getLocalData()->TypeofLoc = Loc;
2174 }
2175
2177 return this->getLocalData()->LParenLoc;
2178 }
2179
2181 this->getLocalData()->LParenLoc = Loc;
2182 }
2183
2185 return this->getLocalData()->RParenLoc;
2186 }
2187
2189 this->getLocalData()->RParenLoc = Loc;
2190 }
2191
2195
2197 setLParenLoc(range.getBegin());
2198 setRParenLoc(range.getEnd());
2199 }
2200
2204
2206 setTypeofLoc(Loc);
2207 setLParenLoc(Loc);
2208 setRParenLoc(Loc);
2209 }
2210};
2211
2212class TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
2213 TypeOfExprType,
2214 TypeOfExprTypeLocInfo> {
2215public:
2217 return getTypePtr()->getUnderlyingExpr();
2218 }
2219
2220 // Reimplemented to account for GNU/C++ extension
2221 // typeof unary-expression
2222 // where there are no parentheses.
2224};
2225
2227 : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
2228public:
2230 return this->getTypePtr()->getUnmodifiedType();
2231 }
2232
2234 return this->getLocalData()->UnmodifiedTInfo;
2235 }
2236
2238 this->getLocalData()->UnmodifiedTInfo = TI;
2239 }
2240
2241 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2242};
2243
2244// decltype(expression) abc;
2245// ~~~~~~~~ DecltypeLoc
2246// ~ RParenLoc
2247// FIXME: add LParenLoc, it is tricky to support due to the limitation of
2248// annotated-decltype token.
2254 : public ConcreteTypeLoc<UnqualTypeLoc, DecltypeTypeLoc, DecltypeType,
2255 DecltypeTypeLocInfo> {
2256public:
2257 Expr *getUnderlyingExpr() const { return getTypePtr()->getUnderlyingExpr(); }
2258
2261
2264
2268
2270 setDecltypeLoc(Loc);
2271 setRParenLoc(Loc);
2272 }
2273};
2274
2278
2280 : public ConcreteTypeLoc<UnqualTypeLoc, PackIndexingTypeLoc,
2281 PackIndexingType, PackIndexingTypeLocInfo> {
2282
2283public:
2284 Expr *getIndexExpr() const { return getTypePtr()->getIndexExpr(); }
2285 QualType getPattern() const { return getTypePtr()->getPattern(); }
2286
2289
2291 setEllipsisLoc(Loc);
2292 }
2293
2295
2296 QualType getInnerType() const { return this->getTypePtr()->getPattern(); }
2297
2301};
2302
2304 // FIXME: While there's only one unary transform right now, future ones may
2305 // need different representations
2308};
2309
2310class UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2311 UnaryTransformTypeLoc,
2312 UnaryTransformType,
2313 UnaryTransformTypeLocInfo> {
2314public:
2317
2320
2323
2327
2329 getLocalData()->UnderlyingTInfo = TInfo;
2330 }
2331
2335
2339
2341 setLParenLoc(Range.getBegin());
2342 setRParenLoc(Range.getEnd());
2343 }
2344
2345 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2346};
2347
2349 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DeducedTypeLoc,
2350 DeducedType> {};
2351
2353 // For decltype(auto).
2355
2357};
2358
2360 : public ConcreteTypeLoc<DeducedTypeLoc,
2361 AutoTypeLoc,
2362 AutoType,
2363 AutoTypeLocInfo> {
2364public:
2366 return getTypePtr()->getKeyword();
2367 }
2368
2369 bool isDecltypeAuto() const { return getTypePtr()->isDecltypeAuto(); }
2372
2373 bool isConstrained() const {
2374 return getTypePtr()->isConstrained();
2375 }
2376
2378
2380
2381 // FIXME: Several of the following functions can be removed. Instead the
2382 // caller can directly work with the ConceptReference.
2384 if (const auto *CR = getConceptReference())
2385 return CR->getNestedNameSpecifierLoc();
2386 return NestedNameSpecifierLoc();
2387 }
2388
2390 if (const auto *CR = getConceptReference())
2391 return CR->getTemplateKWLoc();
2392 return SourceLocation();
2393 }
2394
2396 if (const auto *CR = getConceptReference())
2397 return CR->getConceptNameLoc();
2398 return SourceLocation();
2399 }
2400
2402 if (const auto *CR = getConceptReference())
2403 return CR->getFoundDecl();
2404 return nullptr;
2405 }
2406
2408 if (const auto *CR = getConceptReference())
2409 return CR->getNamedConcept();
2410 return nullptr;
2411 }
2412
2416
2418 return (getConceptReference() &&
2419 getConceptReference()->getTemplateArgsAsWritten() &&
2421 ->getTemplateArgsAsWritten()
2422 ->getLAngleLoc()
2423 .isValid());
2424 }
2425
2427 if (const auto *CR = getConceptReference())
2428 if (const auto *TAAW = CR->getTemplateArgsAsWritten())
2429 return TAAW->getLAngleLoc();
2430 return SourceLocation();
2431 }
2432
2434 if (const auto *CR = getConceptReference())
2435 if (const auto *TAAW = CR->getTemplateArgsAsWritten())
2436 return TAAW->getRAngleLoc();
2437 return SourceLocation();
2438 }
2439
2440 unsigned getNumArgs() const {
2441 return getTypePtr()->getTypeConstraintArguments().size();
2442 }
2443
2444 TemplateArgumentLoc getArgLoc(unsigned i) const {
2445 const auto *CR = getConceptReference();
2446 assert(CR && "No ConceptReference");
2447 return CR->getTemplateArgsAsWritten()->getTemplateArgs()[i];
2448 }
2449
2459
2460 void copy(AutoTypeLoc Loc) {
2461 unsigned size = getFullDataSize();
2462 assert(size == Loc.getFullDataSize());
2463 memcpy(Data, Loc.Data, size);
2464 }
2465
2466 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2467};
2468
2471 /// Data associated with the nested-name-specifier location.
2473};
2474
2476 : public ConcreteTypeLoc<DeducedTypeLoc,
2477 DeducedTemplateSpecializationTypeLoc,
2478 DeducedTemplateSpecializationType,
2479 DeducedTemplateSpecializationLocInfo> {
2480public:
2484
2488
2490
2492
2494 void *Data = getLocalData()->QualifierData;
2495 if (!Data)
2496 return NestedNameSpecifierLoc();
2497 NestedNameSpecifier Qualifier =
2498 getTypePtr()->getTemplateName().getQualifier();
2499 assert(Qualifier && "missing qualification");
2500 return NestedNameSpecifierLoc(Qualifier, Data);
2501 }
2502
2504 if (!QualifierLoc) {
2505 // Even if we have a nested-name-specifier in the dependent
2506 // template specialization type, we won't record the nested-name-specifier
2507 // location information when this type-source location information is
2508 // part of a nested-name-specifier.
2509 getLocalData()->QualifierData = nullptr;
2510 return;
2511 }
2512
2513 assert(QualifierLoc.getNestedNameSpecifier() ==
2514 getTypePtr()->getTemplateName().getQualifier() &&
2515 "Inconsistent nested-name-specifier pointer");
2516 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2517 }
2518
2521 if (BeginLoc.isInvalid())
2522 BeginLoc = getQualifierLoc().getBeginLoc();
2523 if (BeginLoc.isInvalid())
2524 BeginLoc = getNameLoc();
2525 return {BeginLoc, getNameLoc()};
2526 }
2527
2528 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2529};
2530
2533
2534 /// Data associated with the nested-name-specifier location.
2536};
2537
2538// This is exactly the structure of an ElaboratedTypeLoc whose inner
2539// type is some sort of TypeDeclTypeLoc.
2543
2544class DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2545 DependentNameTypeLoc,
2546 DependentNameType,
2547 DependentNameLocInfo> {
2548public:
2552
2556
2558 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2559 getLocalData()->QualifierData);
2560 }
2561
2563 assert(QualifierLoc.getNestedNameSpecifier()
2564 == getTypePtr()->getQualifier() &&
2565 "Inconsistent nested-name-specifier pointer");
2566 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2567 }
2568
2570 return this->getLocalData()->NameLoc;
2571 }
2572
2574 this->getLocalData()->NameLoc = Loc;
2575 }
2576
2578 if (getElaboratedKeywordLoc().isValid())
2580 else
2582 }
2583
2585 unsigned size = getFullDataSize();
2586 assert(size == Loc.getFullDataSize());
2587 memcpy(Data, Loc.Data, size);
2588 }
2589
2590 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2591};
2592
2596
2598 : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
2599 PackExpansionType, PackExpansionTypeLocInfo> {
2600public:
2602 return this->getLocalData()->EllipsisLoc;
2603 }
2604
2606 this->getLocalData()->EllipsisLoc = Loc;
2607 }
2608
2612
2614 setEllipsisLoc(Loc);
2615 }
2616
2618 return getInnerTypeLoc();
2619 }
2620
2622 return this->getTypePtr()->getPattern();
2623 }
2624};
2625
2629
2630class AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc,
2631 AtomicType, AtomicTypeLocInfo> {
2632public:
2634 return this->getInnerTypeLoc();
2635 }
2636
2640
2642 return this->getLocalData()->KWLoc;
2643 }
2644
2646 this->getLocalData()->KWLoc = Loc;
2647 }
2648
2650 return this->getLocalData()->LParenLoc;
2651 }
2652
2654 this->getLocalData()->LParenLoc = Loc;
2655 }
2656
2658 return this->getLocalData()->RParenLoc;
2659 }
2660
2662 this->getLocalData()->RParenLoc = Loc;
2663 }
2664
2668
2670 setLParenLoc(Range.getBegin());
2671 setRParenLoc(Range.getEnd());
2672 }
2673
2675 setKWLoc(Loc);
2676 setLParenLoc(Loc);
2677 setRParenLoc(Loc);
2678 }
2679
2681 return this->getTypePtr()->getValueType();
2682 }
2683};
2684
2688
2689class PipeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, PipeTypeLoc, PipeType,
2690 PipeTypeLocInfo> {
2691public:
2692 TypeLoc getValueLoc() const { return this->getInnerTypeLoc(); }
2693
2695
2696 SourceLocation getKWLoc() const { return this->getLocalData()->KWLoc; }
2697 void setKWLoc(SourceLocation Loc) { this->getLocalData()->KWLoc = Loc; }
2698
2700 setKWLoc(Loc);
2701 }
2702
2703 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2704};
2705
2706template <typename T>
2708 TypeLoc Cur = *this;
2709 while (!T::isKind(Cur)) {
2710 if (auto PTL = Cur.getAs<ParenTypeLoc>())
2711 Cur = PTL.getInnerLoc();
2712 else if (auto ATL = Cur.getAs<AttributedTypeLoc>())
2713 Cur = ATL.getModifiedLoc();
2714 else if (auto ATL = Cur.getAs<BTFTagAttributedTypeLoc>())
2715 Cur = ATL.getWrappedLoc();
2716 else if (auto ATL = Cur.getAs<HLSLAttributedResourceTypeLoc>())
2717 Cur = ATL.getWrappedLoc();
2718 else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())
2719 Cur = ATL.getOriginalLoc();
2720 else if (auto MQL = Cur.getAs<MacroQualifiedTypeLoc>())
2721 Cur = MQL.getInnerLoc();
2722 else
2723 break;
2724 }
2725 return Cur.getAs<T>();
2726}
2727class BitIntTypeLoc final
2728 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, BitIntTypeLoc,
2729 BitIntType> {};
2731 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentBitIntTypeLoc,
2732 DependentBitIntType> {};
2733
2735 ObjCProtocolDecl *Protocol = nullptr;
2737
2738public:
2740 : Protocol(protocol), Loc(loc) {}
2741 ObjCProtocolDecl *getProtocol() const { return Protocol; }
2742 SourceLocation getLocation() const { return Loc; }
2743
2744 /// The source range is just the protocol name.
2745 SourceRange getSourceRange() const LLVM_READONLY {
2746 return SourceRange(Loc, Loc);
2747 }
2748};
2749
2750struct PredefinedSugarTypeLocInfo {}; // Nothing.
2751
2753 : public ConcreteTypeLoc<UnqualTypeLoc, PredefinedSugarTypeLoc,
2754 PredefinedSugarType, PredefinedSugarTypeLocInfo> {
2755public:
2757 SourceRange getLocalSourceRange() const { return {}; }
2758};
2759
2760} // namespace clang
2761
2762#endif // LLVM_CLANG_AST_TYPELOC_H
This file provides AST data structures related to concepts.
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.
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:220
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:220
QualType getInnerType() const
Definition TypeLoc.h:1428
unsigned getLocalDataSize() const
Definition TypeLoc.h:1436
TypeLoc getOriginalLoc() const
Definition TypeLoc.h:1420
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1424
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1434
QualType getOriginalType() const
Definition TypeBase.h:3505
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1805
Wrapper for source info for arrays.
Definition TypeLoc.h:1749
SourceLocation getLBracketLoc() const
Definition TypeLoc.h:1751
Expr * getSizeExpr() const
Definition TypeLoc.h:1771
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1755
TypeLoc getElementLoc() const
Definition TypeLoc.h:1779
void setRBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1763
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1787
SourceLocation getRBracketLoc() const
Definition TypeLoc.h:1759
SourceRange getBracketsRange() const
Definition TypeLoc.h:1767
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1783
QualType getInnerType() const
Definition TypeLoc.h:1793
void setSizeExpr(Expr *Size)
Definition TypeLoc.h:1775
QualType getElementType() const
Definition TypeBase.h:3735
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2657
QualType getInnerType() const
Definition TypeLoc.h:2680
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2637
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2661
SourceRange getParensRange() const
Definition TypeLoc.h:2665
TypeLoc getValueLoc() const
Definition TypeLoc.h:2633
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2653
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2645
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2674
SourceLocation getKWLoc() const
Definition TypeLoc.h:2641
SourceLocation getLParenLoc() const
Definition TypeLoc.h:2649
void setParensRange(SourceRange Range)
Definition TypeLoc.h:2669
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition TypeBase.h:8101
Attr - This represents one attribute.
Definition Attr.h:46
Type source information for an attributed type.
Definition TypeLoc.h:1008
const Attr * getAttr() const
The type attribute.
Definition TypeLoc.h:1031
QualType getInnerType() const
Definition TypeLoc.h:1048
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition TypeLoc.h:1022
TypeLoc getEquivalentTypeLoc() const
Definition TypeLoc.h:1026
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1044
SourceRange getLocalSourceRange() const
Definition TypeLoc.cpp:580
void setAttr(const Attr *A)
Definition TypeLoc.h:1034
attr::Kind getAttrKind() const
Definition TypeLoc.h:1010
bool isQualifier() const
Definition TypeLoc.h:1014
bool hasExplicitTemplateArgs() const
Definition TypeLoc.h:2417
SourceLocation getTemplateKWLoc() const
Definition TypeLoc.h:2389
AutoTypeKeyword getAutoKeyword() const
Definition TypeLoc.h:2365
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
Definition TypeLoc.h:2383
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:2433
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2370
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:788
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2450
void copy(AutoTypeLoc Loc)
Definition TypeLoc.h:2460
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:2426
void setConceptReference(ConceptReference *CR)
Definition TypeLoc.h:2377
SourceLocation getConceptNameLoc() const
Definition TypeLoc.h:2395
NamedDecl * getFoundDecl() const
Definition TypeLoc.h:2401
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition TypeLoc.h:2444
bool isDecltypeAuto() const
Definition TypeLoc.h:2369
bool isConstrained() const
Definition TypeLoc.h:2373
unsigned getNumArgs() const
Definition TypeLoc.h:2440
TemplateDecl * getNamedConcept() const
Definition TypeLoc.h:2407
ConceptReference * getConceptReference() const
Definition TypeLoc.h:2379
DeclarationNameInfo getConceptNameInfo() const
Definition TypeLoc.h:2413
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2371
Type source information for an btf_tag attributed type.
Definition TypeLoc.h:1058
QualType getInnerType() const
Definition TypeLoc.h:1073
TypeLoc getWrappedLoc() const
Definition TypeLoc.h:1060
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1071
const BTFTypeTagAttr * getAttr() const
The btf_type_tag attribute.
Definition TypeLoc.h:1063
SourceRange getLocalSourceRange() const
Definition TypeLoc.cpp:597
Wrapper for source info for block pointers.
Definition TypeLoc.h:1498
SourceLocation getCaretLoc() const
Definition TypeLoc.h:1500
void setCaretLoc(SourceLocation Loc)
Definition TypeLoc.h:1504
QualType getInnerType() const
Definition TypeLoc.h:1313
unsigned getLocalDataSize() const
Definition TypeLoc.h:1318
TypeLoc getInnerLoc() const
Definition TypeLoc.h:1312
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1314
QualType desugar() const
Definition TypeBase.h:3399
Wrapper for source info for builtin types.
Definition TypeLoc.h:577
SourceLocation getBuiltinLoc() const
Definition TypeLoc.h:579
TypeSpecifierType getWrittenTypeSpec() const
Definition TypeLoc.cpp:321
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:680
TypeSpecifierWidth getWrittenWidthSpec() const
Definition TypeLoc.h:641
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:621
void setWrittenTypeSpec(TypeSpecifierType written)
Definition TypeLoc.h:663
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
Definition TypeLoc.h:602
bool needsExtraLocalData() const
Definition TypeLoc.h:606
bool hasWrittenWidthSpec() const
Definition TypeLoc.h:648
void setModeAttr(bool written)
Definition TypeLoc.h:675
void setBuiltinLoc(SourceLocation Loc)
Definition TypeLoc.h:583
void setWrittenWidthSpec(TypeSpecifierWidth written)
Definition TypeLoc.h:652
SourceLocation getNameLoc() const
Definition TypeLoc.h:597
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:617
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition TypeLoc.h:599
void setWrittenSignSpec(TypeSpecifierSign written)
Definition TypeLoc.h:636
bool hasWrittenSignSpec() const
Definition TypeLoc.h:632
bool hasModeAttr() const
Definition TypeLoc.h:668
unsigned getExtraLocalDataSize() const
Definition TypeLoc.h:613
bool hasWrittenTypeSpec() const
Definition TypeLoc.h:659
TypeSpecifierSign getWrittenSignSpec() const
Definition TypeLoc.h:625
void expandBuiltinRange(SourceRange Range)
Definition TypeLoc.h:587
Kind getKind() const
Definition TypeBase.h:3213
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Declaration of a C++20 concept.
A reference to a concept and its template args, as it appears in the code.
Definition ASTConcept.h:130
const DeclarationNameInfo & getConceptNameInfo() const
Definition ASTConcept.h:174
A metaprogramming base class for TypeLoc classes which correspond to a particular Type subclass.
Definition TypeLoc.h:384
const TypeClass * getTypePtr() const
Definition TypeLoc.h:433
friend class TypeLoc
Definition TypeLoc.h:385
TypeLoc getInnerTypeLoc() const
Definition TypeLoc.h:470
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:442
HasNoInnerType getInnerType() const
Definition TypeLoc.h:468
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:453
LocalData * getLocalData() const
Definition TypeLoc.h:446
unsigned getLocalDataAlignment() const
Definition TypeLoc.h:401
void * getNonLocalData() const
Definition TypeLoc.h:460
TypeLoc getNextTypeLoc() const
Definition TypeLoc.h:429
unsigned getExtraLocalDataSize() const
Definition TypeLoc.h:438
void copyLocal(Derived other)
Definition TypeLoc.h:415
unsigned getLocalDataSize() const
Definition TypeLoc.h:406
Expr * getCountExpr() const
Definition TypeLoc.h:1326
SourceRange getLocalSourceRange() const
Definition TypeLoc.cpp:593
bool isCountInBytes() const
Definition TypeBase.h:3464
Expr * getCountExpr() const
Definition TypeBase.h:3463
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1446
SourceLocation getDecltypeLoc() const
Definition TypeLoc.h:2259
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2269
Expr * getUnderlyingExpr() const
Definition TypeLoc.h:2257
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2262
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2263
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2260
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2265
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:2503
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2485
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:798
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:2481
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:2489
void setTemplateNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2491
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:2493
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:1949
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1974
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1970
QualType getInnerType() const
Returns the type before the address space attribute application area.
Definition TypeLoc.h:1984
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
Definition TypeLoc.h:1956
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1992
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition TypeLoc.h:1967
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition TypeLoc.h:1946
QualType getPointeeType() const
Definition TypeBase.h:4074
void copy(DependentNameTypeLoc Loc)
Definition TypeLoc.h:2584
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:2557
SourceLocation getNameLoc() const
Definition TypeLoc.h:2569
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:636
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2577
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:2549
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2573
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2553
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:2562
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1818
SourceLocation getNameLoc() const
Definition TypeLoc.h:2066
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2070
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2068
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2074
SourceLocation getNameLoc() const
Definition TypeLoc.h:2038
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2042
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2046
TypeLoc getElementLoc() const
Definition TypeLoc.h:2050
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2040
QualType getInnerType() const
Definition TypeLoc.h:2052
QualType getElementType() const
Definition TypeBase.h:4240
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:763
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:744
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:752
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:768
SourceLocation getNameLoc() const
Definition TypeLoc.h:761
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:756
Represents an enum.
Definition Decl.h:4010
Wrapper for source info for enum types.
Definition TypeLoc.h:863
EnumDecl * getDecl() const
Definition TypeLoc.h:865
This represents one expression.
Definition Expr.h:112
Wrapper for source info for functions.
Definition TypeLoc.h:1616
ParmVarDecl ** getParmArray() const
Definition TypeLoc.h:1684
QualType getInnerType() const
Definition TypeLoc.h:1725
unsigned getNumParams() const
Definition TypeLoc.h:1688
ParmVarDecl * getParam(unsigned i) const
Definition TypeLoc.h:1694
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1640
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1636
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1652
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1668
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1695
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1679
SourceRange getParensRange() const
Definition TypeLoc.h:1664
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1660
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:1723
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1644
unsigned getExtraLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition TypeLoc.h:1718
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1674
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1697
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1632
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1701
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1648
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1656
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1705
QualType getReturnType() const
Definition TypeBase.h:4805
Type source information for HLSL attributed resource type.
Definition TypeLoc.h:1085
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1098
TypeSourceInfo * getContainedTypeSourceInfo() const
Definition TypeLoc.h:1089
void setContainedTypeSourceInfo(TypeSourceInfo *TSI) const
Definition TypeLoc.h:1092
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1097
void setSourceRange(const SourceRange &R)
Definition TypeLoc.h:1096
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1119
void setSpirvTypeLoc(SourceLocation loc) const
Definition TypeLoc.h:1117
SourceLocation getSpirvTypeLoc() const
Definition TypeLoc.h:1116
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1122
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:510
const TypeClass * getTypePtr() const
Definition TypeLoc.h:526
Wrapper for source info for injected class names of class templates.
Definition TypeLoc.h:872
CXXRecordDecl * getDecl() const
Definition TypeLoc.h:874
void setAmpLoc(SourceLocation Loc)
Definition TypeLoc.h:1586
SourceLocation getAmpLoc() const
Definition TypeLoc.h:1582
const IdentifierInfo * getMacroIdentifier() const
Definition TypeLoc.h:1347
SourceLocation getExpansionLoc() const
Definition TypeLoc.h:1351
TypeLoc getInnerLoc() const
Definition TypeLoc.h:1345
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1341
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1355
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1361
QualType getInnerType() const
Definition TypeLoc.h:1359
QualType getUnderlyingType() const
Definition TypeBase.h:6164
const IdentifierInfo * getMacroIdentifier() const
Definition TypeBase.h:6163
Expr * getAttrColumnOperand() const
The attribute's column operand, if it has one.
Definition TypeLoc.h:2108
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition TypeLoc.h:2115
void setAttrRowOperand(Expr *e)
Definition TypeLoc.h:2103
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2122
void setAttrColumnOperand(Expr *e)
Definition TypeLoc.h:2109
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:2118
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2097
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition TypeLoc.h:2096
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:2128
Expr * getAttrRowOperand() const
The attribute's row operand, if it has one.
Definition TypeLoc.h:2102
Wrapper for source info for member pointers.
Definition TypeLoc.h:1516
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1538
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1522
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1526
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1548
SourceLocation getStarLoc() const
Definition TypeLoc.h:1518
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:1531
This represents a decl that may have a name.
Definition Decl.h:274
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
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.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Represents an ObjC class declaration.
Definition DeclObjC.h:1154
Wrapper for source info for ObjC interfaces.
Definition TypeLoc.h:1275
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:1285
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1289
void setNameEndLoc(SourceLocation Loc)
Definition TypeLoc.h:1297
ObjCInterfaceDecl * getIFaceDecl() const
Definition TypeLoc.h:1277
SourceLocation getNameEndLoc() const
Definition TypeLoc.h:1293
SourceLocation getNameLoc() const
Definition TypeLoc.h:1281
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1301
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition Type.cpp:952
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1558
SourceLocation getStarLoc() const
Definition TypeLoc.h:1560
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1564
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:1255
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:1168
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition TypeLoc.h:1216
unsigned getExtraLocalDataSize() const
Definition TypeLoc.h:1250
bool hasBaseTypeAsWritten() const
Definition TypeLoc.h:1226
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:564
SourceLocation getTypeArgsLAngleLoc() const
Definition TypeLoc.h:1156
unsigned getNumTypeArgs() const
Definition TypeLoc.h:1172
ArrayRef< SourceLocation > getProtocolLocs() const
Definition TypeLoc.h:1222
unsigned getNumProtocols() const
Definition TypeLoc.h:1202
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:1160
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1238
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition TypeLoc.h:1176
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition TypeLoc.h:1181
void setProtocolLAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:1190
void setProtocolRAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:1198
SourceLocation getProtocolRAngleLoc() const
Definition TypeLoc.h:1194
SourceLocation getProtocolLoc(unsigned i) const
Definition TypeLoc.h:1206
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1230
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition TypeLoc.h:1211
TypeLoc getBaseLoc() const
Definition TypeLoc.h:1234
QualType getInnerType() const
Definition TypeLoc.h:1261
SourceLocation getProtocolLAngleLoc() const
Definition TypeLoc.h:1186
SourceLocation getTypeArgsRAngleLoc() const
Definition TypeLoc.h:1164
Represents an Objective-C protocol declaration.
Definition DeclObjC.h:2084
SourceLocation getLocation() const
Definition TypeLoc.h:2742
ObjCProtocolLoc(ObjCProtocolDecl *protocol, SourceLocation loc)
Definition TypeLoc.h:2739
ObjCProtocolDecl * getProtocol() const
Definition TypeLoc.h:2741
SourceRange getSourceRange() const LLVM_READONLY
The source range is just the protocol name.
Definition TypeLoc.h:2745
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition TypeLoc.h:895
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:964
ObjCTypeParamDecl * getDecl() const
Definition TypeLoc.h:902
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:968
unsigned getNumProtocols() const
Definition TypeLoc.h:932
SourceLocation getNameLoc() const
Definition TypeLoc.h:904
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition TypeLoc.h:946
SourceLocation getProtocolLoc(unsigned i) const
Definition TypeLoc.h:936
ArrayRef< SourceLocation > getProtocolLocs() const
Definition TypeLoc.h:951
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition TypeLoc.h:941
void setProtocolLAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:918
unsigned getExtraLocalDataSize() const
Definition TypeLoc.h:957
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:553
SourceLocation getProtocolLAngleLoc() const
Definition TypeLoc.h:912
void setProtocolRAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:928
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:908
SourceLocation getProtocolRAngleLoc() const
Definition TypeLoc.h:922
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2609
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2605
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2601
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2617
QualType getInnerType() const
Definition TypeLoc.h:2621
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2613
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2287
Expr * getIndexExpr() const
Definition TypeLoc.h:2284
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2294
QualType getPattern() const
Definition TypeLoc.h:2285
QualType getInnerType() const
Definition TypeLoc.h:2296
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2298
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2288
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2290
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1387
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1395
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1379
QualType getInnerType() const
Definition TypeLoc.h:1404
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1375
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1391
TypeLoc getInnerLoc() const
Definition TypeLoc.h:1400
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1383
QualType getInnerType() const
Definition TypeBase.h:3312
Represents a parameter to a function.
Definition Decl.h:1790
TypeLoc getValueLoc() const
Definition TypeLoc.h:2692
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2699
QualType getInnerType() const
Definition TypeLoc.h:2703
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2697
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2694
SourceLocation getKWLoc() const
Definition TypeLoc.h:2696
QualType getElementType() const
Definition TypeBase.h:8131
A base class for.
Definition TypeLoc.h:1456
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1474
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1470
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1462
QualType getInnerType() const
Definition TypeLoc.h:1478
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1466
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1458
Wrapper for source info for pointers.
Definition TypeLoc.h:1485
SourceLocation getStarLoc() const
Definition TypeLoc.h:1487
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1491
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:2756
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2757
A (possibly-)qualified type.
Definition TypeBase.h:937
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition TypeBase.h:1064
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition TypeBase.h:8302
static QualType getFromOpaquePtr(const void *Ptr)
Definition TypeBase.h:986
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition TypeLoc.h:300
TypeLoc getNextTypeLoc() const
Definition TypeLoc.h:322
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Initializes the local data of this type source info block to provide no information.
Definition TypeLoc.h:314
unsigned getLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition TypeLoc.h:328
friend class TypeLoc
Definition TypeLoc.h:342
unsigned getLocalDataAlignment() const
Returns the alignment of the type source info data block that is specific to this type.
Definition TypeLoc.h:336
void copyLocal(TypeLoc other)
Definition TypeLoc.h:318
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:302
UnqualTypeLoc getUnqualifiedLoc() const
Definition TypeLoc.h:304
void setAmpAmpLoc(SourceLocation Loc)
Definition TypeLoc.h:1600
SourceLocation getAmpAmpLoc() const
Definition TypeLoc.h:1596
Represents a struct/union/class.
Definition Decl.h:4324
Wrapper for source info for record types.
Definition TypeLoc.h:855
RecordDecl * getDecl() const
Definition TypeLoc.h:857
QualType getInnerType() const
Definition TypeLoc.h:1572
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3590
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:998
Abstract type representing delayed type pack expansions.
Definition TypeLoc.h:986
Wrapper for substituted template type parameters.
Definition TypeLoc.h:992
Wrapper for substituted template type parameters.
Definition TypeLoc.h:980
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3717
TagDecl * getDecl() const
Definition TypeLoc.h:796
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:826
SourceLocation getNameLoc() const
Definition TypeLoc.h:822
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:801
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:809
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:836
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:816
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:824
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:805
bool isDefinition() const
True if the tag was defined in this type specifier.
Definition TypeLoc.cpp:305
A convenient class for passing around template argument information.
Location wrapper for a TemplateArgument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
static void initializeArgLocs(ASTContext &Context, ArrayRef< TemplateArgument > Args, TemplateArgumentLocInfo *ArgInfos, SourceLocation Loc)
Definition TypeLoc.cpp:714
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:1879
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition TypeLoc.h:1889
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1908
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1894
MutableArrayRef< TemplateArgumentLocInfo > getArgLocInfos()
Definition TypeLoc.h:1885
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, SourceLocation NameLoc, SourceLocation LAngleLoc, SourceLocation RAngleLoc)
Definition TypeLoc.cpp:644
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1877
void copy(TemplateSpecializationTypeLoc Loc)
Definition TypeLoc.h:1897
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:1921
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1873
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1863
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:688
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1859
unsigned getExtraLocalDataSize() const
Definition TypeLoc.h:1917
Declaration of a template type parameter.
Wrapper for template type parameters.
Definition TypeLoc.h:881
TemplateTypeParmDecl * getDecl() const
Definition TypeLoc.h:883
Base wrapper for a particular "section" of type source info.
Definition TypeLoc.h:59
SourceLocation findNullabilityLoc() const
Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier),...
Definition TypeLoc.cpp:441
TypeLoc()=default
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition TypeLoc.h:349
static unsigned getLocalAlignmentForType(QualType Ty)
Returns the alignment of type source info data block for the given type.
Definition TypeLoc.cpp:75
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
Definition TypeLoc.cpp:452
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition TypeLoc.h:133
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:171
void dump() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:89
NestedNameSpecifierLoc getPrefix() const
If this type represents a qualified-id, this returns it's nested name specifier.
Definition TypeLoc.cpp:473
friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS)
Definition TypeLoc.h:234
TypeLoc IgnoreParens() const
Definition TypeLoc.h:1409
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition TypeLoc.h:78
TypeLoc(QualType ty, void *opaqueData)
Definition TypeLoc.h:68
void * Data
Definition TypeLoc.h:64
SourceLocation getNonElaboratedBeginLoc() const
This returns the position of the type after any elaboration, such as the 'struct' keyword.
Definition TypeLoc.cpp:496
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
Definition TypeLoc.h:217
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition TypeLoc.h:154
SourceRange getLocalSourceRange() const
Get the local source range.
Definition TypeLoc.h:160
void initializeFullCopy(TypeLoc Other, unsigned Size)
Initializes this by copying its information from another TypeLoc of the same type.
Definition TypeLoc.h:225
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition TypeLoc.h:165
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:879
TypeLoc(const Type *ty, void *opaqueData)
Definition TypeLoc.h:70
void * getOpaqueData() const
Get the pointer where source information is stored.
Definition TypeLoc.h:143
TypeLocClass
The kinds of TypeLocs.
Definition TypeLoc.h:108
const void * Ty
Definition TypeLoc.h:63
SourceLocation getTemplateKeywordLoc() const
Get the SourceLocation of the template keyword (if any).
Definition TypeLoc.cpp:886
void copy(TypeLoc other)
Copies the other type loc into this one.
Definition TypeLoc.cpp:169
TypeLocClass getTypeLocClass() const
Definition TypeLoc.h:116
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
Definition TypeLoc.cpp:95
void initialize(ASTContext &Context, SourceLocation Loc) const
Initializes this to state that every location in this type is the given location.
Definition TypeLoc.h:211
bool isNull() const
Definition TypeLoc.h:121
SourceLocation getEndLoc() const
Get the end source location.
Definition TypeLoc.cpp:227
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:2707
friend bool operator!=(const TypeLoc &LHS, const TypeLoc &RHS)
Definition TypeLoc.h:238
SourceLocation getBeginLoc() const
Get the begin source location.
Definition TypeLoc.cpp:193
const Type * getTypePtr() const
Definition TypeLoc.h:137
SourceRange getLocalSourceRange() const
Definition TypeLoc.cpp:312
Expr * getUnderlyingExpr() const
Definition TypeLoc.h:2216
Expr * getUnderlyingExpr() const
Definition TypeBase.h:6191
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:601
void setUnmodifiedTInfo(TypeSourceInfo *TI) const
Definition TypeLoc.h:2237
TypeSourceInfo * getUnmodifiedTInfo() const
Definition TypeLoc.h:2233
QualType getUnmodifiedType() const
Definition TypeLoc.h:2229
A container of type source information.
Definition TypeBase.h:8273
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition TypeLoc.h:267
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
Definition TypeLoc.h:540
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:559
friend class TypeLoc
Definition TypeLoc.h:564
SourceLocation getNameLoc() const
Definition TypeLoc.h:547
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:551
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:555
The base class of the type hierarchy.
Definition TypeBase.h:1833
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition Type.cpp:753
TypeClass getTypeClass() const
Definition TypeBase.h:2385
Wrapper for source info for typedefs.
Definition TypeLoc.h:777
void setParensRange(SourceRange range)
Definition TypeLoc.h:2196
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2201
SourceLocation getLParenLoc() const
Definition TypeLoc.h:2176
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2184
SourceRange getParensRange() const
Definition TypeLoc.h:2192
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2180
SourceLocation getTypeofLoc() const
Definition TypeLoc.h:2168
void setTypeofLoc(SourceLocation Loc)
Definition TypeLoc.h:2172
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2188
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2205
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2322
void setParensRange(SourceRange Range)
Definition TypeLoc.h:2340
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:609
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2332
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2316
SourceLocation getKWLoc() const
Definition TypeLoc.h:2315
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2321
TypeSourceInfo * getUnderlyingTInfo() const
Definition TypeLoc.h:2324
SourceRange getParensRange() const
Definition TypeLoc.h:2336
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition TypeLoc.h:2328
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2319
SourceLocation getLParenLoc() const
Definition TypeLoc.h:2318
Wrapper of type source information for a type with no direct qualifiers.
Definition TypeLoc.h:274
TypeLocClass getTypeLocClass() const
Definition TypeLoc.h:283
UnqualTypeLoc(const Type *Ty, void *Data)
Definition TypeLoc.h:277
friend class TypeLoc
Definition TypeLoc.h:288
const Type * getTypePtr() const
Definition TypeLoc.h:279
Wrapper for source info for unresolved typename using decls.
Definition TypeLoc.h:782
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4033
Wrapper for source info for types used via transparent aliases.
Definition TypeLoc.h:785
TypeLoc getElementLoc() const
Definition TypeLoc.h:2027
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2017
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2023
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2019
QualType getInnerType() const
Definition TypeLoc.h:2029
SourceLocation getNameLoc() const
Definition TypeLoc.h:2015
QualType getElementType() const
Definition TypeBase.h:4190
#define bool
Definition gpuintrin.h:32
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
Definition Specifiers.h:55
@ TST_unspecified
Definition Specifiers.h:56
bool isa(CodeGen::Address addr)
Definition Address.h:330
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition TypeBase.h:1792
const FunctionProtoType * T
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:562
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
U cast(CodeGen::Address addr)
Definition Address.h:327
@ None
The alignment was not explicit in code.
Definition ASTContext.h:178
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5868
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5889
@ Other
Other implicit parameter.
Definition Decl.h:1746
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
SourceLocation LBracketLoc
Definition TypeLoc.h:1741
SourceLocation RBracketLoc
Definition TypeLoc.h:1741
SourceLocation KWLoc
Definition TypeLoc.h:2627
SourceLocation RParenLoc
Definition TypeLoc.h:2627
SourceLocation LParenLoc
Definition TypeLoc.h:2627
const Attr * TypeAttr
Definition TypeLoc.h:1001
ConceptReference * CR
Definition TypeLoc.h:2356
SourceLocation RParenLoc
Definition TypeLoc.h:2354
SourceRange BuiltinRange
Definition TypeLoc.h:570
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation RParenLoc
Definition TypeLoc.h:2251
SourceLocation DecltypeLoc
Definition TypeLoc.h:2250
void * QualifierData
Data associated with the nested-name-specifier location.
Definition TypeLoc.h:2472
SourceLocation ElaboratedKWLoc
Definition TypeLoc.h:2532
void * QualifierData
Data associated with the nested-name-specifier location.
Definition TypeLoc.h:2535
ElaboratedNameLocInfo(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation NameLoc)
Definition TypeLoc.h:697
SourceLocation ElaboratedKeywordLoc
Definition TypeLoc.h:694
SourceRange getLocalSourceRange(NestedNameSpecifier Qualifier) const
Definition TypeLoc.h:714
ElaboratedNameLocInfo(ASTContext &Context, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, SourceLocation Loc)
Definition TypeLoc.h:702
NestedNameSpecifierLoc getQualifierLoc(NestedNameSpecifier Qualifier) const
Definition TypeLoc.h:709
SourceLocation LParenLoc
Definition TypeLoc.h:1607
SourceLocation RParenLoc
Definition TypeLoc.h:1608
SourceLocation LocalRangeEnd
Definition TypeLoc.h:1609
SourceLocation LocalRangeBegin
Definition TypeLoc.h:1606
SourceLocation ExpansionLoc
Definition TypeLoc.h:1334
SourceLocation AttrLoc
Definition TypeLoc.h:2084
SourceRange OperandParens
Definition TypeLoc.h:2085
SourceLocation NameEndLoc
Definition TypeLoc.h:1268
SourceLocation TypeArgsLAngleLoc
Definition TypeLoc.h:1128
SourceLocation ProtocolLAngleLoc
Definition TypeLoc.h:1130
SourceLocation TypeArgsRAngleLoc
Definition TypeLoc.h:1129
SourceLocation ProtocolRAngleLoc
Definition TypeLoc.h:1131
SourceLocation LParenLoc
Definition TypeLoc.h:1367
SourceLocation RParenLoc
Definition TypeLoc.h:1368
SourceLocation KWLoc
Definition TypeLoc.h:2686
SourceLocation StarLoc
Definition TypeLoc.h:1450
SourceLocation NameLoc
Definition TypeLoc.h:788
SourceLocation ElaboratedKWLoc
Definition TypeLoc.h:789
Location information for a TemplateArgument.
SourceLocation NameLoc
Definition TypeLoc.h:1832
TypeSourceInfo * UnmodifiedTInfo
Definition TypeLoc.h:2161
SourceLocation NameLoc
Definition TypeLoc.h:532
SourceLocation RParenLoc
Definition TypeLoc.h:2154
SourceLocation LParenLoc
Definition TypeLoc.h:2153
SourceLocation TypeofLoc
Definition TypeLoc.h:2152
TypeSourceInfo * UnderlyingTInfo
Definition TypeLoc.h:2307
SourceLocation NameLoc
Definition TypeLoc.h:2009
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition Specifiers.h:109