clang 22.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 *getOriginalDecl() const { return getTypePtr()->getOriginalDecl(); }
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:
858 return getTypePtr()->getOriginalDecl();
859 }
860};
861
862/// Wrapper for source info for enum types.
863class EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
864 EnumTypeLoc,
865 EnumType> {
866public:
867 EnumDecl *getOriginalDecl() const { return getTypePtr()->getOriginalDecl(); }
868};
869
870/// Wrapper for source info for injected class names of class
871/// templates.
873 : public InheritingConcreteTypeLoc<TagTypeLoc, InjectedClassNameTypeLoc,
874 InjectedClassNameType> {
875public:
877 return getTypePtr()->getOriginalDecl();
878 }
879};
880
881/// Wrapper for template type parameters.
883 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
884 TemplateTypeParmTypeLoc,
885 TemplateTypeParmType> {
886public:
887 TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); }
888};
889
893
894/// ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for
895/// protocol qualifiers are stored after Info.
896class ObjCTypeParamTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
897 ObjCTypeParamTypeLoc,
898 ObjCTypeParamType,
899 ObjCTypeParamTypeLocInfo> {
900 // SourceLocations are stored after Info, one for each protocol qualifier.
901 SourceLocation *getProtocolLocArray() const {
902 return (SourceLocation*)this->getExtraLocalData() + 2;
903 }
904
905public:
906 ObjCTypeParamDecl *getDecl() const { return getTypePtr()->getDecl(); }
907
909 return this->getLocalData()->NameLoc;
910 }
911
913 this->getLocalData()->NameLoc = Loc;
914 }
915
921
923 *((SourceLocation*)this->getExtraLocalData()) = Loc;
924 }
925
927 return getNumProtocols() ?
928 *((SourceLocation*)this->getExtraLocalData() + 1) :
930 }
931
933 *((SourceLocation*)this->getExtraLocalData() + 1) = Loc;
934 }
935
936 unsigned getNumProtocols() const {
937 return this->getTypePtr()->getNumProtocols();
938 }
939
940 SourceLocation getProtocolLoc(unsigned i) const {
941 assert(i < getNumProtocols() && "Index is out of bounds!");
942 return getProtocolLocArray()[i];
943 }
944
945 void setProtocolLoc(unsigned i, SourceLocation Loc) {
946 assert(i < getNumProtocols() && "Index is out of bounds!");
947 getProtocolLocArray()[i] = Loc;
948 }
949
950 ObjCProtocolDecl *getProtocol(unsigned i) const {
951 assert(i < getNumProtocols() && "Index is out of bounds!");
952 return *(this->getTypePtr()->qual_begin() + i);
953 }
954
956 return {getProtocolLocArray(), getNumProtocols()};
957 }
958
959 void initializeLocal(ASTContext &Context, SourceLocation Loc);
960
961 unsigned getExtraLocalDataSize() const {
962 if (!this->getNumProtocols()) return 0;
963 // When there are protocol qualifers, we have LAngleLoc and RAngleLoc
964 // as well.
965 return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ;
966 }
967
968 unsigned getExtraLocalDataAlignment() const {
969 return alignof(SourceLocation);
970 }
971
973 SourceLocation start = getNameLoc();
975 if (end.isInvalid()) return SourceRange(start, start);
976 return SourceRange(start, end);
977 }
978};
979
980/// Wrapper for substituted template type parameters.
982 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
983 SubstTemplateTypeParmTypeLoc,
984 SubstTemplateTypeParmType> {
985};
986
987/// Abstract type representing delayed type pack expansions.
989 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, SubstPackTypeLoc,
990 SubstPackType> {};
991
992/// Wrapper for substituted template type parameters.
994 : public InheritingConcreteTypeLoc<SubstPackTypeLoc,
995 SubstTemplateTypeParmPackTypeLoc,
996 SubstTemplateTypeParmPackType> {};
997
998/// Wrapper for substituted template type parameters.
1000 : public InheritingConcreteTypeLoc<SubstPackTypeLoc,
1001 SubstBuiltinTemplatePackTypeLoc,
1002 SubstBuiltinTemplatePackType> {};
1003
1006};
1007
1008/// Type source information for an attributed type.
1009class AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1010 AttributedTypeLoc,
1011 AttributedType,
1012 AttributedLocInfo> {
1013public:
1015 return getTypePtr()->getAttrKind();
1016 }
1017
1018 bool isQualifier() const {
1019 return getTypePtr()->isQualifier();
1020 }
1021
1022 /// The modified type, which is generally canonically different from
1023 /// the attribute type.
1024 /// int main(int, char**) __attribute__((noreturn))
1025 /// ~~~ ~~~~~~~~~~~~~
1027 return getInnerTypeLoc();
1028 }
1029
1031 return TypeLoc(getTypePtr()->getEquivalentType(), getNonLocalData());
1032 }
1033
1034 /// The type attribute.
1035 const Attr *getAttr() const {
1036 return getLocalData()->TypeAttr;
1037 }
1038 void setAttr(const Attr *A) {
1039 getLocalData()->TypeAttr = A;
1040 }
1041
1042 template<typename T> const T *getAttrAs() {
1043 return dyn_cast_or_null<T>(getAttr());
1044 }
1045
1047
1049 setAttr(nullptr);
1050 }
1051
1053 return getTypePtr()->getModifiedType();
1054 }
1055};
1056
1057struct BTFTagAttributedLocInfo {}; // Nothing.
1058
1059/// Type source information for an btf_tag attributed type.
1061 : public ConcreteTypeLoc<UnqualTypeLoc, BTFTagAttributedTypeLoc,
1062 BTFTagAttributedType, BTFTagAttributedLocInfo> {
1063public:
1065
1066 /// The btf_type_tag attribute.
1067 const BTFTypeTagAttr *getAttr() const { return getTypePtr()->getAttr(); }
1068
1069 template <typename T> T *getAttrAs() {
1070 return dyn_cast_or_null<T>(getAttr());
1071 }
1072
1074
1076
1077 QualType getInnerType() const { return getTypePtr()->getWrappedType(); }
1078};
1079
1084
1085/// Type source information for HLSL attributed resource type.
1087 : public ConcreteTypeLoc<UnqualTypeLoc, HLSLAttributedResourceTypeLoc,
1088 HLSLAttributedResourceType,
1089 HLSLAttributedResourceLocInfo> {
1090public:
1092
1099
1105 QualType getInnerType() const { return getTypePtr()->getWrappedType(); }
1106 unsigned getLocalDataSize() const {
1107 return sizeof(HLSLAttributedResourceLocInfo);
1108 }
1109};
1110
1114
1116 : public ConcreteTypeLoc<UnqualTypeLoc, HLSLInlineSpirvTypeLoc,
1117 HLSLInlineSpirvType, HLSLInlineSpirvTypeLocInfo> {
1118public:
1120 void setSpirvTypeLoc(SourceLocation loc) const { getLocalData()->Loc = loc; }
1121
1126 setSpirvTypeLoc(loc);
1127 }
1128};
1129
1137
1138// A helper class for defining ObjC TypeLocs that can qualified with
1139// protocols.
1140//
1141// TypeClass basically has to be either ObjCInterfaceType or
1142// ObjCObjectPointerType.
1143class ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1144 ObjCObjectTypeLoc,
1145 ObjCObjectType,
1146 ObjCObjectTypeLocInfo> {
1147 // TypeSourceInfo*'s are stored after Info, one for each type argument.
1148 TypeSourceInfo **getTypeArgLocArray() const {
1149 return (TypeSourceInfo**)this->getExtraLocalData();
1150 }
1151
1152 // SourceLocations are stored after the type argument information, one for
1153 // each Protocol.
1154 SourceLocation *getProtocolLocArray() const {
1155 return (SourceLocation*)(getTypeArgLocArray() + getNumTypeArgs());
1156 }
1157
1158public:
1162
1166
1170
1174
1175 unsigned getNumTypeArgs() const {
1176 return this->getTypePtr()->getTypeArgsAsWritten().size();
1177 }
1178
1179 TypeSourceInfo *getTypeArgTInfo(unsigned i) const {
1180 assert(i < getNumTypeArgs() && "Index is out of bounds!");
1181 return getTypeArgLocArray()[i];
1182 }
1183
1184 void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo) {
1185 assert(i < getNumTypeArgs() && "Index is out of bounds!");
1186 getTypeArgLocArray()[i] = TInfo;
1187 }
1188
1192
1196
1200
1204
1205 unsigned getNumProtocols() const {
1206 return this->getTypePtr()->getNumProtocols();
1207 }
1208
1209 SourceLocation getProtocolLoc(unsigned i) const {
1210 assert(i < getNumProtocols() && "Index is out of bounds!");
1211 return getProtocolLocArray()[i];
1212 }
1213
1214 void setProtocolLoc(unsigned i, SourceLocation Loc) {
1215 assert(i < getNumProtocols() && "Index is out of bounds!");
1216 getProtocolLocArray()[i] = Loc;
1217 }
1218
1219 ObjCProtocolDecl *getProtocol(unsigned i) const {
1220 assert(i < getNumProtocols() && "Index is out of bounds!");
1221 return *(this->getTypePtr()->qual_begin() + i);
1222 }
1223
1224
1226 return {getProtocolLocArray(), getNumProtocols()};
1227 }
1228
1231 }
1232
1233 void setHasBaseTypeAsWritten(bool HasBaseType) {
1234 getLocalData()->HasBaseTypeAsWritten = HasBaseType;
1235 }
1236
1238 return getInnerTypeLoc();
1239 }
1240
1243 if (start.isInvalid())
1244 start = getProtocolLAngleLoc();
1246 if (end.isInvalid())
1247 end = getTypeArgsRAngleLoc();
1248 return SourceRange(start, end);
1249 }
1250
1251 void initializeLocal(ASTContext &Context, SourceLocation Loc);
1252
1253 unsigned getExtraLocalDataSize() const {
1254 return this->getNumTypeArgs() * sizeof(TypeSourceInfo *)
1255 + this->getNumProtocols() * sizeof(SourceLocation);
1256 }
1257
1259 static_assert(alignof(ObjCObjectTypeLoc) >= alignof(TypeSourceInfo *),
1260 "not enough alignment for tail-allocated data");
1261 return alignof(TypeSourceInfo *);
1262 }
1263
1265 return getTypePtr()->getBaseType();
1266 }
1267};
1268
1273
1274/// Wrapper for source info for ObjC interfaces.
1275class ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc,
1276 ObjCInterfaceTypeLoc,
1277 ObjCInterfaceType,
1278 ObjCInterfaceLocInfo> {
1279public:
1281 return getTypePtr()->getDecl();
1282 }
1283
1285 return getLocalData()->NameLoc;
1286 }
1287
1289 getLocalData()->NameLoc = Loc;
1290 }
1291
1295
1297 return getLocalData()->NameEndLoc;
1298 }
1299
1301 getLocalData()->NameEndLoc = Loc;
1302 }
1303
1305 setNameLoc(Loc);
1306 setNameEndLoc(Loc);
1307 }
1308};
1309
1312 : public ConcreteTypeLoc<UnqualTypeLoc, BoundsAttributedTypeLoc,
1313 BoundsAttributedType, BoundsAttributedLocInfo> {
1314public:
1316 QualType getInnerType() const { return getTypePtr()->desugar(); }
1318 // nothing to do
1319 }
1320 // LocalData is empty and TypeLocBuilder doesn't handle DataSize 1.
1321 unsigned getLocalDataSize() const { return 0; }
1322};
1323
1325 : public InheritingConcreteTypeLoc<BoundsAttributedTypeLoc,
1326 CountAttributedTypeLoc,
1327 CountAttributedType> {
1328public:
1329 Expr *getCountExpr() const { return getTypePtr()->getCountExpr(); }
1330 bool isCountInBytes() const { return getTypePtr()->isCountInBytes(); }
1331 bool isOrNull() const { return getTypePtr()->isOrNull(); }
1332
1334};
1335
1339
1341 : public ConcreteTypeLoc<UnqualTypeLoc, MacroQualifiedTypeLoc,
1342 MacroQualifiedType, MacroQualifiedLocInfo> {
1343public:
1345 setExpansionLoc(Loc);
1346 }
1347
1349
1351 return getTypePtr()->getMacroIdentifier();
1352 }
1353
1355 return this->getLocalData()->ExpansionLoc;
1356 }
1357
1359 this->getLocalData()->ExpansionLoc = Loc;
1360 }
1361
1363
1367};
1368
1373
1375 : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
1376 ParenLocInfo> {
1377public:
1379 return this->getLocalData()->LParenLoc;
1380 }
1381
1383 return this->getLocalData()->RParenLoc;
1384 }
1385
1387 this->getLocalData()->LParenLoc = Loc;
1388 }
1389
1391 this->getLocalData()->RParenLoc = Loc;
1392 }
1393
1397
1399 setLParenLoc(Loc);
1400 setRParenLoc(Loc);
1401 }
1402
1404 return getInnerTypeLoc();
1405 }
1406
1408 return this->getTypePtr()->getInnerType();
1409 }
1410};
1411
1413 if (ParenTypeLoc::isKind(*this))
1414 return IgnoreParensImpl(*this);
1415 return *this;
1416}
1417
1418struct AdjustedLocInfo {}; // Nothing.
1419
1420class AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc,
1421 AdjustedType, AdjustedLocInfo> {
1422public:
1424 return getInnerTypeLoc();
1425 }
1426
1428 // do nothing
1429 }
1430
1432 // The inner type is the undecayed type, since that's what we have source
1433 // location information for.
1434 return getTypePtr()->getOriginalType();
1435 }
1436
1437 SourceRange getLocalSourceRange() const { return {}; }
1438
1439 unsigned getLocalDataSize() const {
1440 // sizeof(AdjustedLocInfo) is 1, but we don't need its address to be unique
1441 // anyway. TypeLocBuilder can't handle data sizes of 1.
1442 return 0; // No data.
1443 }
1444};
1445
1446/// Wrapper for source info for pointers decayed from arrays and
1447/// functions.
1449 AdjustedTypeLoc, DecayedTypeLoc, DecayedType> {
1450};
1451
1455
1456/// A base class for
1457template <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
1458class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
1459 TypeClass, LocalData> {
1460public:
1462 return this->getLocalData()->StarLoc;
1463 }
1464
1466 this->getLocalData()->StarLoc = Loc;
1467 }
1468
1470 return this->getInnerTypeLoc();
1471 }
1472
1476
1478 setSigilLoc(Loc);
1479 }
1480
1482 return this->getTypePtr()->getPointeeType();
1483 }
1484};
1485
1486/// Wrapper for source info for pointers.
1487class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
1488 PointerType> {
1489public:
1491 return getSigilLoc();
1492 }
1493
1495 setSigilLoc(Loc);
1496 }
1497};
1498
1499/// Wrapper for source info for block pointers.
1500class BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
1501 BlockPointerType> {
1502public:
1504 return getSigilLoc();
1505 }
1506
1508 setSigilLoc(Loc);
1509 }
1510};
1511
1513 void *QualifierData = nullptr;
1514};
1515
1516/// Wrapper for source info for member pointers.
1517class MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
1518 MemberPointerType,
1519 MemberPointerLocInfo> {
1520public:
1522 return getSigilLoc();
1523 }
1524
1526 setSigilLoc(Loc);
1527 }
1528
1530 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
1531 getLocalData()->QualifierData);
1532 }
1533
1535 assert(QualifierLoc.getNestedNameSpecifier() ==
1536 getTypePtr()->getQualifier() &&
1537 "Inconsistent nested-name-specifier pointer");
1538 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
1539 }
1540
1542 setSigilLoc(Loc);
1543 if (NestedNameSpecifier Qualifier = getTypePtr()->getQualifier()) {
1545 Builder.MakeTrivial(Context, Qualifier, Loc);
1546 setQualifierLoc(Builder.getWithLocInContext(Context));
1547 } else
1548 getLocalData()->QualifierData = nullptr;
1549 }
1550
1553 return SourceRange(QL.getBeginLoc(), getStarLoc());
1554 return SourceRange(getStarLoc());
1555 }
1556};
1557
1558/// Wraps an ObjCPointerType with source location information.
1560 public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
1561 ObjCObjectPointerType> {
1562public:
1564 return getSigilLoc();
1565 }
1566
1568 setSigilLoc(Loc);
1569 }
1570};
1571
1572class ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
1573 ReferenceType> {
1574public:
1577 }
1578};
1579
1581 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1582 LValueReferenceTypeLoc,
1583 LValueReferenceType> {
1584public:
1586 return getSigilLoc();
1587 }
1588
1590 setSigilLoc(Loc);
1591 }
1592};
1593
1595 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1596 RValueReferenceTypeLoc,
1597 RValueReferenceType> {
1598public:
1600 return getSigilLoc();
1601 }
1602
1604 setSigilLoc(Loc);
1605 }
1606};
1607
1614
1615/// Wrapper for source info for functions.
1616class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1617 FunctionTypeLoc,
1618 FunctionType,
1619 FunctionLocInfo> {
1620 bool hasExceptionSpec() const {
1621 if (auto *FPT = dyn_cast<FunctionProtoType>(getTypePtr())) {
1622 return FPT->hasExceptionSpec();
1623 }
1624 return false;
1625 }
1626
1627 SourceRange *getExceptionSpecRangePtr() const {
1628 assert(hasExceptionSpec() && "No exception spec range");
1629 // After the Info comes the ParmVarDecl array, and after that comes the
1630 // exception specification information.
1631 return (SourceRange *)(getParmArray() + getNumParams());
1632 }
1633
1634public:
1638
1642
1646
1650
1652 return this->getLocalData()->LParenLoc;
1653 }
1654
1656 this->getLocalData()->LParenLoc = Loc;
1657 }
1658
1660 return this->getLocalData()->RParenLoc;
1661 }
1662
1664 this->getLocalData()->RParenLoc = Loc;
1665 }
1666
1670
1672 if (hasExceptionSpec())
1673 return *getExceptionSpecRangePtr();
1674 return {};
1675 }
1676
1678 if (hasExceptionSpec())
1679 *getExceptionSpecRangePtr() = R;
1680 }
1681
1683 return {getParmArray(), getNumParams()};
1684 }
1685
1686 // ParmVarDecls* are stored after Info, one for each parameter.
1688 return (ParmVarDecl**) getExtraLocalData();
1689 }
1690
1691 unsigned getNumParams() const {
1693 return 0;
1694 return cast<FunctionProtoType>(getTypePtr())->getNumParams();
1695 }
1696
1697 ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; }
1698 void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1699
1701 return getInnerTypeLoc();
1702 }
1703
1707
1709 setLocalRangeBegin(Loc);
1710 setLParenLoc(Loc);
1711 setRParenLoc(Loc);
1712 setLocalRangeEnd(Loc);
1713 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
1714 setParam(i, nullptr);
1715 if (hasExceptionSpec())
1717 }
1718
1719 /// Returns the size of the type source info data block that is
1720 /// specific to this type.
1721 unsigned getExtraLocalDataSize() const {
1722 unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
1723 return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
1724 }
1725
1726 unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); }
1727
1729};
1730
1732 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1733 FunctionProtoTypeLoc,
1734 FunctionProtoType> {
1735};
1736
1738 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1739 FunctionNoProtoTypeLoc,
1740 FunctionNoProtoType> {
1741};
1742
1747
1748/// Wrapper for source info for arrays.
1749class ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1750 ArrayTypeLoc,
1751 ArrayType,
1752 ArrayLocInfo> {
1753public:
1755 return getLocalData()->LBracketLoc;
1756 }
1757
1759 getLocalData()->LBracketLoc = Loc;
1760 }
1761
1763 return getLocalData()->RBracketLoc;
1764 }
1765
1767 getLocalData()->RBracketLoc = Loc;
1768 }
1769
1773
1775 return getLocalData()->Size;
1776 }
1777
1778 void setSizeExpr(Expr *Size) {
1779 getLocalData()->Size = Size;
1780 }
1781
1783 return getInnerTypeLoc();
1784 }
1785
1789
1791 setLBracketLoc(Loc);
1792 setRBracketLoc(Loc);
1793 setSizeExpr(nullptr);
1794 }
1795
1797};
1798
1800 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1801 ConstantArrayTypeLoc,
1802 ConstantArrayType> {
1803};
1804
1805/// Wrapper for source info for array parameter types.
1808 ConstantArrayTypeLoc, ArrayParameterTypeLoc, ArrayParameterType> {};
1809
1811 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1812 IncompleteArrayTypeLoc,
1813 IncompleteArrayType> {
1814};
1815
1817 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1818 DependentSizedArrayTypeLoc,
1819 DependentSizedArrayType> {
1820public:
1825};
1826
1828 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1829 VariableArrayTypeLoc,
1830 VariableArrayType> {
1831};
1832
1833// Location information for a TemplateName. Rudimentary for now.
1837
1845
1847 public ConcreteTypeLoc<UnqualTypeLoc,
1848 TemplateSpecializationTypeLoc,
1849 TemplateSpecializationType,
1850 TemplateSpecializationLocInfo> {
1851public:
1852 void set(SourceLocation ElaboratedKeywordLoc,
1853 NestedNameSpecifierLoc QualifierLoc,
1854 SourceLocation TemplateKeywordLoc, SourceLocation NameLoc,
1855 SourceLocation LAngleLoc, SourceLocation RAngleLoc);
1856
1857 void set(SourceLocation ElaboratedKeywordLoc,
1858 NestedNameSpecifierLoc QualifierLoc,
1859 SourceLocation TemplateKeywordLoc, SourceLocation NameLoc,
1860 const TemplateArgumentListInfo &TAL);
1861
1865
1867 if (!getLocalData()->QualifierData)
1868 return NestedNameSpecifierLoc();
1869
1870 NestedNameSpecifier Qualifier =
1871 getTypePtr()->getTemplateName().getQualifier();
1872 assert(Qualifier && "missing qualification");
1873 return NestedNameSpecifierLoc(Qualifier, getLocalData()->QualifierData);
1874 }
1875
1879
1881
1883
1884 unsigned getNumArgs() const {
1885 return getTypePtr()->template_arguments().size();
1886 }
1887
1889 return {getArgInfos(), getNumArgs()};
1890 }
1891
1892 TemplateArgumentLoc getArgLoc(unsigned i) const {
1893 return TemplateArgumentLoc(getTypePtr()->template_arguments()[i],
1894 getArgInfos()[i]);
1895 }
1896
1898
1899 /// - Copy the location information from the given info.
1901 unsigned size = getFullDataSize();
1902 assert(size == Loc.getFullDataSize());
1903
1904 // We're potentially copying Expr references here. We don't
1905 // bother retaining them because TypeSourceInfos live forever, so
1906 // as long as the Expr was retained when originally written into
1907 // the TypeLoc, we're okay.
1908 memcpy(Data, Loc.Data, size);
1909 }
1910
1912
1913 void initializeLocal(ASTContext &Context, SourceLocation Loc);
1914
1915 static void initializeArgLocs(ASTContext &Context,
1917 TemplateArgumentLocInfo *ArgInfos,
1918 SourceLocation Loc);
1919
1920 unsigned getExtraLocalDataSize() const {
1921 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1922 }
1923
1925 return alignof(TemplateArgumentLocInfo);
1926 }
1927
1928private:
1929 TemplateArgumentLocInfo *getArgInfos() const {
1930 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1931 }
1932};
1933
1939
1941 : public ConcreteTypeLoc<UnqualTypeLoc,
1942 DependentAddressSpaceTypeLoc,
1943 DependentAddressSpaceType,
1944 DependentAddressSpaceLocInfo> {
1945public:
1946 /// The location of the attribute name, i.e.
1947 /// int * __attribute__((address_space(11)))
1948 /// ^~~~~~~~~~~~~
1950 return getLocalData()->AttrLoc;
1951 }
1953 getLocalData()->AttrLoc = loc;
1954 }
1955
1956 /// The attribute's expression operand, if it has one.
1957 /// int * __attribute__((address_space(11)))
1958 /// ^~
1960 return getLocalData()->ExprOperand;
1961 }
1964 }
1965
1966 /// The location of the parentheses around the operand, if there is
1967 /// an operand.
1968 /// int * __attribute__((address_space(11)))
1969 /// ^ ^
1976
1978 SourceRange range(getAttrNameLoc());
1979 range.setEnd(getAttrOperandParensRange().getEnd());
1980 return range;
1981 }
1982
1983 /// Returns the type before the address space attribute application
1984 /// area.
1985 /// int * __attribute__((address_space(11))) *
1986 /// ^ ^
1988 return this->getTypePtr()->getPointeeType();
1989 }
1990
1992 return this->getInnerTypeLoc();
1993 }
1994
1996 setAttrNameLoc(loc);
1999 setAttrExprOperand(getTypePtr()->getAddrSpaceExpr());
2000 }
2001};
2002
2003//===----------------------------------------------------------------------===//
2004//
2005// All of these need proper implementations.
2006//
2007//===----------------------------------------------------------------------===//
2008
2009// FIXME: size expression and attribute locations (or keyword if we
2010// ever fully support altivec syntax).
2014
2015class VectorTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, VectorTypeLoc,
2016 VectorType, VectorTypeLocInfo> {
2017public:
2018 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
2019
2020 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
2021
2025
2027 setNameLoc(Loc);
2028 }
2029
2031
2032 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2033};
2034
2035// FIXME: size expression and attribute locations (or keyword if we
2036// ever fully support altivec syntax).
2038 : public ConcreteTypeLoc<UnqualTypeLoc, DependentVectorTypeLoc,
2039 DependentVectorType, VectorTypeLocInfo> {
2040public:
2041 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
2042
2043 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
2044
2048
2050 setNameLoc(Loc);
2051 }
2052
2054
2055 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2056};
2057
2058// FIXME: size expression and attribute locations.
2060 : public InheritingConcreteTypeLoc<VectorTypeLoc, ExtVectorTypeLoc,
2061 ExtVectorType> {};
2062
2063// FIXME: attribute locations.
2064// For some reason, this isn't a subtype of VectorType.
2066 : public ConcreteTypeLoc<UnqualTypeLoc, DependentSizedExtVectorTypeLoc,
2067 DependentSizedExtVectorType, VectorTypeLocInfo> {
2068public:
2069 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
2070
2071 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
2072
2076
2078 setNameLoc(Loc);
2079 }
2080
2082
2083 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2084};
2085
2092
2093class MatrixTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, MatrixTypeLoc,
2094 MatrixType, MatrixTypeLocInfo> {
2095public:
2096 /// The location of the attribute name, i.e.
2097 /// float __attribute__((matrix_type(4, 2)))
2098 /// ^~~~~~~~~~~~~~~~~
2101
2102 /// The attribute's row operand, if it has one.
2103 /// float __attribute__((matrix_type(4, 2)))
2104 /// ^
2107
2108 /// The attribute's column operand, if it has one.
2109 /// float __attribute__((matrix_type(4, 2)))
2110 /// ^
2113
2114 /// The location of the parentheses around the operand, if there is
2115 /// an operand.
2116 /// float __attribute__((matrix_type(4, 2)))
2117 /// ^ ^
2124
2126 SourceRange range(getAttrNameLoc());
2127 range.setEnd(getAttrOperandParensRange().getEnd());
2128 return range;
2129 }
2130
2132 setAttrNameLoc(loc);
2134 setAttrRowOperand(nullptr);
2135 setAttrColumnOperand(nullptr);
2136 }
2137};
2138
2140 : public InheritingConcreteTypeLoc<MatrixTypeLoc, ConstantMatrixTypeLoc,
2141 ConstantMatrixType> {};
2142
2144 : public InheritingConcreteTypeLoc<MatrixTypeLoc,
2145 DependentSizedMatrixTypeLoc,
2146 DependentSizedMatrixType> {};
2147
2148// FIXME: location of the '_Complex' keyword.
2149class ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
2150 ComplexTypeLoc,
2151 ComplexType> {
2152};
2153
2159
2161};
2162
2166
2167template <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
2169 : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
2170public:
2172 return this->getLocalData()->TypeofLoc;
2173 }
2174
2176 this->getLocalData()->TypeofLoc = Loc;
2177 }
2178
2180 return this->getLocalData()->LParenLoc;
2181 }
2182
2184 this->getLocalData()->LParenLoc = Loc;
2185 }
2186
2188 return this->getLocalData()->RParenLoc;
2189 }
2190
2192 this->getLocalData()->RParenLoc = Loc;
2193 }
2194
2198
2200 setLParenLoc(range.getBegin());
2201 setRParenLoc(range.getEnd());
2202 }
2203
2207
2209 setTypeofLoc(Loc);
2210 setLParenLoc(Loc);
2211 setRParenLoc(Loc);
2212 }
2213};
2214
2215class TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
2216 TypeOfExprType,
2217 TypeOfExprTypeLocInfo> {
2218public:
2220 return getTypePtr()->getUnderlyingExpr();
2221 }
2222
2223 // Reimplemented to account for GNU/C++ extension
2224 // typeof unary-expression
2225 // where there are no parentheses.
2227};
2228
2230 : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
2231public:
2233 return this->getTypePtr()->getUnmodifiedType();
2234 }
2235
2237 return this->getLocalData()->UnmodifiedTInfo;
2238 }
2239
2241 this->getLocalData()->UnmodifiedTInfo = TI;
2242 }
2243
2244 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2245};
2246
2247// decltype(expression) abc;
2248// ~~~~~~~~ DecltypeLoc
2249// ~ RParenLoc
2250// FIXME: add LParenLoc, it is tricky to support due to the limitation of
2251// annotated-decltype token.
2257 : public ConcreteTypeLoc<UnqualTypeLoc, DecltypeTypeLoc, DecltypeType,
2258 DecltypeTypeLocInfo> {
2259public:
2260 Expr *getUnderlyingExpr() const { return getTypePtr()->getUnderlyingExpr(); }
2261
2264
2267
2271
2273 setDecltypeLoc(Loc);
2274 setRParenLoc(Loc);
2275 }
2276};
2277
2281
2283 : public ConcreteTypeLoc<UnqualTypeLoc, PackIndexingTypeLoc,
2284 PackIndexingType, PackIndexingTypeLocInfo> {
2285
2286public:
2287 Expr *getIndexExpr() const { return getTypePtr()->getIndexExpr(); }
2288 QualType getPattern() const { return getTypePtr()->getPattern(); }
2289
2292
2294 setEllipsisLoc(Loc);
2295 }
2296
2298
2299 QualType getInnerType() const { return this->getTypePtr()->getPattern(); }
2300
2304};
2305
2307 // FIXME: While there's only one unary transform right now, future ones may
2308 // need different representations
2311};
2312
2313class UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2314 UnaryTransformTypeLoc,
2315 UnaryTransformType,
2316 UnaryTransformTypeLocInfo> {
2317public:
2320
2323
2326
2330
2332 getLocalData()->UnderlyingTInfo = TInfo;
2333 }
2334
2338
2342
2344 setLParenLoc(Range.getBegin());
2345 setRParenLoc(Range.getEnd());
2346 }
2347
2348 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2349};
2350
2352 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DeducedTypeLoc,
2353 DeducedType> {};
2354
2356 // For decltype(auto).
2358
2360};
2361
2363 : public ConcreteTypeLoc<DeducedTypeLoc,
2364 AutoTypeLoc,
2365 AutoType,
2366 AutoTypeLocInfo> {
2367public:
2369 return getTypePtr()->getKeyword();
2370 }
2371
2372 bool isDecltypeAuto() const { return getTypePtr()->isDecltypeAuto(); }
2375
2376 bool isConstrained() const {
2377 return getTypePtr()->isConstrained();
2378 }
2379
2381
2383
2384 // FIXME: Several of the following functions can be removed. Instead the
2385 // caller can directly work with the ConceptReference.
2387 if (const auto *CR = getConceptReference())
2388 return CR->getNestedNameSpecifierLoc();
2389 return NestedNameSpecifierLoc();
2390 }
2391
2393 if (const auto *CR = getConceptReference())
2394 return CR->getTemplateKWLoc();
2395 return SourceLocation();
2396 }
2397
2399 if (const auto *CR = getConceptReference())
2400 return CR->getConceptNameLoc();
2401 return SourceLocation();
2402 }
2403
2405 if (const auto *CR = getConceptReference())
2406 return CR->getFoundDecl();
2407 return nullptr;
2408 }
2409
2411 if (const auto *CR = getConceptReference())
2412 return CR->getNamedConcept();
2413 return nullptr;
2414 }
2415
2419
2421 return (getConceptReference() &&
2422 getConceptReference()->getTemplateArgsAsWritten() &&
2424 ->getTemplateArgsAsWritten()
2425 ->getLAngleLoc()
2426 .isValid());
2427 }
2428
2430 if (const auto *CR = getConceptReference())
2431 if (const auto *TAAW = CR->getTemplateArgsAsWritten())
2432 return TAAW->getLAngleLoc();
2433 return SourceLocation();
2434 }
2435
2437 if (const auto *CR = getConceptReference())
2438 if (const auto *TAAW = CR->getTemplateArgsAsWritten())
2439 return TAAW->getRAngleLoc();
2440 return SourceLocation();
2441 }
2442
2443 unsigned getNumArgs() const {
2444 return getTypePtr()->getTypeConstraintArguments().size();
2445 }
2446
2447 TemplateArgumentLoc getArgLoc(unsigned i) const {
2448 const auto *CR = getConceptReference();
2449 assert(CR && "No ConceptReference");
2450 return CR->getTemplateArgsAsWritten()->getTemplateArgs()[i];
2451 }
2452
2462
2463 void copy(AutoTypeLoc Loc) {
2464 unsigned size = getFullDataSize();
2465 assert(size == Loc.getFullDataSize());
2466 memcpy(Data, Loc.Data, size);
2467 }
2468
2469 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2470};
2471
2474 /// Data associated with the nested-name-specifier location.
2476};
2477
2479 : public ConcreteTypeLoc<DeducedTypeLoc,
2480 DeducedTemplateSpecializationTypeLoc,
2481 DeducedTemplateSpecializationType,
2482 DeducedTemplateSpecializationLocInfo> {
2483public:
2487
2491
2493
2495
2497 void *Data = getLocalData()->QualifierData;
2498 if (!Data)
2499 return NestedNameSpecifierLoc();
2500 NestedNameSpecifier Qualifier =
2501 getTypePtr()->getTemplateName().getQualifier();
2502 assert(Qualifier && "missing qualification");
2503 return NestedNameSpecifierLoc(Qualifier, Data);
2504 }
2505
2507 if (!QualifierLoc) {
2508 // Even if we have a nested-name-specifier in the dependent
2509 // template specialization type, we won't record the nested-name-specifier
2510 // location information when this type-source location information is
2511 // part of a nested-name-specifier.
2512 getLocalData()->QualifierData = nullptr;
2513 return;
2514 }
2515
2516 assert(QualifierLoc.getNestedNameSpecifier() ==
2517 getTypePtr()->getTemplateName().getQualifier() &&
2518 "Inconsistent nested-name-specifier pointer");
2519 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2520 }
2521
2524 if (BeginLoc.isInvalid())
2525 BeginLoc = getQualifierLoc().getBeginLoc();
2526 if (BeginLoc.isInvalid())
2527 BeginLoc = getNameLoc();
2528 return {BeginLoc, getNameLoc()};
2529 }
2530
2531 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2532};
2533
2536
2537 /// Data associated with the nested-name-specifier location.
2539};
2540
2541// This is exactly the structure of an ElaboratedTypeLoc whose inner
2542// type is some sort of TypeDeclTypeLoc.
2546
2547class DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2548 DependentNameTypeLoc,
2549 DependentNameType,
2550 DependentNameLocInfo> {
2551public:
2555
2559
2561 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2562 getLocalData()->QualifierData);
2563 }
2564
2566 assert(QualifierLoc.getNestedNameSpecifier()
2567 == getTypePtr()->getQualifier() &&
2568 "Inconsistent nested-name-specifier pointer");
2569 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2570 }
2571
2573 return this->getLocalData()->NameLoc;
2574 }
2575
2577 this->getLocalData()->NameLoc = Loc;
2578 }
2579
2581 if (getElaboratedKeywordLoc().isValid())
2583 else
2585 }
2586
2588 unsigned size = getFullDataSize();
2589 assert(size == Loc.getFullDataSize());
2590 memcpy(Data, Loc.Data, size);
2591 }
2592
2593 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2594};
2595
2599
2601 : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
2602 PackExpansionType, PackExpansionTypeLocInfo> {
2603public:
2605 return this->getLocalData()->EllipsisLoc;
2606 }
2607
2609 this->getLocalData()->EllipsisLoc = Loc;
2610 }
2611
2615
2617 setEllipsisLoc(Loc);
2618 }
2619
2621 return getInnerTypeLoc();
2622 }
2623
2625 return this->getTypePtr()->getPattern();
2626 }
2627};
2628
2632
2633class AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc,
2634 AtomicType, AtomicTypeLocInfo> {
2635public:
2637 return this->getInnerTypeLoc();
2638 }
2639
2643
2645 return this->getLocalData()->KWLoc;
2646 }
2647
2649 this->getLocalData()->KWLoc = Loc;
2650 }
2651
2653 return this->getLocalData()->LParenLoc;
2654 }
2655
2657 this->getLocalData()->LParenLoc = Loc;
2658 }
2659
2661 return this->getLocalData()->RParenLoc;
2662 }
2663
2665 this->getLocalData()->RParenLoc = Loc;
2666 }
2667
2671
2673 setLParenLoc(Range.getBegin());
2674 setRParenLoc(Range.getEnd());
2675 }
2676
2678 setKWLoc(Loc);
2679 setLParenLoc(Loc);
2680 setRParenLoc(Loc);
2681 }
2682
2684 return this->getTypePtr()->getValueType();
2685 }
2686};
2687
2691
2692class PipeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, PipeTypeLoc, PipeType,
2693 PipeTypeLocInfo> {
2694public:
2695 TypeLoc getValueLoc() const { return this->getInnerTypeLoc(); }
2696
2698
2699 SourceLocation getKWLoc() const { return this->getLocalData()->KWLoc; }
2700 void setKWLoc(SourceLocation Loc) { this->getLocalData()->KWLoc = Loc; }
2701
2703 setKWLoc(Loc);
2704 }
2705
2706 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2707};
2708
2709template <typename T>
2711 TypeLoc Cur = *this;
2712 while (!T::isKind(Cur)) {
2713 if (auto PTL = Cur.getAs<ParenTypeLoc>())
2714 Cur = PTL.getInnerLoc();
2715 else if (auto ATL = Cur.getAs<AttributedTypeLoc>())
2716 Cur = ATL.getModifiedLoc();
2717 else if (auto ATL = Cur.getAs<BTFTagAttributedTypeLoc>())
2718 Cur = ATL.getWrappedLoc();
2719 else if (auto ATL = Cur.getAs<HLSLAttributedResourceTypeLoc>())
2720 Cur = ATL.getWrappedLoc();
2721 else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())
2722 Cur = ATL.getOriginalLoc();
2723 else if (auto MQL = Cur.getAs<MacroQualifiedTypeLoc>())
2724 Cur = MQL.getInnerLoc();
2725 else
2726 break;
2727 }
2728 return Cur.getAs<T>();
2729}
2730class BitIntTypeLoc final
2731 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, BitIntTypeLoc,
2732 BitIntType> {};
2734 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentBitIntTypeLoc,
2735 DependentBitIntType> {};
2736
2738 ObjCProtocolDecl *Protocol = nullptr;
2740
2741public:
2743 : Protocol(protocol), Loc(loc) {}
2744 ObjCProtocolDecl *getProtocol() const { return Protocol; }
2745 SourceLocation getLocation() const { return Loc; }
2746
2747 /// The source range is just the protocol name.
2748 SourceRange getSourceRange() const LLVM_READONLY {
2749 return SourceRange(Loc, Loc);
2750 }
2751};
2752
2753struct PredefinedSugarTypeLocInfo {}; // Nothing.
2754
2756 : public ConcreteTypeLoc<UnqualTypeLoc, PredefinedSugarTypeLoc,
2757 PredefinedSugarType, PredefinedSugarTypeLocInfo> {
2758public:
2760 SourceRange getLocalSourceRange() const { return {}; }
2761};
2762
2763} // namespace clang
2764
2765#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:1431
unsigned getLocalDataSize() const
Definition TypeLoc.h:1439
TypeLoc getOriginalLoc() const
Definition TypeLoc.h:1423
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1427
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1437
QualType getOriginalType() const
Definition TypeBase.h:3504
Wrapper for source info for array parameter types.
Definition TypeLoc.h:1808
Wrapper for source info for arrays.
Definition TypeLoc.h:1752
SourceLocation getLBracketLoc() const
Definition TypeLoc.h:1754
Expr * getSizeExpr() const
Definition TypeLoc.h:1774
void setLBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1758
TypeLoc getElementLoc() const
Definition TypeLoc.h:1782
void setRBracketLoc(SourceLocation Loc)
Definition TypeLoc.h:1766
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1790
SourceLocation getRBracketLoc() const
Definition TypeLoc.h:1762
SourceRange getBracketsRange() const
Definition TypeLoc.h:1770
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1786
QualType getInnerType() const
Definition TypeLoc.h:1796
void setSizeExpr(Expr *Size)
Definition TypeLoc.h:1778
QualType getElementType() const
Definition TypeBase.h:3734
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2660
QualType getInnerType() const
Definition TypeLoc.h:2683
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2640
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2664
SourceRange getParensRange() const
Definition TypeLoc.h:2668
TypeLoc getValueLoc() const
Definition TypeLoc.h:2636
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2656
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2648
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2677
SourceLocation getKWLoc() const
Definition TypeLoc.h:2644
SourceLocation getLParenLoc() const
Definition TypeLoc.h:2652
void setParensRange(SourceRange Range)
Definition TypeLoc.h:2672
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition TypeBase.h:8089
Attr - This represents one attribute.
Definition Attr.h:44
Type source information for an attributed type.
Definition TypeLoc.h:1012
const Attr * getAttr() const
The type attribute.
Definition TypeLoc.h:1035
QualType getInnerType() const
Definition TypeLoc.h:1052
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition TypeLoc.h:1026
TypeLoc getEquivalentTypeLoc() const
Definition TypeLoc.h:1030
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1048
SourceRange getLocalSourceRange() const
Definition TypeLoc.cpp:581
void setAttr(const Attr *A)
Definition TypeLoc.h:1038
attr::Kind getAttrKind() const
Definition TypeLoc.h:1014
bool isQualifier() const
Definition TypeLoc.h:1018
bool hasExplicitTemplateArgs() const
Definition TypeLoc.h:2420
SourceLocation getTemplateKWLoc() const
Definition TypeLoc.h:2392
AutoTypeKeyword getAutoKeyword() const
Definition TypeLoc.h:2368
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
Definition TypeLoc.h:2386
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:2436
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2373
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:789
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2453
void copy(AutoTypeLoc Loc)
Definition TypeLoc.h:2463
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:2429
void setConceptReference(ConceptReference *CR)
Definition TypeLoc.h:2380
SourceLocation getConceptNameLoc() const
Definition TypeLoc.h:2398
NamedDecl * getFoundDecl() const
Definition TypeLoc.h:2404
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition TypeLoc.h:2447
bool isDecltypeAuto() const
Definition TypeLoc.h:2372
bool isConstrained() const
Definition TypeLoc.h:2376
unsigned getNumArgs() const
Definition TypeLoc.h:2443
TemplateDecl * getNamedConcept() const
Definition TypeLoc.h:2410
ConceptReference * getConceptReference() const
Definition TypeLoc.h:2382
DeclarationNameInfo getConceptNameInfo() const
Definition TypeLoc.h:2416
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2374
Type source information for an btf_tag attributed type.
Definition TypeLoc.h:1062
QualType getInnerType() const
Definition TypeLoc.h:1077
TypeLoc getWrappedLoc() const
Definition TypeLoc.h:1064
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1075
const BTFTypeTagAttr * getAttr() const
The btf_type_tag attribute.
Definition TypeLoc.h:1067
SourceRange getLocalSourceRange() const
Definition TypeLoc.cpp:598
Wrapper for source info for block pointers.
Definition TypeLoc.h:1501
SourceLocation getCaretLoc() const
Definition TypeLoc.h:1503
void setCaretLoc(SourceLocation Loc)
Definition TypeLoc.h:1507
QualType getInnerType() const
Definition TypeLoc.h:1316
unsigned getLocalDataSize() const
Definition TypeLoc.h:1321
TypeLoc getInnerLoc() const
Definition TypeLoc.h:1315
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1317
QualType desugar() const
Definition TypeBase.h:3398
Wrapper for source info for builtin types.
Definition TypeLoc.h:577
SourceLocation getBuiltinLoc() const
Definition TypeLoc.h:579
TypeSpecifierType getWrittenTypeSpec() const
Definition TypeLoc.cpp:322
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:3212
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:1329
SourceRange getLocalSourceRange() const
Definition TypeLoc.cpp:594
bool isCountInBytes() const
Definition TypeBase.h:3463
Expr * getCountExpr() const
Definition TypeBase.h:3462
Wrapper for source info for pointers decayed from arrays and functions.
Definition TypeLoc.h:1449
SourceLocation getDecltypeLoc() const
Definition TypeLoc.h:2262
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2272
Expr * getUnderlyingExpr() const
Definition TypeLoc.h:2260
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2265
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2266
void setDecltypeLoc(SourceLocation Loc)
Definition TypeLoc.h:2263
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2268
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:2506
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2488
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:799
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:2484
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:2492
void setTemplateNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2494
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:2496
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:1952
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1977
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:1973
QualType getInnerType() const
Returns the type before the address space attribute application area.
Definition TypeLoc.h:1987
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
Definition TypeLoc.h:1959
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1995
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition TypeLoc.h:1970
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition TypeLoc.h:1949
QualType getPointeeType() const
Definition TypeBase.h:4073
void copy(DependentNameTypeLoc Loc)
Definition TypeLoc.h:2587
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:2560
SourceLocation getNameLoc() const
Definition TypeLoc.h:2572
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:637
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2580
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:2552
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2576
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition TypeLoc.h:2556
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:2565
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1821
SourceLocation getNameLoc() const
Definition TypeLoc.h:2069
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2073
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2071
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2077
SourceLocation getNameLoc() const
Definition TypeLoc.h:2041
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2045
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2049
TypeLoc getElementLoc() const
Definition TypeLoc.h:2053
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2043
QualType getInnerType() const
Definition TypeLoc.h:2055
QualType getElementType() const
Definition TypeBase.h:4239
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:4007
Wrapper for source info for enum types.
Definition TypeLoc.h:865
EnumDecl * getOriginalDecl() const
Definition TypeLoc.h:867
This represents one expression.
Definition Expr.h:112
Wrapper for source info for functions.
Definition TypeLoc.h:1619
ParmVarDecl ** getParmArray() const
Definition TypeLoc.h:1687
QualType getInnerType() const
Definition TypeLoc.h:1728
unsigned getNumParams() const
Definition TypeLoc.h:1691
ParmVarDecl * getParam(unsigned i) const
Definition TypeLoc.h:1697
SourceLocation getLocalRangeEnd() const
Definition TypeLoc.h:1643
void setLocalRangeBegin(SourceLocation L)
Definition TypeLoc.h:1639
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1655
SourceRange getExceptionSpecRange() const
Definition TypeLoc.h:1671
void setParam(unsigned i, ParmVarDecl *VD)
Definition TypeLoc.h:1698
ArrayRef< ParmVarDecl * > getParams() const
Definition TypeLoc.h:1682
SourceRange getParensRange() const
Definition TypeLoc.h:1667
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1663
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:1726
void setLocalRangeEnd(SourceLocation L)
Definition TypeLoc.h:1647
unsigned getExtraLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition TypeLoc.h:1721
void setExceptionSpecRange(SourceRange R)
Definition TypeLoc.h:1677
TypeLoc getReturnLoc() const
Definition TypeLoc.h:1700
SourceLocation getLocalRangeBegin() const
Definition TypeLoc.h:1635
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1704
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1651
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1659
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1708
QualType getReturnType() const
Definition TypeBase.h:4802
Type source information for HLSL attributed resource type.
Definition TypeLoc.h:1089
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1102
TypeSourceInfo * getContainedTypeSourceInfo() const
Definition TypeLoc.h:1093
void setContainedTypeSourceInfo(TypeSourceInfo *TSI) const
Definition TypeLoc.h:1096
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1101
void setSourceRange(const SourceRange &R)
Definition TypeLoc.h:1100
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1122
void setSpirvTypeLoc(SourceLocation loc) const
Definition TypeLoc.h:1120
SourceLocation getSpirvTypeLoc() const
Definition TypeLoc.h:1119
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:1125
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:874
CXXRecordDecl * getOriginalDecl() const
Definition TypeLoc.h:876
void setAmpLoc(SourceLocation Loc)
Definition TypeLoc.h:1589
SourceLocation getAmpLoc() const
Definition TypeLoc.h:1585
const IdentifierInfo * getMacroIdentifier() const
Definition TypeLoc.h:1350
SourceLocation getExpansionLoc() const
Definition TypeLoc.h:1354
TypeLoc getInnerLoc() const
Definition TypeLoc.h:1348
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1344
void setExpansionLoc(SourceLocation Loc)
Definition TypeLoc.h:1358
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1364
QualType getInnerType() const
Definition TypeLoc.h:1362
QualType getUnderlyingType() const
Definition TypeBase.h:6161
const IdentifierInfo * getMacroIdentifier() const
Definition TypeBase.h:6160
Expr * getAttrColumnOperand() const
The attribute's column operand, if it has one.
Definition TypeLoc.h:2111
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition TypeLoc.h:2118
void setAttrRowOperand(Expr *e)
Definition TypeLoc.h:2106
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2125
void setAttrColumnOperand(Expr *e)
Definition TypeLoc.h:2112
void setAttrOperandParensRange(SourceRange range)
Definition TypeLoc.h:2121
void setAttrNameLoc(SourceLocation loc)
Definition TypeLoc.h:2100
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition TypeLoc.h:2099
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:2131
Expr * getAttrRowOperand() const
The attribute's row operand, if it has one.
Definition TypeLoc.h:2105
Wrapper for source info for member pointers.
Definition TypeLoc.h:1519
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1541
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1525
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1529
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1551
SourceLocation getStarLoc() const
Definition TypeLoc.h:1521
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition TypeLoc.h:1534
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:1278
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:1288
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1292
void setNameEndLoc(SourceLocation Loc)
Definition TypeLoc.h:1300
ObjCInterfaceDecl * getIFaceDecl() const
Definition TypeLoc.h:1280
SourceLocation getNameEndLoc() const
Definition TypeLoc.h:1296
SourceLocation getNameLoc() const
Definition TypeLoc.h:1284
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1304
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition Type.cpp:951
Wraps an ObjCPointerType with source location information.
Definition TypeLoc.h:1561
SourceLocation getStarLoc() const
Definition TypeLoc.h:1563
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1567
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:1258
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:1171
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition TypeLoc.h:1219
unsigned getExtraLocalDataSize() const
Definition TypeLoc.h:1253
bool hasBaseTypeAsWritten() const
Definition TypeLoc.h:1229
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:565
SourceLocation getTypeArgsLAngleLoc() const
Definition TypeLoc.h:1159
unsigned getNumTypeArgs() const
Definition TypeLoc.h:1175
ArrayRef< SourceLocation > getProtocolLocs() const
Definition TypeLoc.h:1225
unsigned getNumProtocols() const
Definition TypeLoc.h:1205
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:1163
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1241
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition TypeLoc.h:1179
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition TypeLoc.h:1184
void setProtocolLAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:1193
void setProtocolRAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:1201
SourceLocation getProtocolRAngleLoc() const
Definition TypeLoc.h:1197
SourceLocation getProtocolLoc(unsigned i) const
Definition TypeLoc.h:1209
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition TypeLoc.h:1233
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition TypeLoc.h:1214
TypeLoc getBaseLoc() const
Definition TypeLoc.h:1237
QualType getInnerType() const
Definition TypeLoc.h:1264
SourceLocation getProtocolLAngleLoc() const
Definition TypeLoc.h:1189
SourceLocation getTypeArgsRAngleLoc() const
Definition TypeLoc.h:1167
Represents an Objective-C protocol declaration.
Definition DeclObjC.h:2084
SourceLocation getLocation() const
Definition TypeLoc.h:2745
ObjCProtocolLoc(ObjCProtocolDecl *protocol, SourceLocation loc)
Definition TypeLoc.h:2742
ObjCProtocolDecl * getProtocol() const
Definition TypeLoc.h:2744
SourceRange getSourceRange() const LLVM_READONLY
The source range is just the protocol name.
Definition TypeLoc.h:2748
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:899
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:968
ObjCTypeParamDecl * getDecl() const
Definition TypeLoc.h:906
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:972
unsigned getNumProtocols() const
Definition TypeLoc.h:936
SourceLocation getNameLoc() const
Definition TypeLoc.h:908
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition TypeLoc.h:950
SourceLocation getProtocolLoc(unsigned i) const
Definition TypeLoc.h:940
ArrayRef< SourceLocation > getProtocolLocs() const
Definition TypeLoc.h:955
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition TypeLoc.h:945
void setProtocolLAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:922
unsigned getExtraLocalDataSize() const
Definition TypeLoc.h:961
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:554
SourceLocation getProtocolLAngleLoc() const
Definition TypeLoc.h:916
void setProtocolRAngleLoc(SourceLocation Loc)
Definition TypeLoc.h:932
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:912
SourceLocation getProtocolRAngleLoc() const
Definition TypeLoc.h:926
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2612
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2608
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2604
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2620
QualType getInnerType() const
Definition TypeLoc.h:2624
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2616
SourceLocation getEllipsisLoc() const
Definition TypeLoc.h:2290
Expr * getIndexExpr() const
Definition TypeLoc.h:2287
TypeLoc getPatternLoc() const
Definition TypeLoc.h:2297
QualType getPattern() const
Definition TypeLoc.h:2288
QualType getInnerType() const
Definition TypeLoc.h:2299
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2301
void setEllipsisLoc(SourceLocation Loc)
Definition TypeLoc.h:2291
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2293
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1390
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1398
SourceLocation getRParenLoc() const
Definition TypeLoc.h:1382
QualType getInnerType() const
Definition TypeLoc.h:1407
SourceLocation getLParenLoc() const
Definition TypeLoc.h:1378
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1394
TypeLoc getInnerLoc() const
Definition TypeLoc.h:1403
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:1386
QualType getInnerType() const
Definition TypeBase.h:3311
Represents a parameter to a function.
Definition Decl.h:1790
TypeLoc getValueLoc() const
Definition TypeLoc.h:2695
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2702
QualType getInnerType() const
Definition TypeLoc.h:2706
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2700
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2697
SourceLocation getKWLoc() const
Definition TypeLoc.h:2699
QualType getElementType() const
Definition TypeBase.h:8119
A base class for.
Definition TypeLoc.h:1459
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:1477
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1473
void setSigilLoc(SourceLocation Loc)
Definition TypeLoc.h:1465
QualType getInnerType() const
Definition TypeLoc.h:1481
TypeLoc getPointeeLoc() const
Definition TypeLoc.h:1469
SourceLocation getSigilLoc() const
Definition TypeLoc.h:1461
Wrapper for source info for pointers.
Definition TypeLoc.h:1488
SourceLocation getStarLoc() const
Definition TypeLoc.h:1490
void setStarLoc(SourceLocation Loc)
Definition TypeLoc.h:1494
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition TypeLoc.h:2759
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2760
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:8290
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:1603
SourceLocation getAmpAmpLoc() const
Definition TypeLoc.h:1599
Represents a struct/union/class.
Definition Decl.h:4312
Wrapper for source info for record types.
Definition TypeLoc.h:855
RecordDecl * getOriginalDecl() const
Definition TypeLoc.h:857
QualType getInnerType() const
Definition TypeLoc.h:1575
QualType getPointeeTypeAsWritten() const
Definition TypeBase.h:3589
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:1002
Abstract type representing delayed type pack expansions.
Definition TypeLoc.h:990
Wrapper for substituted template type parameters.
Definition TypeLoc.h:996
Wrapper for substituted template type parameters.
Definition TypeLoc.h:984
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3717
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
TagDecl * getOriginalDecl() const
Definition TypeLoc.h:796
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:715
SourceLocation getLAngleLoc() const
Definition TypeLoc.h:1882
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition TypeLoc.h:1892
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:1911
SourceLocation getRAngleLoc() const
Definition TypeLoc.h:1897
MutableArrayRef< TemplateArgumentLocInfo > getArgLocInfos()
Definition TypeLoc.h:1888
void set(SourceLocation ElaboratedKeywordLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKeywordLoc, SourceLocation NameLoc, SourceLocation LAngleLoc, SourceLocation RAngleLoc)
Definition TypeLoc.cpp:645
SourceLocation getTemplateNameLoc() const
Definition TypeLoc.h:1880
void copy(TemplateSpecializationTypeLoc Loc)
Definition TypeLoc.h:1900
unsigned getExtraLocalDataAlignment() const
Definition TypeLoc.h:1924
SourceLocation getTemplateKeywordLoc() const
Definition TypeLoc.h:1876
NestedNameSpecifierLoc getQualifierLoc() const
Definition TypeLoc.h:1866
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:689
SourceLocation getElaboratedKeywordLoc() const
Definition TypeLoc.h:1862
unsigned getExtraLocalDataSize() const
Definition TypeLoc.h:1920
Declaration of a template type parameter.
Wrapper for template type parameters.
Definition TypeLoc.h:885
TemplateTypeParmDecl * getDecl() const
Definition TypeLoc.h:887
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:442
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:453
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:474
friend bool operator==(const TypeLoc &LHS, const TypeLoc &RHS)
Definition TypeLoc.h:234
TypeLoc IgnoreParens() const
Definition TypeLoc.h:1412
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:497
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:880
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:887
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:2710
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:313
Expr * getUnderlyingExpr() const
Definition TypeLoc.h:2219
Expr * getUnderlyingExpr() const
Definition TypeBase.h:6188
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:602
void setUnmodifiedTInfo(TypeSourceInfo *TI) const
Definition TypeLoc.h:2240
TypeSourceInfo * getUnmodifiedTInfo() const
Definition TypeLoc.h:2236
QualType getUnmodifiedType() const
Definition TypeLoc.h:2232
A container of type source information.
Definition TypeBase.h:8261
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:752
TypeClass getTypeClass() const
Definition TypeBase.h:2385
Wrapper for source info for typedefs.
Definition TypeLoc.h:777
void setParensRange(SourceRange range)
Definition TypeLoc.h:2199
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2204
SourceLocation getLParenLoc() const
Definition TypeLoc.h:2179
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2187
SourceRange getParensRange() const
Definition TypeLoc.h:2195
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2183
SourceLocation getTypeofLoc() const
Definition TypeLoc.h:2171
void setTypeofLoc(SourceLocation Loc)
Definition TypeLoc.h:2175
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2191
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2208
void setRParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2325
void setParensRange(SourceRange Range)
Definition TypeLoc.h:2343
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.cpp:610
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2335
void setKWLoc(SourceLocation Loc)
Definition TypeLoc.h:2319
SourceLocation getKWLoc() const
Definition TypeLoc.h:2318
SourceLocation getRParenLoc() const
Definition TypeLoc.h:2324
TypeSourceInfo * getUnderlyingTInfo() const
Definition TypeLoc.h:2327
SourceRange getParensRange() const
Definition TypeLoc.h:2339
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition TypeLoc.h:2331
void setLParenLoc(SourceLocation Loc)
Definition TypeLoc.h:2322
SourceLocation getLParenLoc() const
Definition TypeLoc.h:2321
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:4037
Wrapper for source info for types used via transparent aliases.
Definition TypeLoc.h:785
TypeLoc getElementLoc() const
Definition TypeLoc.h:2030
void setNameLoc(SourceLocation Loc)
Definition TypeLoc.h:2020
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition TypeLoc.h:2026
SourceRange getLocalSourceRange() const
Definition TypeLoc.h:2022
QualType getInnerType() const
Definition TypeLoc.h:2032
SourceLocation getNameLoc() const
Definition TypeLoc.h:2018
QualType getElementType() const
Definition TypeBase.h:4189
#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:560
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:5865
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5886
@ 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:1744
SourceLocation RBracketLoc
Definition TypeLoc.h:1744
SourceLocation KWLoc
Definition TypeLoc.h:2630
SourceLocation RParenLoc
Definition TypeLoc.h:2630
SourceLocation LParenLoc
Definition TypeLoc.h:2630
const Attr * TypeAttr
Definition TypeLoc.h:1005
ConceptReference * CR
Definition TypeLoc.h:2359
SourceLocation RParenLoc
Definition TypeLoc.h:2357
SourceRange BuiltinRange
Definition TypeLoc.h:570
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation RParenLoc
Definition TypeLoc.h:2254
SourceLocation DecltypeLoc
Definition TypeLoc.h:2253
void * QualifierData
Data associated with the nested-name-specifier location.
Definition TypeLoc.h:2475
SourceLocation ElaboratedKWLoc
Definition TypeLoc.h:2535
void * QualifierData
Data associated with the nested-name-specifier location.
Definition TypeLoc.h:2538
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:1610
SourceLocation RParenLoc
Definition TypeLoc.h:1611
SourceLocation LocalRangeEnd
Definition TypeLoc.h:1612
SourceLocation LocalRangeBegin
Definition TypeLoc.h:1609
SourceLocation ExpansionLoc
Definition TypeLoc.h:1337
SourceLocation AttrLoc
Definition TypeLoc.h:2087
SourceRange OperandParens
Definition TypeLoc.h:2088
SourceLocation NameEndLoc
Definition TypeLoc.h:1271
SourceLocation TypeArgsLAngleLoc
Definition TypeLoc.h:1131
SourceLocation ProtocolLAngleLoc
Definition TypeLoc.h:1133
SourceLocation TypeArgsRAngleLoc
Definition TypeLoc.h:1132
SourceLocation ProtocolRAngleLoc
Definition TypeLoc.h:1134
SourceLocation LParenLoc
Definition TypeLoc.h:1370
SourceLocation RParenLoc
Definition TypeLoc.h:1371
SourceLocation KWLoc
Definition TypeLoc.h:2689
SourceLocation StarLoc
Definition TypeLoc.h:1453
SourceLocation NameLoc
Definition TypeLoc.h:788
SourceLocation ElaboratedKWLoc
Definition TypeLoc.h:789
Location information for a TemplateArgument.
SourceLocation NameLoc
Definition TypeLoc.h:1835
TypeSourceInfo * UnmodifiedTInfo
Definition TypeLoc.h:2164
SourceLocation NameLoc
Definition TypeLoc.h:532
SourceLocation RParenLoc
Definition TypeLoc.h:2157
SourceLocation LParenLoc
Definition TypeLoc.h:2156
SourceLocation TypeofLoc
Definition TypeLoc.h:2155
TypeSourceInfo * UnderlyingTInfo
Definition TypeLoc.h:2310
SourceLocation NameLoc
Definition TypeLoc.h:2012
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition Specifiers.h:109