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