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 size = llvm::alignTo(size, asDerived()->getLocalDataAlignment());
401 return size;
402 }
403
404 void copyLocal(Derived other) {
405 // Some subclasses have no data to copy.
406 if (asDerived()->getLocalDataSize() == 0) return;
407
408 // Copy the fixed-sized local data.
409 memcpy(getLocalData(), other.getLocalData(), sizeof(LocalData));
410
411 // Copy the variable-sized local data. We need to do this
412 // separately because the padding in the source and the padding in
413 // the destination might be different.
414 memcpy(getExtraLocalData(), other.getExtraLocalData(),
415 asDerived()->getExtraLocalDataSize());
416 }
417
419 return getNextTypeLoc(asDerived()->getInnerType());
420 }
421
422 const TypeClass *getTypePtr() const {
423 return cast<TypeClass>(Base::getTypePtr());
424 }
425
426protected:
427 unsigned getExtraLocalDataSize() const {
428 return 0;
429 }
430
431 unsigned getExtraLocalDataAlignment() const {
432 return 1;
433 }
434
435 LocalData *getLocalData() const {
436 return static_cast<LocalData*>(Base::Data);
437 }
438
439 /// Gets a pointer past the Info structure; useful for classes with
440 /// local data that can't be captured in the Info (e.g. because it's
441 /// of variable size).
442 void *getExtraLocalData() const {
443 unsigned size = sizeof(LocalData);
444 unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
445 size = llvm::alignTo(size, extraAlign);
446 return reinterpret_cast<char *>(Base::Data) + size;
447 }
448
449 void *getNonLocalData() const {
450 auto data = reinterpret_cast<uintptr_t>(Base::Data);
451 data += asDerived()->getLocalDataSize();
452 data = llvm::alignTo(data, getNextTypeAlign());
453 return reinterpret_cast<void*>(data);
454 }
455
456 struct HasNoInnerType {};
458
460 return TypeLoc(asDerived()->getInnerType(), getNonLocalData());
461 }
462
463private:
464 unsigned getInnerTypeSize() const {
465 return getInnerTypeSize(asDerived()->getInnerType());
466 }
467
468 unsigned getInnerTypeSize(HasNoInnerType _) const {
469 return 0;
470 }
471
472 unsigned getInnerTypeSize(QualType _) const {
474 }
475
476 unsigned getNextTypeAlign() const {
477 return getNextTypeAlign(asDerived()->getInnerType());
478 }
479
480 unsigned getNextTypeAlign(HasNoInnerType _) const {
481 return 1;
482 }
483
484 unsigned getNextTypeAlign(QualType T) const {
486 }
487
488 TypeLoc getNextTypeLoc(HasNoInnerType _) const { return {}; }
489
490 TypeLoc getNextTypeLoc(QualType T) const {
491 return TypeLoc(T, getNonLocalData());
492 }
493};
494
495/// A metaprogramming class designed for concrete subtypes of abstract
496/// types where all subtypes share equivalently-structured source
497/// information. See the note on ConcreteTypeLoc.
498template <class Base, class Derived, class TypeClass>
500 friend class TypeLoc;
501
502 static bool classofType(const Type *Ty) {
503 return TypeClass::classof(Ty);
504 }
505
506 static bool isKind(const TypeLoc &TL) {
507 return !TL.getType().hasLocalQualifiers() &&
508 Derived::classofType(TL.getTypePtr());
509 }
510 static bool isKind(const UnqualTypeLoc &TL) {
511 return Derived::classofType(TL.getTypePtr());
512 }
513
514public:
515 const TypeClass *getTypePtr() const {
516 return cast<TypeClass>(Base::getTypePtr());
517 }
518};
519
522};
523
524/// A reasonable base class for TypeLocs that correspond to
525/// types that are written as a type-specifier.
526class TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
527 TypeSpecTypeLoc,
528 Type,
529 TypeSpecLocInfo> {
530public:
531 enum {
534 };
535
537 return this->getLocalData()->NameLoc;
538 }
539
541 this->getLocalData()->NameLoc = Loc;
542 }
543
545 return SourceRange(getNameLoc(), getNameLoc());
546 }
547
550 }
551
552private:
553 friend class TypeLoc;
554
555 static bool isKind(const TypeLoc &TL);
556};
557
560};
561
562/// Wrapper for source info for builtin types.
563class BuiltinTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
564 BuiltinTypeLoc,
565 BuiltinType,
566 BuiltinLocInfo> {
567public:
570 }
571
574 }
575
577 SourceRange &BuiltinRange = getLocalData()->BuiltinRange;
578 if (!BuiltinRange.getBegin().isValid()) {
579 BuiltinRange = Range;
580 } else {
581 BuiltinRange.setBegin(std::min(Range.getBegin(), BuiltinRange.getBegin()));
582 BuiltinRange.setEnd(std::max(Range.getEnd(), BuiltinRange.getEnd()));
583 }
584 }
585
587
589 return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
590 }
592 return *(static_cast<WrittenBuiltinSpecs*>(getExtraLocalData()));
593 }
594
595 bool needsExtraLocalData() const {
597 return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) ||
598 (bk >= BuiltinType::Short && bk <= BuiltinType::Ibm128) ||
599 bk == BuiltinType::UChar || bk == BuiltinType::SChar;
600 }
601
602 unsigned getExtraLocalDataSize() const {
603 return needsExtraLocalData() ? sizeof(WrittenBuiltinSpecs) : 0;
604 }
605
606 unsigned getExtraLocalDataAlignment() const {
607 return needsExtraLocalData() ? alignof(WrittenBuiltinSpecs) : 1;
608 }
609
611 return getLocalData()->BuiltinRange;
612 }
613
616 return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign);
617 else
619 }
620
621 bool hasWrittenSignSpec() const {
623 }
624
627 getWrittenBuiltinSpecs().Sign = static_cast<unsigned>(written);
628 }
629
632 return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width);
633 else
635 }
636
637 bool hasWrittenWidthSpec() const {
639 }
640
643 getWrittenBuiltinSpecs().Width = static_cast<unsigned>(written);
644 }
645
647
648 bool hasWrittenTypeSpec() const {
650 }
651
654 getWrittenBuiltinSpecs().Type = written;
655 }
656
657 bool hasModeAttr() const {
660 else
661 return false;
662 }
663
664 void setModeAttr(bool written) {
667 }
668
671 if (needsExtraLocalData()) {
673 wbs.Sign = static_cast<unsigned>(TypeSpecifierSign::Unspecified);
674 wbs.Width = static_cast<unsigned>(TypeSpecifierWidth::Unspecified);
675 wbs.Type = TST_unspecified;
676 wbs.ModeAttr = false;
677 }
678 }
679};
680
681/// Wrapper for source info for types used via transparent aliases.
682class UsingTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
683 UsingTypeLoc, UsingType> {
684public:
686 return getTypePtr()->getUnderlyingType();
687 }
689};
690
691/// Wrapper for source info for typedefs.
692class TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
693 TypedefTypeLoc,
694 TypedefType> {
695public:
697 return getTypePtr()->getDecl();
698 }
699};
700
701/// Wrapper for source info for injected class names of class
702/// templates.
704 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
705 InjectedClassNameTypeLoc,
706 InjectedClassNameType> {
707public:
709 return getTypePtr()->getDecl();
710 }
711};
712
713/// Wrapper for source info for unresolved typename using decls.
715 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
716 UnresolvedUsingTypeLoc,
717 UnresolvedUsingType> {
718public:
720 return getTypePtr()->getDecl();
721 }
722};
723
724/// Wrapper for source info for tag types. Note that this only
725/// records source info for the name itself; a type written 'struct foo'
726/// should be represented as an ElaboratedTypeLoc. We currently
727/// only do that when C++ is enabled because of the expense of
728/// creating an ElaboratedType node for so many type references in C.
729class TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
730 TagTypeLoc,
731 TagType> {
732public:
733 TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
734
735 /// True if the tag was defined in this type specifier.
736 bool isDefinition() const;
737};
738
739/// Wrapper for source info for record types.
740class RecordTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
741 RecordTypeLoc,
742 RecordType> {
743public:
744 RecordDecl *getDecl() const { return getTypePtr()->getDecl(); }
745};
746
747/// Wrapper for source info for enum types.
748class EnumTypeLoc : public InheritingConcreteTypeLoc<TagTypeLoc,
749 EnumTypeLoc,
750 EnumType> {
751public:
752 EnumDecl *getDecl() const { return getTypePtr()->getDecl(); }
753};
754
755/// Wrapper for template type parameters.
757 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
758 TemplateTypeParmTypeLoc,
759 TemplateTypeParmType> {
760public:
762};
763
766};
767
768/// ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for
769/// protocol qualifiers are stored after Info.
770class ObjCTypeParamTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
771 ObjCTypeParamTypeLoc,
772 ObjCTypeParamType,
773 ObjCTypeParamTypeLocInfo> {
774 // SourceLocations are stored after Info, one for each protocol qualifier.
775 SourceLocation *getProtocolLocArray() const {
776 return (SourceLocation*)this->getExtraLocalData() + 2;
777 }
778
779public:
780 ObjCTypeParamDecl *getDecl() const { return getTypePtr()->getDecl(); }
781
783 return this->getLocalData()->NameLoc;
784 }
785
787 this->getLocalData()->NameLoc = Loc;
788 }
789
791 return getNumProtocols() ?
792 *((SourceLocation*)this->getExtraLocalData()) :
794 }
795
797 *((SourceLocation*)this->getExtraLocalData()) = Loc;
798 }
799
801 return getNumProtocols() ?
802 *((SourceLocation*)this->getExtraLocalData() + 1) :
804 }
805
807 *((SourceLocation*)this->getExtraLocalData() + 1) = Loc;
808 }
809
810 unsigned getNumProtocols() const {
811 return this->getTypePtr()->getNumProtocols();
812 }
813
814 SourceLocation getProtocolLoc(unsigned i) const {
815 assert(i < getNumProtocols() && "Index is out of bounds!");
816 return getProtocolLocArray()[i];
817 }
818
820 assert(i < getNumProtocols() && "Index is out of bounds!");
821 getProtocolLocArray()[i] = Loc;
822 }
823
824 ObjCProtocolDecl *getProtocol(unsigned i) const {
825 assert(i < getNumProtocols() && "Index is out of bounds!");
826 return *(this->getTypePtr()->qual_begin() + i);
827 }
828
830 return llvm::ArrayRef(getProtocolLocArray(), getNumProtocols());
831 }
832
834
835 unsigned getExtraLocalDataSize() const {
836 if (!this->getNumProtocols()) return 0;
837 // When there are protocol qualifers, we have LAngleLoc and RAngleLoc
838 // as well.
839 return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ;
840 }
841
842 unsigned getExtraLocalDataAlignment() const {
843 return alignof(SourceLocation);
844 }
845
847 SourceLocation start = getNameLoc();
849 if (end.isInvalid()) return SourceRange(start, start);
850 return SourceRange(start, end);
851 }
852};
853
854/// Wrapper for substituted template type parameters.
856 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
857 SubstTemplateTypeParmTypeLoc,
858 SubstTemplateTypeParmType> {
859};
860
861 /// Wrapper for substituted template type parameters.
863 public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
864 SubstTemplateTypeParmPackTypeLoc,
865 SubstTemplateTypeParmPackType> {
866};
867
870};
871
872/// Type source information for an attributed type.
873class AttributedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
874 AttributedTypeLoc,
875 AttributedType,
876 AttributedLocInfo> {
877public:
879 return getTypePtr()->getAttrKind();
880 }
881
882 bool isQualifier() const {
883 return getTypePtr()->isQualifier();
884 }
885
886 /// The modified type, which is generally canonically different from
887 /// the attribute type.
888 /// int main(int, char**) __attribute__((noreturn))
889 /// ~~~ ~~~~~~~~~~~~~
891 return getInnerTypeLoc();
892 }
893
895 return TypeLoc(getTypePtr()->getEquivalentType(), getNonLocalData());
896 }
897
898 /// The type attribute.
899 const Attr *getAttr() const {
900 return getLocalData()->TypeAttr;
901 }
902 void setAttr(const Attr *A) {
903 getLocalData()->TypeAttr = A;
904 }
905
906 template<typename T> const T *getAttrAs() {
907 return dyn_cast_or_null<T>(getAttr());
908 }
909
911
913 setAttr(nullptr);
914 }
915
917 return getTypePtr()->getModifiedType();
918 }
919};
920
921struct BTFTagAttributedLocInfo {}; // Nothing.
922
923/// Type source information for an btf_tag attributed type.
925 : public ConcreteTypeLoc<UnqualTypeLoc, BTFTagAttributedTypeLoc,
926 BTFTagAttributedType, BTFTagAttributedLocInfo> {
927public:
929
930 /// The btf_type_tag attribute.
931 const BTFTypeTagAttr *getAttr() const { return getTypePtr()->getAttr(); }
932
933 template <typename T> T *getAttrAs() {
934 return dyn_cast_or_null<T>(getAttr());
935 }
936
938
940
942};
943
947};
948
949/// Type source information for HLSL attributed resource type.
951 : public ConcreteTypeLoc<UnqualTypeLoc, HLSLAttributedResourceTypeLoc,
952 HLSLAttributedResourceType,
953 HLSLAttributedResourceLocInfo> {
954public:
956
959 }
962 }
963
964 void setSourceRange(const SourceRange &R) { getLocalData()->Range = R; }
968 }
970 unsigned getLocalDataSize() const {
971 return sizeof(HLSLAttributedResourceLocInfo);
972 }
973};
974
981};
982
983// A helper class for defining ObjC TypeLocs that can qualified with
984// protocols.
985//
986// TypeClass basically has to be either ObjCInterfaceType or
987// ObjCObjectPointerType.
988class ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
989 ObjCObjectTypeLoc,
990 ObjCObjectType,
991 ObjCObjectTypeLocInfo> {
992 // TypeSourceInfo*'s are stored after Info, one for each type argument.
993 TypeSourceInfo **getTypeArgLocArray() const {
994 return (TypeSourceInfo**)this->getExtraLocalData();
995 }
996
997 // SourceLocations are stored after the type argument information, one for
998 // each Protocol.
999 SourceLocation *getProtocolLocArray() const {
1000 return (SourceLocation*)(getTypeArgLocArray() + getNumTypeArgs());
1001 }
1002
1003public:
1005 return this->getLocalData()->TypeArgsLAngleLoc;
1006 }
1007
1010 }
1011
1013 return this->getLocalData()->TypeArgsRAngleLoc;
1014 }
1015
1018 }
1019
1020 unsigned getNumTypeArgs() const {
1021 return this->getTypePtr()->getTypeArgsAsWritten().size();
1022 }
1023
1024 TypeSourceInfo *getTypeArgTInfo(unsigned i) const {
1025 assert(i < getNumTypeArgs() && "Index is out of bounds!");
1026 return getTypeArgLocArray()[i];
1027 }
1028
1029 void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo) {
1030 assert(i < getNumTypeArgs() && "Index is out of bounds!");
1031 getTypeArgLocArray()[i] = TInfo;
1032 }
1033
1035 return this->getLocalData()->ProtocolLAngleLoc;
1036 }
1037
1040 }
1041
1043 return this->getLocalData()->ProtocolRAngleLoc;
1044 }
1045
1048 }
1049
1050 unsigned getNumProtocols() const {
1051 return this->getTypePtr()->getNumProtocols();
1052 }
1053
1054 SourceLocation getProtocolLoc(unsigned i) const {
1055 assert(i < getNumProtocols() && "Index is out of bounds!");
1056 return getProtocolLocArray()[i];
1057 }
1058
1060 assert(i < getNumProtocols() && "Index is out of bounds!");
1061 getProtocolLocArray()[i] = Loc;
1062 }
1063
1064 ObjCProtocolDecl *getProtocol(unsigned i) const {
1065 assert(i < getNumProtocols() && "Index is out of bounds!");
1066 return *(this->getTypePtr()->qual_begin() + i);
1067 }
1068
1069
1071 return llvm::ArrayRef(getProtocolLocArray(), getNumProtocols());
1072 }
1073
1076 }
1077
1078 void setHasBaseTypeAsWritten(bool HasBaseType) {
1079 getLocalData()->HasBaseTypeAsWritten = HasBaseType;
1080 }
1081
1083 return getInnerTypeLoc();
1084 }
1085
1088 if (start.isInvalid())
1089 start = getProtocolLAngleLoc();
1091 if (end.isInvalid())
1092 end = getTypeArgsRAngleLoc();
1093 return SourceRange(start, end);
1094 }
1095
1097
1098 unsigned getExtraLocalDataSize() const {
1099 return this->getNumTypeArgs() * sizeof(TypeSourceInfo *)
1100 + this->getNumProtocols() * sizeof(SourceLocation);
1101 }
1102
1104 static_assert(alignof(ObjCObjectTypeLoc) >= alignof(TypeSourceInfo *),
1105 "not enough alignment for tail-allocated data");
1106 return alignof(TypeSourceInfo *);
1107 }
1108
1110 return getTypePtr()->getBaseType();
1111 }
1112};
1113
1117};
1118
1119/// Wrapper for source info for ObjC interfaces.
1120class ObjCInterfaceTypeLoc : public ConcreteTypeLoc<ObjCObjectTypeLoc,
1121 ObjCInterfaceTypeLoc,
1122 ObjCInterfaceType,
1123 ObjCInterfaceLocInfo> {
1124public:
1126 return getTypePtr()->getDecl();
1127 }
1128
1130 return getLocalData()->NameLoc;
1131 }
1132
1135 }
1136
1139 }
1140
1142 return getLocalData()->NameEndLoc;
1143 }
1144
1147 }
1148
1150 setNameLoc(Loc);
1152 }
1153};
1154
1157 : public ConcreteTypeLoc<UnqualTypeLoc, BoundsAttributedTypeLoc,
1158 BoundsAttributedType, BoundsAttributedLocInfo> {
1159public:
1161 QualType getInnerType() const { return getTypePtr()->desugar(); }
1163 // nothing to do
1164 }
1165 // LocalData is empty and TypeLocBuilder doesn't handle DataSize 1.
1166 unsigned getLocalDataSize() const { return 0; }
1167};
1168
1170 : public InheritingConcreteTypeLoc<BoundsAttributedTypeLoc,
1171 CountAttributedTypeLoc,
1172 CountAttributedType> {
1173public:
1174 Expr *getCountExpr() const { return getTypePtr()->getCountExpr(); }
1175 bool isCountInBytes() const { return getTypePtr()->isCountInBytes(); }
1176 bool isOrNull() const { return getTypePtr()->isOrNull(); }
1177
1179};
1180
1183};
1184
1186 : public ConcreteTypeLoc<UnqualTypeLoc, MacroQualifiedTypeLoc,
1187 MacroQualifiedType, MacroQualifiedLocInfo> {
1188public:
1191 }
1192
1194
1196 return getTypePtr()->getMacroIdentifier();
1197 }
1198
1200 return this->getLocalData()->ExpansionLoc;
1201 }
1202
1204 this->getLocalData()->ExpansionLoc = Loc;
1205 }
1206
1208
1211 }
1212};
1213
1217};
1218
1220 : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
1221 ParenLocInfo> {
1222public:
1224 return this->getLocalData()->LParenLoc;
1225 }
1226
1228 return this->getLocalData()->RParenLoc;
1229 }
1230
1232 this->getLocalData()->LParenLoc = Loc;
1233 }
1234
1236 this->getLocalData()->RParenLoc = Loc;
1237 }
1238
1241 }
1242
1246 }
1247
1249 return getInnerTypeLoc();
1250 }
1251
1253 return this->getTypePtr()->getInnerType();
1254 }
1255};
1256
1258 if (ParenTypeLoc::isKind(*this))
1259 return IgnoreParensImpl(*this);
1260 return *this;
1261}
1262
1263struct AdjustedLocInfo {}; // Nothing.
1264
1265class AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc,
1266 AdjustedType, AdjustedLocInfo> {
1267public:
1269 return getInnerTypeLoc();
1270 }
1271
1273 // do nothing
1274 }
1275
1277 // The inner type is the undecayed type, since that's what we have source
1278 // location information for.
1279 return getTypePtr()->getOriginalType();
1280 }
1281
1282 SourceRange getLocalSourceRange() const { return {}; }
1283
1284 unsigned getLocalDataSize() const {
1285 // sizeof(AdjustedLocInfo) is 1, but we don't need its address to be unique
1286 // anyway. TypeLocBuilder can't handle data sizes of 1.
1287 return 0; // No data.
1288 }
1289};
1290
1291/// Wrapper for source info for pointers decayed from arrays and
1292/// functions.
1294 AdjustedTypeLoc, DecayedTypeLoc, DecayedType> {
1295};
1296
1299};
1300
1301/// A base class for
1302template <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
1303class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
1304 TypeClass, LocalData> {
1305public:
1307 return this->getLocalData()->StarLoc;
1308 }
1309
1311 this->getLocalData()->StarLoc = Loc;
1312 }
1313
1315 return this->getInnerTypeLoc();
1316 }
1317
1319 return SourceRange(getSigilLoc(), getSigilLoc());
1320 }
1321
1324 }
1325
1327 return this->getTypePtr()->getPointeeType();
1328 }
1329};
1330
1331/// Wrapper for source info for pointers.
1332class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
1333 PointerType> {
1334public:
1336 return getSigilLoc();
1337 }
1338
1341 }
1342};
1343
1344/// Wrapper for source info for block pointers.
1345class BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
1346 BlockPointerType> {
1347public:
1349 return getSigilLoc();
1350 }
1351
1354 }
1355};
1356
1359};
1360
1361/// Wrapper for source info for member pointers.
1362class MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
1363 MemberPointerType,
1364 MemberPointerLocInfo> {
1365public:
1367 return getSigilLoc();
1368 }
1369
1372 }
1373
1374 const Type *getClass() const {
1375 return getTypePtr()->getClass();
1376 }
1377
1379 return getLocalData()->ClassTInfo;
1380 }
1381
1383 getLocalData()->ClassTInfo = TI;
1384 }
1385
1388 setClassTInfo(nullptr);
1389 }
1390
1392 if (TypeSourceInfo *TI = getClassTInfo())
1393 return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc());
1394 else
1395 return SourceRange(getStarLoc());
1396 }
1397};
1398
1399/// Wraps an ObjCPointerType with source location information.
1401 public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
1402 ObjCObjectPointerType> {
1403public:
1405 return getSigilLoc();
1406 }
1407
1410 }
1411};
1412
1413class ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
1414 ReferenceType> {
1415public:
1417 return getTypePtr()->getPointeeTypeAsWritten();
1418 }
1419};
1420
1422 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1423 LValueReferenceTypeLoc,
1424 LValueReferenceType> {
1425public:
1427 return getSigilLoc();
1428 }
1429
1432 }
1433};
1434
1436 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1437 RValueReferenceTypeLoc,
1438 RValueReferenceType> {
1439public:
1441 return getSigilLoc();
1442 }
1443
1446 }
1447};
1448
1454};
1455
1456/// Wrapper for source info for functions.
1457class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1458 FunctionTypeLoc,
1459 FunctionType,
1460 FunctionLocInfo> {
1461 bool hasExceptionSpec() const {
1462 if (auto *FPT = dyn_cast<FunctionProtoType>(getTypePtr())) {
1463 return FPT->hasExceptionSpec();
1464 }
1465 return false;
1466 }
1467
1468 SourceRange *getExceptionSpecRangePtr() const {
1469 assert(hasExceptionSpec() && "No exception spec range");
1470 // After the Info comes the ParmVarDecl array, and after that comes the
1471 // exception specification information.
1472 return (SourceRange *)(getParmArray() + getNumParams());
1473 }
1474
1475public:
1477 return getLocalData()->LocalRangeBegin;
1478 }
1479
1482 }
1483
1485 return getLocalData()->LocalRangeEnd;
1486 }
1487
1490 }
1491
1493 return this->getLocalData()->LParenLoc;
1494 }
1495
1497 this->getLocalData()->LParenLoc = Loc;
1498 }
1499
1501 return this->getLocalData()->RParenLoc;
1502 }
1503
1505 this->getLocalData()->RParenLoc = Loc;
1506 }
1507
1510 }
1511
1513 if (hasExceptionSpec())
1514 return *getExceptionSpecRangePtr();
1515 return {};
1516 }
1517
1519 if (hasExceptionSpec())
1520 *getExceptionSpecRangePtr() = R;
1521 }
1522
1525 }
1526
1527 // ParmVarDecls* are stored after Info, one for each parameter.
1529 return (ParmVarDecl**) getExtraLocalData();
1530 }
1531
1532 unsigned getNumParams() const {
1533 if (isa<FunctionNoProtoType>(getTypePtr()))
1534 return 0;
1535 return cast<FunctionProtoType>(getTypePtr())->getNumParams();
1536 }
1537
1538 ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; }
1539 void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1540
1542 return getInnerTypeLoc();
1543 }
1544
1547 }
1548
1554 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
1555 setParam(i, nullptr);
1556 if (hasExceptionSpec())
1558 }
1559
1560 /// Returns the size of the type source info data block that is
1561 /// specific to this type.
1562 unsigned getExtraLocalDataSize() const {
1563 unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
1564 return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
1565 }
1566
1567 unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); }
1568
1570};
1571
1573 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1574 FunctionProtoTypeLoc,
1575 FunctionProtoType> {
1576};
1577
1579 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1580 FunctionNoProtoTypeLoc,
1581 FunctionNoProtoType> {
1582};
1583
1587};
1588
1589/// Wrapper for source info for arrays.
1590class ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1591 ArrayTypeLoc,
1592 ArrayType,
1593 ArrayLocInfo> {
1594public:
1596 return getLocalData()->LBracketLoc;
1597 }
1598
1601 }
1602
1604 return getLocalData()->RBracketLoc;
1605 }
1606
1609 }
1610
1613 }
1614
1616 return getLocalData()->Size;
1617 }
1618
1619 void setSizeExpr(Expr *Size) {
1620 getLocalData()->Size = Size;
1621 }
1622
1624 return getInnerTypeLoc();
1625 }
1626
1629 }
1630
1634 setSizeExpr(nullptr);
1635 }
1636
1638};
1639
1641 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1642 ConstantArrayTypeLoc,
1643 ConstantArrayType> {
1644};
1645
1646/// Wrapper for source info for array parameter types.
1649 ConstantArrayTypeLoc, ArrayParameterTypeLoc, ArrayParameterType> {};
1650
1652 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1653 IncompleteArrayTypeLoc,
1654 IncompleteArrayType> {
1655};
1656
1658 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1659 DependentSizedArrayTypeLoc,
1660 DependentSizedArrayType> {
1661public:
1665 }
1666};
1667
1669 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1670 VariableArrayTypeLoc,
1671 VariableArrayType> {
1672};
1673
1674// Location information for a TemplateName. Rudimentary for now.
1677};
1678
1683};
1684
1686 public ConcreteTypeLoc<UnqualTypeLoc,
1687 TemplateSpecializationTypeLoc,
1688 TemplateSpecializationType,
1689 TemplateSpecializationLocInfo> {
1690public:
1692 return getLocalData()->TemplateKWLoc;
1693 }
1694
1697 }
1698
1700 return getLocalData()->LAngleLoc;
1701 }
1702
1705 }
1706
1708 return getLocalData()->RAngleLoc;
1709 }
1710
1713 }
1714
1715 unsigned getNumArgs() const {
1716 return getTypePtr()->template_arguments().size();
1717 }
1718
1720 getArgInfos()[i] = AI;
1721 }
1722
1724 return getArgInfos()[i];
1725 }
1726
1727 TemplateArgumentLoc getArgLoc(unsigned i) const {
1728 return TemplateArgumentLoc(getTypePtr()->template_arguments()[i],
1729 getArgLocInfo(i));
1730 }
1731
1733 return getLocalData()->NameLoc;
1734 }
1735
1738 }
1739
1740 /// - Copy the location information from the given info.
1742 unsigned size = getFullDataSize();
1743 assert(size == Loc.getFullDataSize());
1744
1745 // We're potentially copying Expr references here. We don't
1746 // bother retaining them because TypeSourceInfos live forever, so
1747 // as long as the Expr was retained when originally written into
1748 // the TypeLoc, we're okay.
1749 memcpy(Data, Loc.Data, size);
1750 }
1751
1753 if (getTemplateKeywordLoc().isValid())
1755 else
1757 }
1758
1764 initializeArgLocs(Context, getTypePtr()->template_arguments(),
1765 getArgInfos(), Loc);
1766 }
1767
1768 static void initializeArgLocs(ASTContext &Context,
1770 TemplateArgumentLocInfo *ArgInfos,
1772
1773 unsigned getExtraLocalDataSize() const {
1774 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1775 }
1776
1778 return alignof(TemplateArgumentLocInfo);
1779 }
1780
1781private:
1782 TemplateArgumentLocInfo *getArgInfos() const {
1783 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1784 }
1785};
1786
1791};
1792
1794 : public ConcreteTypeLoc<UnqualTypeLoc,
1795 DependentAddressSpaceTypeLoc,
1796 DependentAddressSpaceType,
1797 DependentAddressSpaceLocInfo> {
1798public:
1799 /// The location of the attribute name, i.e.
1800 /// int * __attribute__((address_space(11)))
1801 /// ^~~~~~~~~~~~~
1803 return getLocalData()->AttrLoc;
1804 }
1806 getLocalData()->AttrLoc = loc;
1807 }
1808
1809 /// The attribute's expression operand, if it has one.
1810 /// int * __attribute__((address_space(11)))
1811 /// ^~
1813 return getLocalData()->ExprOperand;
1814 }
1817 }
1818
1819 /// The location of the parentheses around the operand, if there is
1820 /// an operand.
1821 /// int * __attribute__((address_space(11)))
1822 /// ^ ^
1824 return getLocalData()->OperandParens;
1825 }
1827 getLocalData()->OperandParens = range;
1828 }
1829
1831 SourceRange range(getAttrNameLoc());
1832 range.setEnd(getAttrOperandParensRange().getEnd());
1833 return range;
1834 }
1835
1836 /// Returns the type before the address space attribute application
1837 /// area.
1838 /// int * __attribute__((address_space(11))) *
1839 /// ^ ^
1841 return this->getTypePtr()->getPointeeType();
1842 }
1843
1845 return this->getInnerTypeLoc();
1846 }
1847
1849 setAttrNameLoc(loc);
1852 setAttrExprOperand(getTypePtr()->getAddrSpaceExpr());
1853 }
1854};
1855
1856//===----------------------------------------------------------------------===//
1857//
1858// All of these need proper implementations.
1859//
1860//===----------------------------------------------------------------------===//
1861
1862// FIXME: size expression and attribute locations (or keyword if we
1863// ever fully support altivec syntax).
1866};
1867
1868class VectorTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, VectorTypeLoc,
1869 VectorType, VectorTypeLocInfo> {
1870public:
1871 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1872
1874
1876 return SourceRange(getNameLoc(), getNameLoc());
1877 }
1878
1880 setNameLoc(Loc);
1881 }
1882
1884
1885 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1886};
1887
1888// FIXME: size expression and attribute locations (or keyword if we
1889// ever fully support altivec syntax).
1891 : public ConcreteTypeLoc<UnqualTypeLoc, DependentVectorTypeLoc,
1892 DependentVectorType, VectorTypeLocInfo> {
1893public:
1894 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1895
1897
1899 return SourceRange(getNameLoc(), getNameLoc());
1900 }
1901
1903 setNameLoc(Loc);
1904 }
1905
1907
1908 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1909};
1910
1911// FIXME: size expression and attribute locations.
1913 : public InheritingConcreteTypeLoc<VectorTypeLoc, ExtVectorTypeLoc,
1914 ExtVectorType> {};
1915
1916// FIXME: attribute locations.
1917// For some reason, this isn't a subtype of VectorType.
1919 : public ConcreteTypeLoc<UnqualTypeLoc, DependentSizedExtVectorTypeLoc,
1920 DependentSizedExtVectorType, VectorTypeLocInfo> {
1921public:
1922 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1923
1925
1927 return SourceRange(getNameLoc(), getNameLoc());
1928 }
1929
1931 setNameLoc(Loc);
1932 }
1933
1935
1936 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1937};
1938
1944};
1945
1946class MatrixTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, MatrixTypeLoc,
1947 MatrixType, MatrixTypeLocInfo> {
1948public:
1949 /// The location of the attribute name, i.e.
1950 /// float __attribute__((matrix_type(4, 2)))
1951 /// ^~~~~~~~~~~~~~~~~
1954
1955 /// The attribute's row operand, if it has one.
1956 /// float __attribute__((matrix_type(4, 2)))
1957 /// ^
1960
1961 /// The attribute's column operand, if it has one.
1962 /// float __attribute__((matrix_type(4, 2)))
1963 /// ^
1966
1967 /// The location of the parentheses around the operand, if there is
1968 /// an operand.
1969 /// float __attribute__((matrix_type(4, 2)))
1970 /// ^ ^
1972 return getLocalData()->OperandParens;
1973 }
1975 getLocalData()->OperandParens = range;
1976 }
1977
1979 SourceRange range(getAttrNameLoc());
1980 range.setEnd(getAttrOperandParensRange().getEnd());
1981 return range;
1982 }
1983
1985 setAttrNameLoc(loc);
1987 setAttrRowOperand(nullptr);
1988 setAttrColumnOperand(nullptr);
1989 }
1990};
1991
1993 : public InheritingConcreteTypeLoc<MatrixTypeLoc, ConstantMatrixTypeLoc,
1994 ConstantMatrixType> {};
1995
1997 : public InheritingConcreteTypeLoc<MatrixTypeLoc,
1998 DependentSizedMatrixTypeLoc,
1999 DependentSizedMatrixType> {};
2000
2001// FIXME: location of the '_Complex' keyword.
2002class ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
2003 ComplexTypeLoc,
2004 ComplexType> {
2005};
2006
2011};
2012
2014};
2015
2018};
2019
2020template <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
2022 : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
2023public:
2025 return this->getLocalData()->TypeofLoc;
2026 }
2027
2029 this->getLocalData()->TypeofLoc = Loc;
2030 }
2031
2033 return this->getLocalData()->LParenLoc;
2034 }
2035
2037 this->getLocalData()->LParenLoc = Loc;
2038 }
2039
2041 return this->getLocalData()->RParenLoc;
2042 }
2043
2045 this->getLocalData()->RParenLoc = Loc;
2046 }
2047
2050 }
2051
2053 setLParenLoc(range.getBegin());
2054 setRParenLoc(range.getEnd());
2055 }
2056
2059 }
2060
2065 }
2066};
2067
2068class TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
2069 TypeOfExprType,
2070 TypeOfExprTypeLocInfo> {
2071public:
2073 return getTypePtr()->getUnderlyingExpr();
2074 }
2075
2076 // Reimplemented to account for GNU/C++ extension
2077 // typeof unary-expression
2078 // where there are no parentheses.
2080};
2081
2083 : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
2084public:
2086 return this->getTypePtr()->getUnmodifiedType();
2087 }
2088
2090 return this->getLocalData()->UnmodifiedTInfo;
2091 }
2092
2094 this->getLocalData()->UnmodifiedTInfo = TI;
2095 }
2096
2098};
2099
2100// decltype(expression) abc;
2101// ~~~~~~~~ DecltypeLoc
2102// ~ RParenLoc
2103// FIXME: add LParenLoc, it is tricky to support due to the limitation of
2104// annotated-decltype token.
2108};
2110 : public ConcreteTypeLoc<UnqualTypeLoc, DecltypeTypeLoc, DecltypeType,
2111 DecltypeTypeLocInfo> {
2112public:
2114
2117
2120
2123 }
2124
2128 }
2129};
2130
2133};
2134
2136 : public ConcreteTypeLoc<UnqualTypeLoc, PackIndexingTypeLoc,
2137 PackIndexingType, PackIndexingTypeLocInfo> {
2138
2139public:
2140 Expr *getIndexExpr() const { return getTypePtr()->getIndexExpr(); }
2141 QualType getPattern() const { return getTypePtr()->getPattern(); }
2142
2145
2148 }
2149
2151
2152 QualType getInnerType() const { return this->getTypePtr()->getPattern(); }
2153
2156 }
2157};
2158
2160 // FIXME: While there's only one unary transform right now, future ones may
2161 // need different representations
2164};
2165
2166class UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2167 UnaryTransformTypeLoc,
2168 UnaryTransformType,
2169 UnaryTransformTypeLocInfo> {
2170public:
2173
2176
2179
2181 return getLocalData()->UnderlyingTInfo;
2182 }
2183
2185 getLocalData()->UnderlyingTInfo = TInfo;
2186 }
2187
2189 return SourceRange(getKWLoc(), getRParenLoc());
2190 }
2191
2194 }
2195
2197 setLParenLoc(Range.getBegin());
2198 setRParenLoc(Range.getEnd());
2199 }
2200
2202};
2203
2205 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DeducedTypeLoc,
2206 DeducedType> {};
2207
2209 // For decltype(auto).
2211
2213};
2214
2216 : public ConcreteTypeLoc<DeducedTypeLoc,
2217 AutoTypeLoc,
2218 AutoType,
2219 AutoTypeLocInfo> {
2220public:
2222 return getTypePtr()->getKeyword();
2223 }
2224
2225 bool isDecltypeAuto() const { return getTypePtr()->isDecltypeAuto(); }
2228
2229 bool isConstrained() const {
2230 return getTypePtr()->isConstrained();
2231 }
2232
2234
2236
2237 // FIXME: Several of the following functions can be removed. Instead the
2238 // caller can directly work with the ConceptReference.
2240 if (const auto *CR = getConceptReference())
2241 return CR->getNestedNameSpecifierLoc();
2242 return NestedNameSpecifierLoc();
2243 }
2244
2246 if (const auto *CR = getConceptReference())
2247 return CR->getTemplateKWLoc();
2248 return SourceLocation();
2249 }
2250
2252 if (const auto *CR = getConceptReference())
2253 return CR->getConceptNameLoc();
2254 return SourceLocation();
2255 }
2256
2258 if (const auto *CR = getConceptReference())
2259 return CR->getFoundDecl();
2260 return nullptr;
2261 }
2262
2264 if (const auto *CR = getConceptReference())
2265 return CR->getNamedConcept();
2266 return nullptr;
2267 }
2268
2271 }
2272
2274 return (getConceptReference() &&
2275 getConceptReference()->getTemplateArgsAsWritten() &&
2277 ->getTemplateArgsAsWritten()
2278 ->getLAngleLoc()
2279 .isValid());
2280 }
2281
2283 if (const auto *CR = getConceptReference())
2284 if (const auto *TAAW = CR->getTemplateArgsAsWritten())
2285 return TAAW->getLAngleLoc();
2286 return SourceLocation();
2287 }
2288
2290 if (const auto *CR = getConceptReference())
2291 if (const auto *TAAW = CR->getTemplateArgsAsWritten())
2292 return TAAW->getRAngleLoc();
2293 return SourceLocation();
2294 }
2295
2296 unsigned getNumArgs() const {
2297 return getTypePtr()->getTypeConstraintArguments().size();
2298 }
2299
2300 TemplateArgumentLoc getArgLoc(unsigned i) const {
2301 const auto *CR = getConceptReference();
2302 assert(CR && "No ConceptReference");
2303 return CR->getTemplateArgsAsWritten()->getTemplateArgs()[i];
2304 }
2305
2307 return {isConstrained()
2311 : getConceptNameLoc()))
2312 : getNameLoc(),
2314 }
2315
2317 unsigned size = getFullDataSize();
2318 assert(size == Loc.getFullDataSize());
2319 memcpy(Data, Loc.Data, size);
2320 }
2321
2323};
2324
2326 : public InheritingConcreteTypeLoc<DeducedTypeLoc,
2327 DeducedTemplateSpecializationTypeLoc,
2328 DeducedTemplateSpecializationType> {
2329public:
2331 return getNameLoc();
2332 }
2333
2335 setNameLoc(Loc);
2336 }
2337};
2338
2341
2342 /// Data associated with the nested-name-specifier location.
2344};
2345
2346class ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2347 ElaboratedTypeLoc,
2348 ElaboratedType,
2349 ElaboratedLocInfo> {
2350public:
2353 }
2354
2356 if (isEmpty()) {
2357 assert(Loc.isInvalid());
2358 return;
2359 }
2361 }
2362
2364 return !isEmpty() ? NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2365 getLocalData()->QualifierData)
2367 }
2368
2370 assert(QualifierLoc.getNestedNameSpecifier() ==
2371 getTypePtr()->getQualifier() &&
2372 "Inconsistent nested-name-specifier pointer");
2373 if (isEmpty()) {
2374 assert(!QualifierLoc.hasQualifier());
2375 return;
2376 }
2377 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2378 }
2379
2381 if (getElaboratedKeywordLoc().isValid())
2382 if (getQualifierLoc())
2385 else
2387 else
2389 }
2390
2392
2394
2396
2397 bool isEmpty() const {
2400 }
2401
2402 unsigned getLocalDataAlignment() const {
2403 // FIXME: We want to return 1 here in the empty case, but
2404 // there are bugs in how alignment is handled in TypeLocs
2405 // that prevent this from working.
2407 }
2408
2409 unsigned getLocalDataSize() const {
2411 }
2412
2414 unsigned size = getFullDataSize();
2415 assert(size == Loc.getFullDataSize());
2416 memcpy(Data, Loc.Data, size);
2417 }
2418};
2419
2420// This is exactly the structure of an ElaboratedTypeLoc whose inner
2421// type is some sort of TypeDeclTypeLoc.
2424};
2425
2426class DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2427 DependentNameTypeLoc,
2428 DependentNameType,
2429 DependentNameLocInfo> {
2430public:
2432 return this->getLocalData()->ElaboratedKWLoc;
2433 }
2434
2436 this->getLocalData()->ElaboratedKWLoc = Loc;
2437 }
2438
2440 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2441 getLocalData()->QualifierData);
2442 }
2443
2445 assert(QualifierLoc.getNestedNameSpecifier()
2446 == getTypePtr()->getQualifier() &&
2447 "Inconsistent nested-name-specifier pointer");
2448 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2449 }
2450
2452 return this->getLocalData()->NameLoc;
2453 }
2454
2456 this->getLocalData()->NameLoc = Loc;
2457 }
2458
2460 if (getElaboratedKeywordLoc().isValid())
2462 else
2464 }
2465
2467 unsigned size = getFullDataSize();
2468 assert(size == Loc.getFullDataSize());
2469 memcpy(Data, Loc.Data, size);
2470 }
2471
2473};
2474
2479 // followed by a TemplateArgumentLocInfo[]
2480};
2481
2483 public ConcreteTypeLoc<UnqualTypeLoc,
2484 DependentTemplateSpecializationTypeLoc,
2485 DependentTemplateSpecializationType,
2486 DependentTemplateSpecializationLocInfo> {
2487public:
2489 return this->getLocalData()->ElaboratedKWLoc;
2490 }
2491
2493 this->getLocalData()->ElaboratedKWLoc = Loc;
2494 }
2495
2497 if (!getLocalData()->QualifierData)
2498 return NestedNameSpecifierLoc();
2499
2500 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2501 getLocalData()->QualifierData);
2502 }
2503
2505 if (!QualifierLoc) {
2506 // Even if we have a nested-name-specifier in the dependent
2507 // template specialization type, we won't record the nested-name-specifier
2508 // location information when this type-source location information is
2509 // part of a nested-name-specifier.
2510 getLocalData()->QualifierData = nullptr;
2511 return;
2512 }
2513
2514 assert(QualifierLoc.getNestedNameSpecifier()
2515 == getTypePtr()->getQualifier() &&
2516 "Inconsistent nested-name-specifier pointer");
2517 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2518 }
2519
2521 return getLocalData()->TemplateKWLoc;
2522 }
2523
2526 }
2527
2529 return this->getLocalData()->NameLoc;
2530 }
2531
2533 this->getLocalData()->NameLoc = Loc;
2534 }
2535
2537 return this->getLocalData()->LAngleLoc;
2538 }
2539
2541 this->getLocalData()->LAngleLoc = Loc;
2542 }
2543
2545 return this->getLocalData()->RAngleLoc;
2546 }
2547
2549 this->getLocalData()->RAngleLoc = Loc;
2550 }
2551
2552 unsigned getNumArgs() const {
2553 return getTypePtr()->template_arguments().size();
2554 }
2555
2557 getArgInfos()[i] = AI;
2558 }
2559
2561 return getArgInfos()[i];
2562 }
2563
2564 TemplateArgumentLoc getArgLoc(unsigned i) const {
2565 return TemplateArgumentLoc(getTypePtr()->template_arguments()[i],
2566 getArgLocInfo(i));
2567 }
2568
2570 if (getElaboratedKeywordLoc().isValid())
2572 else if (getQualifierLoc())
2574 else if (getTemplateKeywordLoc().isValid())
2576 else
2578 }
2579
2581 unsigned size = getFullDataSize();
2582 assert(size == Loc.getFullDataSize());
2583 memcpy(Data, Loc.Data, size);
2584 }
2585
2587
2588 unsigned getExtraLocalDataSize() const {
2589 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
2590 }
2591
2593 return alignof(TemplateArgumentLocInfo);
2594 }
2595
2596private:
2597 TemplateArgumentLocInfo *getArgInfos() const {
2598 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
2599 }
2600};
2601
2604};
2605
2607 : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
2608 PackExpansionType, PackExpansionTypeLocInfo> {
2609public:
2611 return this->getLocalData()->EllipsisLoc;
2612 }
2613
2615 this->getLocalData()->EllipsisLoc = Loc;
2616 }
2617
2620 }
2621
2624 }
2625
2627 return getInnerTypeLoc();
2628 }
2629
2631 return this->getTypePtr()->getPattern();
2632 }
2633};
2634
2637};
2638
2639class AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc,
2640 AtomicType, AtomicTypeLocInfo> {
2641public:
2643 return this->getInnerTypeLoc();
2644 }
2645
2647 return SourceRange(getKWLoc(), getRParenLoc());
2648 }
2649
2651 return this->getLocalData()->KWLoc;
2652 }
2653
2655 this->getLocalData()->KWLoc = Loc;
2656 }
2657
2659 return this->getLocalData()->LParenLoc;
2660 }
2661
2663 this->getLocalData()->LParenLoc = Loc;
2664 }
2665
2667 return this->getLocalData()->RParenLoc;
2668 }
2669
2671 this->getLocalData()->RParenLoc = Loc;
2672 }
2673
2676 }
2677
2679 setLParenLoc(Range.getBegin());
2680 setRParenLoc(Range.getEnd());
2681 }
2682
2684 setKWLoc(Loc);
2687 }
2688
2690 return this->getTypePtr()->getValueType();
2691 }
2692};
2693
2696};
2697
2698class PipeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, PipeTypeLoc, PipeType,
2699 PipeTypeLocInfo> {
2700public:
2701 TypeLoc getValueLoc() const { return this->getInnerTypeLoc(); }
2702
2704
2705 SourceLocation getKWLoc() const { return this->getLocalData()->KWLoc; }
2707
2709 setKWLoc(Loc);
2710 }
2711
2712 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2713};
2714
2715template <typename T>
2717 TypeLoc Cur = *this;
2718 while (!T::isKind(Cur)) {
2719 if (auto PTL = Cur.getAs<ParenTypeLoc>())
2720 Cur = PTL.getInnerLoc();
2721 else if (auto ATL = Cur.getAs<AttributedTypeLoc>())
2722 Cur = ATL.getModifiedLoc();
2723 else if (auto ATL = Cur.getAs<BTFTagAttributedTypeLoc>())
2724 Cur = ATL.getWrappedLoc();
2725 else if (auto ATL = Cur.getAs<HLSLAttributedResourceTypeLoc>())
2726 Cur = ATL.getWrappedLoc();
2727 else if (auto ETL = Cur.getAs<ElaboratedTypeLoc>())
2728 Cur = ETL.getNamedTypeLoc();
2729 else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())
2730 Cur = ATL.getOriginalLoc();
2731 else if (auto MQL = Cur.getAs<MacroQualifiedTypeLoc>())
2732 Cur = MQL.getInnerLoc();
2733 else
2734 break;
2735 }
2736 return Cur.getAs<T>();
2737}
2738class BitIntTypeLoc final
2739 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, BitIntTypeLoc,
2740 BitIntType> {};
2742 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentBitIntTypeLoc,
2743 DependentBitIntType> {};
2744
2746 ObjCProtocolDecl *Protocol = nullptr;
2748
2749public:
2751 : Protocol(protocol), Loc(loc) {}
2752 ObjCProtocolDecl *getProtocol() const { return Protocol; }
2753 SourceLocation getLocation() const { return Loc; }
2754
2755 /// The source range is just the protocol name.
2756 SourceRange getSourceRange() const LLVM_READONLY {
2757 return SourceRange(Loc, Loc);
2758 }
2759};
2760
2761} // namespace clang
2762
2763#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:1276
unsigned getLocalDataSize() const
Definition: TypeLoc.h:1284
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1268
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1272
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1282
QualType getOriginalType() const
Definition: Type.h:3370
Wrapper for source info for array parameter types.
Definition: TypeLoc.h:1649
Wrapper for source info for arrays.
Definition: TypeLoc.h:1593
SourceLocation getLBracketLoc() const
Definition: TypeLoc.h:1595
Expr * getSizeExpr() const
Definition: TypeLoc.h:1615
void setLBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1599
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1623
void setRBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1607
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1631
SourceLocation getRBracketLoc() const
Definition: TypeLoc.h:1603
SourceRange getBracketsRange() const
Definition: TypeLoc.h:1611
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1627
QualType getInnerType() const
Definition: TypeLoc.h:1637
void setSizeExpr(Expr *Size)
Definition: TypeLoc.h:1619
QualType getElementType() const
Definition: Type.h:3589
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2666
QualType getInnerType() const
Definition: TypeLoc.h:2689
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2646
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2670
SourceRange getParensRange() const
Definition: TypeLoc.h:2674
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2642
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2662
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2654
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2683
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2650
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2658
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:2678
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:7766
Attr - This represents one attribute.
Definition: Attr.h:43
Type source information for an attributed type.
Definition: TypeLoc.h:876
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:899
QualType getInnerType() const
Definition: TypeLoc.h:916
const T * getAttrAs()
Definition: TypeLoc.h:906
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:890
TypeLoc getEquivalentTypeLoc() const
Definition: TypeLoc.h:894
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:912
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:511
void setAttr(const Attr *A)
Definition: TypeLoc.h:902
attr::Kind getAttrKind() const
Definition: TypeLoc.h:878
bool isQualifier() const
Definition: TypeLoc.h:882
QualType getModifiedType() const
Definition: Type.h:6162
Kind getAttrKind() const
Definition: Type.h:6156
bool isQualifier() const
Does this attribute behave like a type qualifier?
Definition: Type.cpp:4165
bool hasExplicitTemplateArgs() const
Definition: TypeLoc.h:2273
SourceLocation getTemplateKWLoc() const
Definition: TypeLoc.h:2245
AutoTypeKeyword getAutoKeyword() const
Definition: TypeLoc.h:2221
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
Definition: TypeLoc.h:2239
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:2289
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2226
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:662
ConceptDecl * getNamedConcept() const
Definition: TypeLoc.h:2263
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2306
void copy(AutoTypeLoc Loc)
Definition: TypeLoc.h:2316
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:2282
void setConceptReference(ConceptReference *CR)
Definition: TypeLoc.h:2233
SourceLocation getConceptNameLoc() const
Definition: TypeLoc.h:2251
NamedDecl * getFoundDecl() const
Definition: TypeLoc.h:2257
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:2300
bool isDecltypeAuto() const
Definition: TypeLoc.h:2225
bool isConstrained() const
Definition: TypeLoc.h:2229
unsigned getNumArgs() const
Definition: TypeLoc.h:2296
ConceptReference * getConceptReference() const
Definition: TypeLoc.h:2235
DeclarationNameInfo getConceptNameInfo() const
Definition: TypeLoc.h:2269
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2227
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
Definition: Type.h:6571
bool isDecltypeAuto() const
Definition: Type.h:6584
AutoTypeKeyword getKeyword() const
Definition: Type.h:6592
bool isConstrained() const
Definition: Type.h:6580
Type source information for an btf_tag attributed type.
Definition: TypeLoc.h:926
QualType getInnerType() const
Definition: TypeLoc.h:941
TypeLoc getWrappedLoc() const
Definition: TypeLoc.h:928
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:939
const BTFTypeTagAttr * getAttr() const
The btf_type_tag attribute.
Definition: TypeLoc.h:931
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:528
const BTFTypeTagAttr * getAttr() const
Definition: Type.h:6236
QualType getWrappedType() const
Definition: Type.h:6235
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1346
SourceLocation getCaretLoc() const
Definition: TypeLoc.h:1348
void setCaretLoc(SourceLocation Loc)
Definition: TypeLoc.h:1352
QualType getInnerType() const
Definition: TypeLoc.h:1161
unsigned getLocalDataSize() const
Definition: TypeLoc.h:1166
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1160
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1162
QualType desugar() const
Definition: Type.h:3268
Wrapper for source info for builtin types.
Definition: TypeLoc.h:566
SourceLocation getBuiltinLoc() const
Definition: TypeLoc.h:568
TypeSpecifierType getWrittenTypeSpec() const
Definition: TypeLoc.cpp:332
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:669
TypeSpecifierWidth getWrittenWidthSpec() const
Definition: TypeLoc.h:630
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:610
void setWrittenTypeSpec(TypeSpecifierType written)
Definition: TypeLoc.h:652
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
Definition: TypeLoc.h:591
bool needsExtraLocalData() const
Definition: TypeLoc.h:595
bool hasWrittenWidthSpec() const
Definition: TypeLoc.h:637
void setModeAttr(bool written)
Definition: TypeLoc.h:664
void setBuiltinLoc(SourceLocation Loc)
Definition: TypeLoc.h:572
void setWrittenWidthSpec(TypeSpecifierWidth written)
Definition: TypeLoc.h:641
SourceLocation getNameLoc() const
Definition: TypeLoc.h:586
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:606
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:588
void setWrittenSignSpec(TypeSpecifierSign written)
Definition: TypeLoc.h:625
bool hasWrittenSignSpec() const
Definition: TypeLoc.h:621
bool hasModeAttr() const
Definition: TypeLoc.h:657
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:602
bool hasWrittenTypeSpec() const
Definition: TypeLoc.h:648
TypeSpecifierSign getWrittenSignSpec() const
Definition: TypeLoc.h:614
void expandBuiltinRange(SourceRange Range)
Definition: TypeLoc.h:576
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:422
friend class TypeLoc
Definition: TypeLoc.h:374
TypeLoc getInnerTypeLoc() const
Definition: TypeLoc.h:459
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:431
HasNoInnerType getInnerType() const
Definition: TypeLoc.h:457
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:442
LocalData * getLocalData() const
Definition: TypeLoc.h:435
unsigned getLocalDataAlignment() const
Definition: TypeLoc.h:390
void * getNonLocalData() const
Definition: TypeLoc.h:449
TypeLoc getNextTypeLoc() const
Definition: TypeLoc.h:418
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:427
void copyLocal(Derived other)
Definition: TypeLoc.h:404
unsigned getLocalDataSize() const
Definition: TypeLoc.h:395
Expr * getCountExpr() const
Definition: TypeLoc.h:1174
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:1294
SourceLocation getDecltypeLoc() const
Definition: TypeLoc.h:2115
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2125
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:2113
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2118
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2119
void setDecltypeLoc(SourceLocation Loc)
Definition: TypeLoc.h:2116
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2121
Expr * getUnderlyingExpr() const
Definition: Type.h:5889
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2330
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2334
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1805
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1830
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1826
QualType getInnerType() const
Returns the type before the address space attribute application area.
Definition: TypeLoc.h:1840
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
Definition: TypeLoc.h:1812
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:1848
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:1823
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1802
QualType getPointeeType() const
Definition: Type.h:3932
void copy(DependentNameTypeLoc Loc)
Definition: TypeLoc.h:2466
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2439
SourceLocation getNameLoc() const
Definition: TypeLoc.h:2451
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:559
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2459
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2431
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2455
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2435
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2444
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1662
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1922
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1926
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1924
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1930
QualType getElementType() const
Definition: Type.h:3975
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2504
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:569
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2528
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2524
void copy(DependentTemplateSpecializationTypeLoc Loc)
Definition: TypeLoc.h:2580
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2520
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2492
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2548
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:2564
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:2560
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2488
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2540
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2556
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2532
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2496
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:7100
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1894
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1898
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1902
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1906
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1896
QualType getInnerType() const
Definition: TypeLoc.h:1908
QualType getElementType() const
Definition: Type.h:4098
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:549
bool isEmpty() const
Definition: TypeLoc.h:2397
unsigned getLocalDataAlignment() const
Definition: TypeLoc.h:2402
QualType getInnerType() const
Definition: TypeLoc.h:2395
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2351
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2363
void copy(ElaboratedTypeLoc Loc)
Definition: TypeLoc.h:2413
unsigned getLocalDataSize() const
Definition: TypeLoc.h:2409
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2380
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2355
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2393
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2369
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:6983
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:6986
Represents an enum.
Definition: Decl.h:3861
Wrapper for source info for enum types.
Definition: TypeLoc.h:750
EnumDecl * getDecl() const
Definition: TypeLoc.h:752
EnumDecl * getDecl() const
Definition: Type.h:6110
This represents one expression.
Definition: Expr.h:110
Wrapper for source info for functions.
Definition: TypeLoc.h:1460
ParmVarDecl ** getParmArray() const
Definition: TypeLoc.h:1528
QualType getInnerType() const
Definition: TypeLoc.h:1569
unsigned getNumParams() const
Definition: TypeLoc.h:1532
ParmVarDecl * getParam(unsigned i) const
Definition: TypeLoc.h:1538
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1484
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1480
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1496
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1512
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1539
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1523
SourceRange getParensRange() const
Definition: TypeLoc.h:1508
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1504
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1567
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1488
unsigned getExtraLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition: TypeLoc.h:1562
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1518
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1541
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1476
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1545
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1492
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1500
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1549
QualType getReturnType() const
Definition: Type.h:4648
Type source information for HLSL attributed resource type.
Definition: TypeLoc.h:953
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:966
unsigned getLocalDataSize() const
Definition: TypeLoc.h:970
TypeSourceInfo * getContainedTypeSourceInfo() const
Definition: TypeLoc.h:957
void setContainedTypeSourceInfo(TypeSourceInfo *TSI) const
Definition: TypeLoc.h:960
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:965
void setSourceRange(const SourceRange &R)
Definition: TypeLoc.h:964
QualType getWrappedType() const
Definition: Type.h:6298
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:499
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:515
Wrapper for source info for injected class names of class templates.
Definition: TypeLoc.h:706
CXXRecordDecl * getDecl() const
Definition: TypeLoc.h:708
CXXRecordDecl * getDecl() const
Definition: Type.cpp:4236
void setAmpLoc(SourceLocation Loc)
Definition: TypeLoc.h:1430
SourceLocation getAmpLoc() const
Definition: TypeLoc.h:1426
const IdentifierInfo * getMacroIdentifier() const
Definition: TypeLoc.h:1195
SourceLocation getExpansionLoc() const
Definition: TypeLoc.h:1199
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1193
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1189
void setExpansionLoc(SourceLocation Loc)
Definition: TypeLoc.h:1203
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1209
QualType getInnerType() const
Definition: TypeLoc.h:1207
QualType getUnderlyingType() const
Definition: Type.h:5786
const IdentifierInfo * getMacroIdentifier() const
Definition: Type.h:5785
Expr * getAttrColumnOperand() const
The attribute's column operand, if it has one.
Definition: TypeLoc.h:1964
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:1971
void setAttrRowOperand(Expr *e)
Definition: TypeLoc.h:1959
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1978
void setAttrColumnOperand(Expr *e)
Definition: TypeLoc.h:1965
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1974
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1953
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1952
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:1984
Expr * getAttrRowOperand() const
The attribute's row operand, if it has one.
Definition: TypeLoc.h:1958
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1364
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1386
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1370
TypeSourceInfo * getClassTInfo() const
Definition: TypeLoc.h:1378
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1391
void setClassTInfo(TypeSourceInfo *TI)
Definition: TypeLoc.h:1382
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1366
const Type * getClass() const
Definition: TypeLoc.h:1374
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:1123
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1133
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1137
void setNameEndLoc(SourceLocation Loc)
Definition: TypeLoc.h:1145
ObjCInterfaceDecl * getIFaceDecl() const
Definition: TypeLoc.h:1125
SourceLocation getNameEndLoc() const
Definition: TypeLoc.h:1141
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1129
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1149
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition: Type.cpp:936
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1402
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1404
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1408
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1103
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1016
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition: TypeLoc.h:1064
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:1098
bool hasBaseTypeAsWritten() const
Definition: TypeLoc.h:1074
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:495
SourceLocation getTypeArgsLAngleLoc() const
Definition: TypeLoc.h:1004
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:1020
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:1070
unsigned getNumProtocols() const
Definition: TypeLoc.h:1050
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1008
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1086
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition: TypeLoc.h:1024
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1029
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1038
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1046
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:1042
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:1054
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:1078
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:1059
TypeLoc getBaseLoc() const
Definition: TypeLoc.h:1082
QualType getInnerType() const
Definition: TypeLoc.h:1109
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:1034
SourceLocation getTypeArgsRAngleLoc() const
Definition: TypeLoc.h:1012
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
Definition: Type.h:7441
QualType getBaseType() const
Gets the base type of this object type.
Definition: Type.h:7393
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
SourceLocation getLocation() const
Definition: TypeLoc.h:2753
ObjCProtocolLoc(ObjCProtocolDecl *protocol, SourceLocation loc)
Definition: TypeLoc.h:2750
ObjCProtocolDecl * getProtocol() const
Definition: TypeLoc.h:2752
SourceRange getSourceRange() const LLVM_READONLY
The source range is just the protocol name.
Definition: TypeLoc.h:2756
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
Definition: Type.h:7237
qual_iterator qual_begin() const
Definition: Type.h:7230
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:773
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:842
ObjCTypeParamDecl * getDecl() const
Definition: TypeLoc.h:780
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:846
unsigned getNumProtocols() const
Definition: TypeLoc.h:810
SourceLocation getNameLoc() const
Definition: TypeLoc.h:782
ObjCProtocolDecl * getProtocol(unsigned i) const
Definition: TypeLoc.h:824
SourceLocation getProtocolLoc(unsigned i) const
Definition: TypeLoc.h:814
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:829
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:819
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:796
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:835
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:484
SourceLocation getProtocolLAngleLoc() const
Definition: TypeLoc.h:790
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:806
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:786
SourceLocation getProtocolRAngleLoc() const
Definition: TypeLoc.h:800
ObjCTypeParamDecl * getDecl() const
Definition: Type.h:7299
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2618
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2614
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2610
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2626
QualType getInnerType() const
Definition: TypeLoc.h:2630
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2622
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:7167
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2143
Expr * getIndexExpr() const
Definition: TypeLoc.h:2140
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2150
QualType getPattern() const
Definition: TypeLoc.h:2141
QualType getInnerType() const
Definition: TypeLoc.h:2152
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2154
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2144
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2146
QualType getPattern() const
Definition: Type.h:5942
Expr * getIndexExpr() const
Definition: Type.h:5941
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1235
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1243
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1227
QualType getInnerType() const
Definition: TypeLoc.h:1252
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1223
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1239
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1248
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1231
QualType getInnerType() const
Definition: Type.h:3181
Represents a parameter to a function.
Definition: Decl.h:1725
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2701
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2708
QualType getInnerType() const
Definition: TypeLoc.h:2712
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2706
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2703
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2705
QualType getElementType() const
Definition: Type.h:7796
A base class for.
Definition: TypeLoc.h:1304
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1322
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1318
void setSigilLoc(SourceLocation Loc)
Definition: TypeLoc.h:1310
QualType getInnerType() const
Definition: TypeLoc.h:1326
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1314
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1306
Wrapper for source info for pointers.
Definition: TypeLoc.h:1333
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1335
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1339
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:7936
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:1444
SourceLocation getAmpAmpLoc() const
Definition: TypeLoc.h:1440
Represents a struct/union/class.
Definition: Decl.h:4162
Wrapper for source info for record types.
Definition: TypeLoc.h:742
RecordDecl * getDecl() const
Definition: TypeLoc.h:744
RecordDecl * getDecl() const
Definition: Type.h:6087
QualType getInnerType() const
Definition: TypeLoc.h:1416
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:865
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:858
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3578
Wrapper for source info for tag types.
Definition: TypeLoc.h:731
TagDecl * getDecl() const
Definition: TypeLoc.h:733
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:1719
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:1699
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:1723
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1695
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:1727
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1752
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:1707
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1736
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1703
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1732
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1759
void copy(TemplateSpecializationTypeLoc Loc)
Definition: TypeLoc.h:1741
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1777
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:1691
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1711
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:1773
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:6734
Declaration of a template type parameter.
Wrapper for template type parameters.
Definition: TypeLoc.h:759
TemplateTypeParmDecl * getDecl() const
Definition: TypeLoc.h:761
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:6353
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:1257
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:2716
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:2072
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:532
void setUnmodifiedTInfo(TypeSourceInfo *TI) const
Definition: TypeLoc.h:2093
TypeSourceInfo * getUnmodifiedTInfo() const
Definition: TypeLoc.h:2089
QualType getUnmodifiedType() const
Definition: TypeLoc.h:2085
A container of type source information.
Definition: Type.h:7907
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:529
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:548
SourceLocation getNameLoc() const
Definition: TypeLoc.h:536
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:540
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:544
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:6906
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:3427
Wrapper for source info for typedefs.
Definition: TypeLoc.h:694
TypedefNameDecl * getTypedefNameDecl() const
Definition: TypeLoc.h:696
TypedefNameDecl * getDecl() const
Definition: Type.h:5745
void setParensRange(SourceRange range)
Definition: TypeLoc.h:2052
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2057
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2032
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2040
SourceRange getParensRange() const
Definition: TypeLoc.h:2048
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2036
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:2024
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:2028
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2044
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2061
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2178
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:2196
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:540
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2188
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2172
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2171
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2177
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:2180
SourceRange getParensRange() const
Definition: TypeLoc.h:2192
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:2184
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2175
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2174
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:717
UnresolvedUsingTypenameDecl * getDecl() const
Definition: TypeLoc.h:719
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:5683
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3982
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3343
Wrapper for source info for types used via transparent aliases.
Definition: TypeLoc.h:683
QualType getUnderlyingType() const
Definition: TypeLoc.h:685
UsingShadowDecl * getFoundDecl() const
Definition: TypeLoc.h:688
UsingShadowDecl * getFoundDecl() const
Definition: Type.h:5712
QualType getUnderlyingType() const
Definition: Type.cpp:3934
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1883
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1873
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1879
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1875
QualType getInnerType() const
Definition: TypeLoc.h:1885
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1871
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:1585
SourceLocation RBracketLoc
Definition: TypeLoc.h:1585
SourceLocation KWLoc
Definition: TypeLoc.h:2636
SourceLocation RParenLoc
Definition: TypeLoc.h:2636
SourceLocation LParenLoc
Definition: TypeLoc.h:2636
const Attr * TypeAttr
Definition: TypeLoc.h:869
ConceptReference * CR
Definition: TypeLoc.h:2212
SourceLocation RParenLoc
Definition: TypeLoc.h:2210
SourceRange BuiltinRange
Definition: TypeLoc.h:559
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation RParenLoc
Definition: TypeLoc.h:2107
SourceLocation DecltypeLoc
Definition: TypeLoc.h:2106
SourceLocation NameLoc
Definition: TypeLoc.h:2423
SourceLocation ElaboratedKWLoc
Definition: TypeLoc.h:2340
void * QualifierData
Data associated with the nested-name-specifier location.
Definition: TypeLoc.h:2343
SourceLocation LParenLoc
Definition: TypeLoc.h:1451
SourceLocation RParenLoc
Definition: TypeLoc.h:1452
SourceLocation LocalRangeEnd
Definition: TypeLoc.h:1453
SourceLocation LocalRangeBegin
Definition: TypeLoc.h:1450
TypeSourceInfo * ContainedTyInfo
Definition: TypeLoc.h:946
SourceLocation ExpansionLoc
Definition: TypeLoc.h:1182
SourceLocation AttrLoc
Definition: TypeLoc.h:1940
SourceRange OperandParens
Definition: TypeLoc.h:1941
TypeSourceInfo * ClassTInfo
Definition: TypeLoc.h:1358
SourceLocation NameEndLoc
Definition: TypeLoc.h:1116
SourceLocation NameLoc
Definition: TypeLoc.h:1115
SourceLocation TypeArgsLAngleLoc
Definition: TypeLoc.h:976
SourceLocation ProtocolLAngleLoc
Definition: TypeLoc.h:978
SourceLocation TypeArgsRAngleLoc
Definition: TypeLoc.h:977
SourceLocation ProtocolRAngleLoc
Definition: TypeLoc.h:979
SourceLocation EllipsisLoc
Definition: TypeLoc.h:2132
SourceLocation LParenLoc
Definition: TypeLoc.h:1215
SourceLocation RParenLoc
Definition: TypeLoc.h:1216
SourceLocation KWLoc
Definition: TypeLoc.h:2695
SourceLocation StarLoc
Definition: TypeLoc.h:1298
Location information for a TemplateArgument.
Definition: TemplateBase.h:472
SourceLocation NameLoc
Definition: TypeLoc.h:1676
TypeSourceInfo * UnmodifiedTInfo
Definition: TypeLoc.h:2017
SourceLocation NameLoc
Definition: TypeLoc.h:521
SourceLocation RParenLoc
Definition: TypeLoc.h:2010
SourceLocation LParenLoc
Definition: TypeLoc.h:2009
SourceLocation TypeofLoc
Definition: TypeLoc.h:2008
TypeSourceInfo * UnderlyingTInfo
Definition: TypeLoc.h:2163
SourceLocation NameLoc
Definition: TypeLoc.h:1865
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:109