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