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 : public ConcreteTypeLoc<UnqualTypeLoc, BoundsAttributedTypeLoc,
1126 BoundsAttributedType, BoundsAttributedLocInfo> {
1127public:
1129 QualType getInnerType() const { return getTypePtr()->desugar(); }
1131 // nothing to do
1132 }
1133 // LocalData is empty and TypeLocBuilder doesn't handle DataSize 1.
1134 unsigned getLocalDataSize() const { return 0; }
1135};
1136
1138 : public InheritingConcreteTypeLoc<BoundsAttributedTypeLoc,
1139 CountAttributedTypeLoc,
1140 CountAttributedType> {
1141public:
1142 Expr *getCountExpr() const { return getTypePtr()->getCountExpr(); }
1143 bool isCountInBytes() const { return getTypePtr()->isCountInBytes(); }
1144 bool isOrNull() const { return getTypePtr()->isOrNull(); }
1145
1147};
1148
1151};
1152
1154 : public ConcreteTypeLoc<UnqualTypeLoc, MacroQualifiedTypeLoc,
1155 MacroQualifiedType, MacroQualifiedLocInfo> {
1156public:
1158 setExpansionLoc(Loc);
1159 }
1160
1162
1164 return getTypePtr()->getMacroIdentifier();
1165 }
1166
1168 return this->getLocalData()->ExpansionLoc;
1169 }
1170
1172 this->getLocalData()->ExpansionLoc = Loc;
1173 }
1174
1176
1179 }
1180};
1181
1185};
1186
1188 : public ConcreteTypeLoc<UnqualTypeLoc, ParenTypeLoc, ParenType,
1189 ParenLocInfo> {
1190public:
1192 return this->getLocalData()->LParenLoc;
1193 }
1194
1196 return this->getLocalData()->RParenLoc;
1197 }
1198
1200 this->getLocalData()->LParenLoc = Loc;
1201 }
1202
1204 this->getLocalData()->RParenLoc = Loc;
1205 }
1206
1209 }
1210
1212 setLParenLoc(Loc);
1213 setRParenLoc(Loc);
1214 }
1215
1217 return getInnerTypeLoc();
1218 }
1219
1221 return this->getTypePtr()->getInnerType();
1222 }
1223};
1224
1226 if (ParenTypeLoc::isKind(*this))
1227 return IgnoreParensImpl(*this);
1228 return *this;
1229}
1230
1231struct AdjustedLocInfo {}; // Nothing.
1232
1233class AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc,
1234 AdjustedType, AdjustedLocInfo> {
1235public:
1237 return getInnerTypeLoc();
1238 }
1239
1241 // do nothing
1242 }
1243
1245 // The inner type is the undecayed type, since that's what we have source
1246 // location information for.
1247 return getTypePtr()->getOriginalType();
1248 }
1249
1250 SourceRange getLocalSourceRange() const { return {}; }
1251
1252 unsigned getLocalDataSize() const {
1253 // sizeof(AdjustedLocInfo) is 1, but we don't need its address to be unique
1254 // anyway. TypeLocBuilder can't handle data sizes of 1.
1255 return 0; // No data.
1256 }
1257};
1258
1259/// Wrapper for source info for pointers decayed from arrays and
1260/// functions.
1262 AdjustedTypeLoc, DecayedTypeLoc, DecayedType> {
1263};
1264
1267};
1268
1269/// A base class for
1270template <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
1271class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
1272 TypeClass, LocalData> {
1273public:
1275 return this->getLocalData()->StarLoc;
1276 }
1277
1279 this->getLocalData()->StarLoc = Loc;
1280 }
1281
1283 return this->getInnerTypeLoc();
1284 }
1285
1287 return SourceRange(getSigilLoc(), getSigilLoc());
1288 }
1289
1291 setSigilLoc(Loc);
1292 }
1293
1295 return this->getTypePtr()->getPointeeType();
1296 }
1297};
1298
1299/// Wrapper for source info for pointers.
1300class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
1301 PointerType> {
1302public:
1304 return getSigilLoc();
1305 }
1306
1308 setSigilLoc(Loc);
1309 }
1310};
1311
1312/// Wrapper for source info for block pointers.
1313class BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
1314 BlockPointerType> {
1315public:
1317 return getSigilLoc();
1318 }
1319
1321 setSigilLoc(Loc);
1322 }
1323};
1324
1327};
1328
1329/// Wrapper for source info for member pointers.
1330class MemberPointerTypeLoc : public PointerLikeTypeLoc<MemberPointerTypeLoc,
1331 MemberPointerType,
1332 MemberPointerLocInfo> {
1333public:
1335 return getSigilLoc();
1336 }
1337
1339 setSigilLoc(Loc);
1340 }
1341
1342 const Type *getClass() const {
1343 return getTypePtr()->getClass();
1344 }
1345
1347 return getLocalData()->ClassTInfo;
1348 }
1349
1351 getLocalData()->ClassTInfo = TI;
1352 }
1353
1355 setSigilLoc(Loc);
1356 setClassTInfo(nullptr);
1357 }
1358
1360 if (TypeSourceInfo *TI = getClassTInfo())
1361 return SourceRange(TI->getTypeLoc().getBeginLoc(), getStarLoc());
1362 else
1363 return SourceRange(getStarLoc());
1364 }
1365};
1366
1367/// Wraps an ObjCPointerType with source location information.
1369 public PointerLikeTypeLoc<ObjCObjectPointerTypeLoc,
1370 ObjCObjectPointerType> {
1371public:
1373 return getSigilLoc();
1374 }
1375
1377 setSigilLoc(Loc);
1378 }
1379};
1380
1381class ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
1382 ReferenceType> {
1383public:
1385 return getTypePtr()->getPointeeTypeAsWritten();
1386 }
1387};
1388
1390 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1391 LValueReferenceTypeLoc,
1392 LValueReferenceType> {
1393public:
1395 return getSigilLoc();
1396 }
1397
1399 setSigilLoc(Loc);
1400 }
1401};
1402
1404 public InheritingConcreteTypeLoc<ReferenceTypeLoc,
1405 RValueReferenceTypeLoc,
1406 RValueReferenceType> {
1407public:
1409 return getSigilLoc();
1410 }
1411
1413 setSigilLoc(Loc);
1414 }
1415};
1416
1422};
1423
1424/// Wrapper for source info for functions.
1425class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1426 FunctionTypeLoc,
1427 FunctionType,
1428 FunctionLocInfo> {
1429 bool hasExceptionSpec() const {
1430 if (auto *FPT = dyn_cast<FunctionProtoType>(getTypePtr())) {
1431 return FPT->hasExceptionSpec();
1432 }
1433 return false;
1434 }
1435
1436 SourceRange *getExceptionSpecRangePtr() const {
1437 assert(hasExceptionSpec() && "No exception spec range");
1438 // After the Info comes the ParmVarDecl array, and after that comes the
1439 // exception specification information.
1440 return (SourceRange *)(getParmArray() + getNumParams());
1441 }
1442
1443public:
1445 return getLocalData()->LocalRangeBegin;
1446 }
1447
1450 }
1451
1453 return getLocalData()->LocalRangeEnd;
1454 }
1455
1458 }
1459
1461 return this->getLocalData()->LParenLoc;
1462 }
1463
1465 this->getLocalData()->LParenLoc = Loc;
1466 }
1467
1469 return this->getLocalData()->RParenLoc;
1470 }
1471
1473 this->getLocalData()->RParenLoc = Loc;
1474 }
1475
1478 }
1479
1481 if (hasExceptionSpec())
1482 return *getExceptionSpecRangePtr();
1483 return {};
1484 }
1485
1487 if (hasExceptionSpec())
1488 *getExceptionSpecRangePtr() = R;
1489 }
1490
1493 }
1494
1495 // ParmVarDecls* are stored after Info, one for each parameter.
1497 return (ParmVarDecl**) getExtraLocalData();
1498 }
1499
1500 unsigned getNumParams() const {
1501 if (isa<FunctionNoProtoType>(getTypePtr()))
1502 return 0;
1503 return cast<FunctionProtoType>(getTypePtr())->getNumParams();
1504 }
1505
1506 ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; }
1507 void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
1508
1510 return getInnerTypeLoc();
1511 }
1512
1515 }
1516
1518 setLocalRangeBegin(Loc);
1519 setLParenLoc(Loc);
1520 setRParenLoc(Loc);
1521 setLocalRangeEnd(Loc);
1522 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
1523 setParam(i, nullptr);
1524 if (hasExceptionSpec())
1526 }
1527
1528 /// Returns the size of the type source info data block that is
1529 /// specific to this type.
1530 unsigned getExtraLocalDataSize() const {
1531 unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
1532 return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
1533 }
1534
1535 unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); }
1536
1538};
1539
1541 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1542 FunctionProtoTypeLoc,
1543 FunctionProtoType> {
1544};
1545
1547 public InheritingConcreteTypeLoc<FunctionTypeLoc,
1548 FunctionNoProtoTypeLoc,
1549 FunctionNoProtoType> {
1550};
1551
1555};
1556
1557/// Wrapper for source info for arrays.
1558class ArrayTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
1559 ArrayTypeLoc,
1560 ArrayType,
1561 ArrayLocInfo> {
1562public:
1564 return getLocalData()->LBracketLoc;
1565 }
1566
1568 getLocalData()->LBracketLoc = Loc;
1569 }
1570
1572 return getLocalData()->RBracketLoc;
1573 }
1574
1576 getLocalData()->RBracketLoc = Loc;
1577 }
1578
1581 }
1582
1584 return getLocalData()->Size;
1585 }
1586
1587 void setSizeExpr(Expr *Size) {
1588 getLocalData()->Size = Size;
1589 }
1590
1592 return getInnerTypeLoc();
1593 }
1594
1597 }
1598
1600 setLBracketLoc(Loc);
1601 setRBracketLoc(Loc);
1602 setSizeExpr(nullptr);
1603 }
1604
1606};
1607
1609 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1610 ConstantArrayTypeLoc,
1611 ConstantArrayType> {
1612};
1613
1614/// Wrapper for source info for array parameter types.
1617 ConstantArrayTypeLoc, ArrayParameterTypeLoc, ArrayParameterType> {};
1618
1620 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1621 IncompleteArrayTypeLoc,
1622 IncompleteArrayType> {
1623};
1624
1626 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1627 DependentSizedArrayTypeLoc,
1628 DependentSizedArrayType> {
1629public:
1631 ArrayTypeLoc::initializeLocal(Context, Loc);
1633 }
1634};
1635
1637 public InheritingConcreteTypeLoc<ArrayTypeLoc,
1638 VariableArrayTypeLoc,
1639 VariableArrayType> {
1640};
1641
1642// Location information for a TemplateName. Rudimentary for now.
1645};
1646
1651};
1652
1654 public ConcreteTypeLoc<UnqualTypeLoc,
1655 TemplateSpecializationTypeLoc,
1656 TemplateSpecializationType,
1657 TemplateSpecializationLocInfo> {
1658public:
1660 return getLocalData()->TemplateKWLoc;
1661 }
1662
1664 getLocalData()->TemplateKWLoc = Loc;
1665 }
1666
1668 return getLocalData()->LAngleLoc;
1669 }
1670
1672 getLocalData()->LAngleLoc = Loc;
1673 }
1674
1676 return getLocalData()->RAngleLoc;
1677 }
1678
1680 getLocalData()->RAngleLoc = Loc;
1681 }
1682
1683 unsigned getNumArgs() const {
1684 return getTypePtr()->template_arguments().size();
1685 }
1686
1688 getArgInfos()[i] = AI;
1689 }
1690
1692 return getArgInfos()[i];
1693 }
1694
1695 TemplateArgumentLoc getArgLoc(unsigned i) const {
1696 return TemplateArgumentLoc(getTypePtr()->template_arguments()[i],
1697 getArgLocInfo(i));
1698 }
1699
1701 return getLocalData()->NameLoc;
1702 }
1703
1705 getLocalData()->NameLoc = Loc;
1706 }
1707
1708 /// - Copy the location information from the given info.
1710 unsigned size = getFullDataSize();
1711 assert(size == Loc.getFullDataSize());
1712
1713 // We're potentially copying Expr references here. We don't
1714 // bother retaining them because TypeSourceInfos live forever, so
1715 // as long as the Expr was retained when originally written into
1716 // the TypeLoc, we're okay.
1717 memcpy(Data, Loc.Data, size);
1718 }
1719
1721 if (getTemplateKeywordLoc().isValid())
1723 else
1725 }
1726
1729 setTemplateNameLoc(Loc);
1730 setLAngleLoc(Loc);
1731 setRAngleLoc(Loc);
1732 initializeArgLocs(Context, getTypePtr()->template_arguments(),
1733 getArgInfos(), Loc);
1734 }
1735
1736 static void initializeArgLocs(ASTContext &Context,
1738 TemplateArgumentLocInfo *ArgInfos,
1739 SourceLocation Loc);
1740
1741 unsigned getExtraLocalDataSize() const {
1742 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
1743 }
1744
1746 return alignof(TemplateArgumentLocInfo);
1747 }
1748
1749private:
1750 TemplateArgumentLocInfo *getArgInfos() const {
1751 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
1752 }
1753};
1754
1759};
1760
1762 : public ConcreteTypeLoc<UnqualTypeLoc,
1763 DependentAddressSpaceTypeLoc,
1764 DependentAddressSpaceType,
1765 DependentAddressSpaceLocInfo> {
1766public:
1767 /// The location of the attribute name, i.e.
1768 /// int * __attribute__((address_space(11)))
1769 /// ^~~~~~~~~~~~~
1771 return getLocalData()->AttrLoc;
1772 }
1774 getLocalData()->AttrLoc = loc;
1775 }
1776
1777 /// The attribute's expression operand, if it has one.
1778 /// int * __attribute__((address_space(11)))
1779 /// ^~
1781 return getLocalData()->ExprOperand;
1782 }
1785 }
1786
1787 /// The location of the parentheses around the operand, if there is
1788 /// an operand.
1789 /// int * __attribute__((address_space(11)))
1790 /// ^ ^
1792 return getLocalData()->OperandParens;
1793 }
1795 getLocalData()->OperandParens = range;
1796 }
1797
1799 SourceRange range(getAttrNameLoc());
1800 range.setEnd(getAttrOperandParensRange().getEnd());
1801 return range;
1802 }
1803
1804 /// Returns the type before the address space attribute application
1805 /// area.
1806 /// int * __attribute__((address_space(11))) *
1807 /// ^ ^
1809 return this->getTypePtr()->getPointeeType();
1810 }
1811
1813 return this->getInnerTypeLoc();
1814 }
1815
1817 setAttrNameLoc(loc);
1820 setAttrExprOperand(getTypePtr()->getAddrSpaceExpr());
1821 }
1822};
1823
1824//===----------------------------------------------------------------------===//
1825//
1826// All of these need proper implementations.
1827//
1828//===----------------------------------------------------------------------===//
1829
1830// FIXME: size expression and attribute locations (or keyword if we
1831// ever fully support altivec syntax).
1834};
1835
1836class VectorTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, VectorTypeLoc,
1837 VectorType, VectorTypeLocInfo> {
1838public:
1839 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1840
1841 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1842
1844 return SourceRange(getNameLoc(), getNameLoc());
1845 }
1846
1848 setNameLoc(Loc);
1849 }
1850
1852
1853 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1854};
1855
1856// FIXME: size expression and attribute locations (or keyword if we
1857// ever fully support altivec syntax).
1859 : public ConcreteTypeLoc<UnqualTypeLoc, DependentVectorTypeLoc,
1860 DependentVectorType, VectorTypeLocInfo> {
1861public:
1862 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1863
1864 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1865
1867 return SourceRange(getNameLoc(), getNameLoc());
1868 }
1869
1871 setNameLoc(Loc);
1872 }
1873
1875
1876 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1877};
1878
1879// FIXME: size expression and attribute locations.
1881 : public InheritingConcreteTypeLoc<VectorTypeLoc, ExtVectorTypeLoc,
1882 ExtVectorType> {};
1883
1884// FIXME: attribute locations.
1885// For some reason, this isn't a subtype of VectorType.
1887 : public ConcreteTypeLoc<UnqualTypeLoc, DependentSizedExtVectorTypeLoc,
1888 DependentSizedExtVectorType, VectorTypeLocInfo> {
1889public:
1890 SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1891
1892 void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1893
1895 return SourceRange(getNameLoc(), getNameLoc());
1896 }
1897
1899 setNameLoc(Loc);
1900 }
1901
1903
1904 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
1905};
1906
1912};
1913
1914class MatrixTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, MatrixTypeLoc,
1915 MatrixType, MatrixTypeLocInfo> {
1916public:
1917 /// The location of the attribute name, i.e.
1918 /// float __attribute__((matrix_type(4, 2)))
1919 /// ^~~~~~~~~~~~~~~~~
1922
1923 /// The attribute's row operand, if it has one.
1924 /// float __attribute__((matrix_type(4, 2)))
1925 /// ^
1928
1929 /// The attribute's column operand, if it has one.
1930 /// float __attribute__((matrix_type(4, 2)))
1931 /// ^
1934
1935 /// The location of the parentheses around the operand, if there is
1936 /// an operand.
1937 /// float __attribute__((matrix_type(4, 2)))
1938 /// ^ ^
1940 return getLocalData()->OperandParens;
1941 }
1943 getLocalData()->OperandParens = range;
1944 }
1945
1947 SourceRange range(getAttrNameLoc());
1948 range.setEnd(getAttrOperandParensRange().getEnd());
1949 return range;
1950 }
1951
1953 setAttrNameLoc(loc);
1955 setAttrRowOperand(nullptr);
1956 setAttrColumnOperand(nullptr);
1957 }
1958};
1959
1961 : public InheritingConcreteTypeLoc<MatrixTypeLoc, ConstantMatrixTypeLoc,
1962 ConstantMatrixType> {};
1963
1965 : public InheritingConcreteTypeLoc<MatrixTypeLoc,
1966 DependentSizedMatrixTypeLoc,
1967 DependentSizedMatrixType> {};
1968
1969// FIXME: location of the '_Complex' keyword.
1970class ComplexTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1971 ComplexTypeLoc,
1972 ComplexType> {
1973};
1974
1979};
1980
1982};
1983
1986};
1987
1988template <class Derived, class TypeClass, class LocalData = TypeofLocInfo>
1990 : public ConcreteTypeLoc<UnqualTypeLoc, Derived, TypeClass, LocalData> {
1991public:
1993 return this->getLocalData()->TypeofLoc;
1994 }
1995
1997 this->getLocalData()->TypeofLoc = Loc;
1998 }
1999
2001 return this->getLocalData()->LParenLoc;
2002 }
2003
2005 this->getLocalData()->LParenLoc = Loc;
2006 }
2007
2009 return this->getLocalData()->RParenLoc;
2010 }
2011
2013 this->getLocalData()->RParenLoc = Loc;
2014 }
2015
2018 }
2019
2021 setLParenLoc(range.getBegin());
2022 setRParenLoc(range.getEnd());
2023 }
2024
2027 }
2028
2030 setTypeofLoc(Loc);
2031 setLParenLoc(Loc);
2032 setRParenLoc(Loc);
2033 }
2034};
2035
2036class TypeOfExprTypeLoc : public TypeofLikeTypeLoc<TypeOfExprTypeLoc,
2037 TypeOfExprType,
2038 TypeOfExprTypeLocInfo> {
2039public:
2041 return getTypePtr()->getUnderlyingExpr();
2042 }
2043
2044 // Reimplemented to account for GNU/C++ extension
2045 // typeof unary-expression
2046 // where there are no parentheses.
2048};
2049
2051 : public TypeofLikeTypeLoc<TypeOfTypeLoc, TypeOfType, TypeOfTypeLocInfo> {
2052public:
2054 return this->getTypePtr()->getUnmodifiedType();
2055 }
2056
2058 return this->getLocalData()->UnmodifiedTInfo;
2059 }
2060
2062 this->getLocalData()->UnmodifiedTInfo = TI;
2063 }
2064
2065 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2066};
2067
2068// decltype(expression) abc;
2069// ~~~~~~~~ DecltypeLoc
2070// ~ RParenLoc
2071// FIXME: add LParenLoc, it is tricky to support due to the limitation of
2072// annotated-decltype token.
2076};
2078 : public ConcreteTypeLoc<UnqualTypeLoc, DecltypeTypeLoc, DecltypeType,
2079 DecltypeTypeLocInfo> {
2080public:
2082
2085
2088
2091 }
2092
2094 setDecltypeLoc(Loc);
2095 setRParenLoc(Loc);
2096 }
2097};
2098
2101};
2102
2104 : public ConcreteTypeLoc<UnqualTypeLoc, PackIndexingTypeLoc,
2105 PackIndexingType, PackIndexingTypeLocInfo> {
2106
2107public:
2108 Expr *getIndexExpr() const { return getTypePtr()->getIndexExpr(); }
2109 QualType getPattern() const { return getTypePtr()->getPattern(); }
2110
2113
2115 setEllipsisLoc(Loc);
2116 }
2117
2119
2120 QualType getInnerType() const { return this->getTypePtr()->getPattern(); }
2121
2124 }
2125};
2126
2128 // FIXME: While there's only one unary transform right now, future ones may
2129 // need different representations
2132};
2133
2134class UnaryTransformTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2135 UnaryTransformTypeLoc,
2136 UnaryTransformType,
2137 UnaryTransformTypeLocInfo> {
2138public:
2141
2144
2147
2149 return getLocalData()->UnderlyingTInfo;
2150 }
2151
2153 getLocalData()->UnderlyingTInfo = TInfo;
2154 }
2155
2157 return SourceRange(getKWLoc(), getRParenLoc());
2158 }
2159
2162 }
2163
2165 setLParenLoc(Range.getBegin());
2166 setRParenLoc(Range.getEnd());
2167 }
2168
2169 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2170};
2171
2173 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DeducedTypeLoc,
2174 DeducedType> {};
2175
2177 // For decltype(auto).
2179
2181};
2182
2184 : public ConcreteTypeLoc<DeducedTypeLoc,
2185 AutoTypeLoc,
2186 AutoType,
2187 AutoTypeLocInfo> {
2188public:
2190 return getTypePtr()->getKeyword();
2191 }
2192
2193 bool isDecltypeAuto() const { return getTypePtr()->isDecltypeAuto(); }
2196
2197 bool isConstrained() const {
2198 return getTypePtr()->isConstrained();
2199 }
2200
2202
2204
2205 // FIXME: Several of the following functions can be removed. Instead the
2206 // caller can directly work with the ConceptReference.
2208 if (const auto *CR = getConceptReference())
2209 return CR->getNestedNameSpecifierLoc();
2210 return NestedNameSpecifierLoc();
2211 }
2212
2214 if (const auto *CR = getConceptReference())
2215 return CR->getTemplateKWLoc();
2216 return SourceLocation();
2217 }
2218
2220 if (const auto *CR = getConceptReference())
2221 return CR->getConceptNameLoc();
2222 return SourceLocation();
2223 }
2224
2226 if (const auto *CR = getConceptReference())
2227 return CR->getFoundDecl();
2228 return nullptr;
2229 }
2230
2232 if (const auto *CR = getConceptReference())
2233 return CR->getNamedConcept();
2234 return nullptr;
2235 }
2236
2239 }
2240
2242 return (getConceptReference() &&
2243 getConceptReference()->getTemplateArgsAsWritten() &&
2245 ->getTemplateArgsAsWritten()
2246 ->getLAngleLoc()
2247 .isValid());
2248 }
2249
2251 if (const auto *CR = getConceptReference())
2252 if (const auto *TAAW = CR->getTemplateArgsAsWritten())
2253 return TAAW->getLAngleLoc();
2254 return SourceLocation();
2255 }
2256
2258 if (const auto *CR = getConceptReference())
2259 if (const auto *TAAW = CR->getTemplateArgsAsWritten())
2260 return TAAW->getRAngleLoc();
2261 return SourceLocation();
2262 }
2263
2264 unsigned getNumArgs() const {
2265 return getTypePtr()->getTypeConstraintArguments().size();
2266 }
2267
2268 TemplateArgumentLoc getArgLoc(unsigned i) const {
2269 const auto *CR = getConceptReference();
2270 assert(CR && "No ConceptReference");
2271 return CR->getTemplateArgsAsWritten()->getTemplateArgs()[i];
2272 }
2273
2275 return {isConstrained()
2279 : getConceptNameLoc()))
2280 : getNameLoc(),
2282 }
2283
2284 void copy(AutoTypeLoc Loc) {
2285 unsigned size = getFullDataSize();
2286 assert(size == Loc.getFullDataSize());
2287 memcpy(Data, Loc.Data, size);
2288 }
2289
2290 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2291};
2292
2294 : public InheritingConcreteTypeLoc<DeducedTypeLoc,
2295 DeducedTemplateSpecializationTypeLoc,
2296 DeducedTemplateSpecializationType> {
2297public:
2299 return getNameLoc();
2300 }
2301
2303 setNameLoc(Loc);
2304 }
2305};
2306
2309
2310 /// Data associated with the nested-name-specifier location.
2312};
2313
2314class ElaboratedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2315 ElaboratedTypeLoc,
2316 ElaboratedType,
2317 ElaboratedLocInfo> {
2318public:
2321 }
2322
2324 if (isEmpty()) {
2325 assert(Loc.isInvalid());
2326 return;
2327 }
2329 }
2330
2332 return !isEmpty() ? NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2333 getLocalData()->QualifierData)
2335 }
2336
2338 assert(QualifierLoc.getNestedNameSpecifier() ==
2339 getTypePtr()->getQualifier() &&
2340 "Inconsistent nested-name-specifier pointer");
2341 if (isEmpty()) {
2342 assert(!QualifierLoc.hasQualifier());
2343 return;
2344 }
2345 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2346 }
2347
2349 if (getElaboratedKeywordLoc().isValid())
2350 if (getQualifierLoc())
2353 else
2355 else
2357 }
2358
2359 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2360
2362
2364
2365 bool isEmpty() const {
2368 }
2369
2370 unsigned getLocalDataAlignment() const {
2371 // FIXME: We want to return 1 here in the empty case, but
2372 // there are bugs in how alignment is handled in TypeLocs
2373 // that prevent this from working.
2375 }
2376
2377 unsigned getLocalDataSize() const {
2379 }
2380
2382 unsigned size = getFullDataSize();
2383 assert(size == Loc.getFullDataSize());
2384 memcpy(Data, Loc.Data, size);
2385 }
2386};
2387
2388// This is exactly the structure of an ElaboratedTypeLoc whose inner
2389// type is some sort of TypeDeclTypeLoc.
2392};
2393
2394class DependentNameTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
2395 DependentNameTypeLoc,
2396 DependentNameType,
2397 DependentNameLocInfo> {
2398public:
2400 return this->getLocalData()->ElaboratedKWLoc;
2401 }
2402
2404 this->getLocalData()->ElaboratedKWLoc = Loc;
2405 }
2406
2408 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2409 getLocalData()->QualifierData);
2410 }
2411
2413 assert(QualifierLoc.getNestedNameSpecifier()
2414 == getTypePtr()->getQualifier() &&
2415 "Inconsistent nested-name-specifier pointer");
2416 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2417 }
2418
2420 return this->getLocalData()->NameLoc;
2421 }
2422
2424 this->getLocalData()->NameLoc = Loc;
2425 }
2426
2428 if (getElaboratedKeywordLoc().isValid())
2430 else
2432 }
2433
2435 unsigned size = getFullDataSize();
2436 assert(size == Loc.getFullDataSize());
2437 memcpy(Data, Loc.Data, size);
2438 }
2439
2440 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2441};
2442
2447 // followed by a TemplateArgumentLocInfo[]
2448};
2449
2451 public ConcreteTypeLoc<UnqualTypeLoc,
2452 DependentTemplateSpecializationTypeLoc,
2453 DependentTemplateSpecializationType,
2454 DependentTemplateSpecializationLocInfo> {
2455public:
2457 return this->getLocalData()->ElaboratedKWLoc;
2458 }
2459
2461 this->getLocalData()->ElaboratedKWLoc = Loc;
2462 }
2463
2465 if (!getLocalData()->QualifierData)
2466 return NestedNameSpecifierLoc();
2467
2468 return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
2469 getLocalData()->QualifierData);
2470 }
2471
2473 if (!QualifierLoc) {
2474 // Even if we have a nested-name-specifier in the dependent
2475 // template specialization type, we won't record the nested-name-specifier
2476 // location information when this type-source location information is
2477 // part of a nested-name-specifier.
2478 getLocalData()->QualifierData = nullptr;
2479 return;
2480 }
2481
2482 assert(QualifierLoc.getNestedNameSpecifier()
2483 == getTypePtr()->getQualifier() &&
2484 "Inconsistent nested-name-specifier pointer");
2485 getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
2486 }
2487
2489 return getLocalData()->TemplateKWLoc;
2490 }
2491
2493 getLocalData()->TemplateKWLoc = Loc;
2494 }
2495
2497 return this->getLocalData()->NameLoc;
2498 }
2499
2501 this->getLocalData()->NameLoc = Loc;
2502 }
2503
2505 return this->getLocalData()->LAngleLoc;
2506 }
2507
2509 this->getLocalData()->LAngleLoc = Loc;
2510 }
2511
2513 return this->getLocalData()->RAngleLoc;
2514 }
2515
2517 this->getLocalData()->RAngleLoc = Loc;
2518 }
2519
2520 unsigned getNumArgs() const {
2521 return getTypePtr()->template_arguments().size();
2522 }
2523
2525 getArgInfos()[i] = AI;
2526 }
2527
2529 return getArgInfos()[i];
2530 }
2531
2532 TemplateArgumentLoc getArgLoc(unsigned i) const {
2533 return TemplateArgumentLoc(getTypePtr()->template_arguments()[i],
2534 getArgLocInfo(i));
2535 }
2536
2538 if (getElaboratedKeywordLoc().isValid())
2540 else if (getQualifierLoc())
2542 else if (getTemplateKeywordLoc().isValid())
2544 else
2546 }
2547
2549 unsigned size = getFullDataSize();
2550 assert(size == Loc.getFullDataSize());
2551 memcpy(Data, Loc.Data, size);
2552 }
2553
2554 void initializeLocal(ASTContext &Context, SourceLocation Loc);
2555
2556 unsigned getExtraLocalDataSize() const {
2557 return getNumArgs() * sizeof(TemplateArgumentLocInfo);
2558 }
2559
2561 return alignof(TemplateArgumentLocInfo);
2562 }
2563
2564private:
2565 TemplateArgumentLocInfo *getArgInfos() const {
2566 return static_cast<TemplateArgumentLocInfo*>(getExtraLocalData());
2567 }
2568};
2569
2572};
2573
2575 : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
2576 PackExpansionType, PackExpansionTypeLocInfo> {
2577public:
2579 return this->getLocalData()->EllipsisLoc;
2580 }
2581
2583 this->getLocalData()->EllipsisLoc = Loc;
2584 }
2585
2588 }
2589
2591 setEllipsisLoc(Loc);
2592 }
2593
2595 return getInnerTypeLoc();
2596 }
2597
2599 return this->getTypePtr()->getPattern();
2600 }
2601};
2602
2605};
2606
2607class AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc,
2608 AtomicType, AtomicTypeLocInfo> {
2609public:
2611 return this->getInnerTypeLoc();
2612 }
2613
2615 return SourceRange(getKWLoc(), getRParenLoc());
2616 }
2617
2619 return this->getLocalData()->KWLoc;
2620 }
2621
2623 this->getLocalData()->KWLoc = Loc;
2624 }
2625
2627 return this->getLocalData()->LParenLoc;
2628 }
2629
2631 this->getLocalData()->LParenLoc = Loc;
2632 }
2633
2635 return this->getLocalData()->RParenLoc;
2636 }
2637
2639 this->getLocalData()->RParenLoc = Loc;
2640 }
2641
2644 }
2645
2647 setLParenLoc(Range.getBegin());
2648 setRParenLoc(Range.getEnd());
2649 }
2650
2652 setKWLoc(Loc);
2653 setLParenLoc(Loc);
2654 setRParenLoc(Loc);
2655 }
2656
2658 return this->getTypePtr()->getValueType();
2659 }
2660};
2661
2664};
2665
2666class PipeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, PipeTypeLoc, PipeType,
2667 PipeTypeLocInfo> {
2668public:
2669 TypeLoc getValueLoc() const { return this->getInnerTypeLoc(); }
2670
2672
2673 SourceLocation getKWLoc() const { return this->getLocalData()->KWLoc; }
2674 void setKWLoc(SourceLocation Loc) { this->getLocalData()->KWLoc = Loc; }
2675
2677 setKWLoc(Loc);
2678 }
2679
2680 QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
2681};
2682
2683template <typename T>
2685 TypeLoc Cur = *this;
2686 while (!T::isKind(Cur)) {
2687 if (auto PTL = Cur.getAs<ParenTypeLoc>())
2688 Cur = PTL.getInnerLoc();
2689 else if (auto ATL = Cur.getAs<AttributedTypeLoc>())
2690 Cur = ATL.getModifiedLoc();
2691 else if (auto ATL = Cur.getAs<BTFTagAttributedTypeLoc>())
2692 Cur = ATL.getWrappedLoc();
2693 else if (auto ETL = Cur.getAs<ElaboratedTypeLoc>())
2694 Cur = ETL.getNamedTypeLoc();
2695 else if (auto ATL = Cur.getAs<AdjustedTypeLoc>())
2696 Cur = ATL.getOriginalLoc();
2697 else if (auto MQL = Cur.getAs<MacroQualifiedTypeLoc>())
2698 Cur = MQL.getInnerLoc();
2699 else
2700 break;
2701 }
2702 return Cur.getAs<T>();
2703}
2704class BitIntTypeLoc final
2705 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, BitIntTypeLoc,
2706 BitIntType> {};
2708 : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentBitIntTypeLoc,
2709 DependentBitIntType> {};
2710
2712 ObjCProtocolDecl *Protocol = nullptr;
2714
2715public:
2717 : Protocol(protocol), Loc(loc) {}
2718 ObjCProtocolDecl *getProtocol() const { return Protocol; }
2719 SourceLocation getLocation() const { return Loc; }
2720
2721 /// The source range is just the protocol name.
2722 SourceRange getSourceRange() const LLVM_READONLY {
2723 return SourceRange(Loc, Loc);
2724 }
2725};
2726
2727} // namespace clang
2728
2729#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:1244
unsigned getLocalDataSize() const
Definition: TypeLoc.h:1252
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1236
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1240
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1250
QualType getOriginalType() const
Definition: Type.h:3307
Wrapper for source info for array parameter types.
Definition: TypeLoc.h:1617
Wrapper for source info for arrays.
Definition: TypeLoc.h:1561
SourceLocation getLBracketLoc() const
Definition: TypeLoc.h:1563
Expr * getSizeExpr() const
Definition: TypeLoc.h:1583
void setLBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1567
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1591
void setRBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1575
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1599
SourceLocation getRBracketLoc() const
Definition: TypeLoc.h:1571
SourceRange getBracketsRange() const
Definition: TypeLoc.h:1579
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1595
QualType getInnerType() const
Definition: TypeLoc.h:1605
void setSizeExpr(Expr *Size)
Definition: TypeLoc.h:1587
QualType getElementType() const
Definition: Type.h:3526
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2634
QualType getInnerType() const
Definition: TypeLoc.h:2657
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2614
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2638
SourceRange getParensRange() const
Definition: TypeLoc.h:2642
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2610
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2630
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2622
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2651
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2618
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2626
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:2646
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:7185
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:5622
Kind getAttrKind() const
Definition: Type.h:5618
bool isQualifier() const
Does this attribute behave like a type qualifier?
Definition: Type.cpp:4023
bool hasExplicitTemplateArgs() const
Definition: TypeLoc.h:2241
SourceLocation getTemplateKWLoc() const
Definition: TypeLoc.h:2213
AutoTypeKeyword getAutoKeyword() const
Definition: TypeLoc.h:2189
const NestedNameSpecifierLoc getNestedNameSpecifierLoc() const
Definition: TypeLoc.h:2207
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:2257
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2194
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:657
ConceptDecl * getNamedConcept() const
Definition: TypeLoc.h:2231
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2274
void copy(AutoTypeLoc Loc)
Definition: TypeLoc.h:2284
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:2250
void setConceptReference(ConceptReference *CR)
Definition: TypeLoc.h:2201
SourceLocation getConceptNameLoc() const
Definition: TypeLoc.h:2219
NamedDecl * getFoundDecl() const
Definition: TypeLoc.h:2225
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:2268
bool isDecltypeAuto() const
Definition: TypeLoc.h:2193
bool isConstrained() const
Definition: TypeLoc.h:2197
unsigned getNumArgs() const
Definition: TypeLoc.h:2264
ConceptReference * getConceptReference() const
Definition: TypeLoc.h:2203
DeclarationNameInfo getConceptNameInfo() const
Definition: TypeLoc.h:2237
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2195
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
Definition: Type.h:5987
bool isDecltypeAuto() const
Definition: Type.h:6000
AutoTypeKeyword getKeyword() const
Definition: Type.h:6008
bool isConstrained() const
Definition: Type.h:5996
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:523
const BTFTypeTagAttr * getAttr() const
Definition: Type.h:5713
QualType getWrappedType() const
Definition: Type.h:5712
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1314
SourceLocation getCaretLoc() const
Definition: TypeLoc.h:1316
void setCaretLoc(SourceLocation Loc)
Definition: TypeLoc.h:1320
QualType getInnerType() const
Definition: TypeLoc.h:1129
unsigned getLocalDataSize() const
Definition: TypeLoc.h:1134
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1128
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1130
QualType desugar() const
Definition: Type.h:3205
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:3019
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
Expr * getCountExpr() const
Definition: TypeLoc.h:1142
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:519
bool isOrNull() const
Definition: Type.h:3271
bool isCountInBytes() const
Definition: Type.h:3270
Expr * getCountExpr() const
Definition: Type.h:3269
Wrapper for source info for pointers decayed from arrays and functions.
Definition: TypeLoc.h:1262
SourceLocation getDecltypeLoc() const
Definition: TypeLoc.h:2083
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2093
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:2081
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2086
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2087
void setDecltypeLoc(SourceLocation Loc)
Definition: TypeLoc.h:2084
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2089
Expr * getUnderlyingExpr() const
Definition: Type.h:5364
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2298
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2302
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1773
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1798
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1794
QualType getInnerType() const
Returns the type before the address space attribute application area.
Definition: TypeLoc.h:1808
Expr * getAttrExprOperand() const
The attribute's expression operand, if it has one.
Definition: TypeLoc.h:1780
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:1816
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:1791
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1770
QualType getPointeeType() const
Definition: Type.h:3867
void copy(DependentNameTypeLoc Loc)
Definition: TypeLoc.h:2434
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2407
SourceLocation getNameLoc() const
Definition: TypeLoc.h:2419
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:554
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2427
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2399
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2423
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2403
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2412
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1630
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1890
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1894
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1892
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1898
QualType getElementType() const
Definition: Type.h:3910
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2472
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:564
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2496
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2492
void copy(DependentTemplateSpecializationTypeLoc Loc)
Definition: TypeLoc.h:2548
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2488
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2460
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2516
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:2532
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:2528
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2456
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2508
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2524
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2500
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2464
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:6519
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1862
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1866
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1870
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1874
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1864
QualType getInnerType() const
Definition: TypeLoc.h:1876
QualType getElementType() const
Definition: Type.h:4029
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:544
bool isEmpty() const
Definition: TypeLoc.h:2365
unsigned getLocalDataAlignment() const
Definition: TypeLoc.h:2370
QualType getInnerType() const
Definition: TypeLoc.h:2363
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2319
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2331
void copy(ElaboratedTypeLoc Loc)
Definition: TypeLoc.h:2381
unsigned getLocalDataSize() const
Definition: TypeLoc.h:2377
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2348
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2323
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2361
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2337
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:6402
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:6405
Represents an enum.
Definition: Decl.h:3868
Wrapper for source info for enum types.
Definition: TypeLoc.h:749
EnumDecl * getDecl() const
Definition: TypeLoc.h:751
EnumDecl * getDecl() const
Definition: Type.h:5578
This represents one expression.
Definition: Expr.h:110
Wrapper for source info for functions.
Definition: TypeLoc.h:1428
ParmVarDecl ** getParmArray() const
Definition: TypeLoc.h:1496
QualType getInnerType() const
Definition: TypeLoc.h:1537
unsigned getNumParams() const
Definition: TypeLoc.h:1500
ParmVarDecl * getParam(unsigned i) const
Definition: TypeLoc.h:1506
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1452
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1448
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1464
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1480
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1507
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1491
SourceRange getParensRange() const
Definition: TypeLoc.h:1476
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1472
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1535
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1456
unsigned getExtraLocalDataSize() const
Returns the size of the type source info data block that is specific to this type.
Definition: TypeLoc.h:1530
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1486
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1509
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1444
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1513
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1460
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1468
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1517
QualType getReturnType() const
Definition: Type.h:4569
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:4094
void setAmpLoc(SourceLocation Loc)
Definition: TypeLoc.h:1398
SourceLocation getAmpLoc() const
Definition: TypeLoc.h:1394
const IdentifierInfo * getMacroIdentifier() const
Definition: TypeLoc.h:1163
SourceLocation getExpansionLoc() const
Definition: TypeLoc.h:1167
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1161
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1157
void setExpansionLoc(SourceLocation Loc)
Definition: TypeLoc.h:1171
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1177
QualType getInnerType() const
Definition: TypeLoc.h:1175
QualType getUnderlyingType() const
Definition: Type.h:5254
const IdentifierInfo * getMacroIdentifier() const
Definition: Type.h:5253
Expr * getAttrColumnOperand() const
The attribute's column operand, if it has one.
Definition: TypeLoc.h:1932
SourceRange getAttrOperandParensRange() const
The location of the parentheses around the operand, if there is an operand.
Definition: TypeLoc.h:1939
void setAttrRowOperand(Expr *e)
Definition: TypeLoc.h:1927
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1946
void setAttrColumnOperand(Expr *e)
Definition: TypeLoc.h:1933
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1942
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1921
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:1920
void initializeLocal(ASTContext &Context, SourceLocation loc)
Definition: TypeLoc.h:1952
Expr * getAttrRowOperand() const
The attribute's row operand, if it has one.
Definition: TypeLoc.h:1926
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1332
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1354
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1338
TypeSourceInfo * getClassTInfo() const
Definition: TypeLoc.h:1346
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1359
void setClassTInfo(TypeSourceInfo *TI)
Definition: TypeLoc.h:1350
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1334
const Type * getClass() const
Definition: TypeLoc.h:1342
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:1153
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:892
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1370
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1372
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1376
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:6860
QualType getBaseType() const
Gets the base type of this object type.
Definition: Type.h:6812
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2082
SourceLocation getLocation() const
Definition: TypeLoc.h:2719
ObjCProtocolLoc(ObjCProtocolDecl *protocol, SourceLocation loc)
Definition: TypeLoc.h:2716
ObjCProtocolDecl * getProtocol() const
Definition: TypeLoc.h:2718
SourceRange getSourceRange() const LLVM_READONLY
The source range is just the protocol name.
Definition: TypeLoc.h:2722
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
Definition: Type.h:6656
qual_iterator qual_begin() const
Definition: Type.h:6649
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:6718
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2586
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2582
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2578
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2594
QualType getInnerType() const
Definition: TypeLoc.h:2598
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2590
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:6586
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2111
Expr * getIndexExpr() const
Definition: TypeLoc.h:2108
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2118
QualType getPattern() const
Definition: TypeLoc.h:2109
QualType getInnerType() const
Definition: TypeLoc.h:2120
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2122
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2112
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2114
QualType getPattern() const
Definition: Type.h:5414
Expr * getIndexExpr() const
Definition: Type.h:5413
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1203
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1211
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1195
QualType getInnerType() const
Definition: TypeLoc.h:1220
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1191
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1207
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1216
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1199
QualType getInnerType() const
Definition: Type.h:3118
Represents a parameter to a function.
Definition: Decl.h:1761
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2669
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2676
QualType getInnerType() const
Definition: TypeLoc.h:2680
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2674
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2671
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2673
QualType getElementType() const
Definition: Type.h:7215
A base class for.
Definition: TypeLoc.h:1272
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1290
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1286
void setSigilLoc(SourceLocation Loc)
Definition: TypeLoc.h:1278
QualType getInnerType() const
Definition: TypeLoc.h:1294
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1282
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1274
Wrapper for source info for pointers.
Definition: TypeLoc.h:1301
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1303
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1307
A (possibly-)qualified type.
Definition: Type.h:940
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:1067
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:7355
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:989
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:1412
SourceLocation getAmpAmpLoc() const
Definition: TypeLoc.h:1408
Represents a struct/union/class.
Definition: Decl.h:4169
Wrapper for source info for record types.
Definition: TypeLoc.h:741
RecordDecl * getDecl() const
Definition: TypeLoc.h:743
RecordDecl * getDecl() const
Definition: Type.h:5555
QualType getInnerType() const
Definition: TypeLoc.h:1384
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:3585
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:3993
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
static void initializeArgLocs(ASTContext &Context, ArrayRef< TemplateArgument > Args, TemplateArgumentLocInfo *ArgInfos, SourceLocation Loc)
Definition: TypeLoc.cpp:582
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:1687
SourceLocation getLAngleLoc() const
Definition: TypeLoc.h:1667
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const
Definition: TypeLoc.h:1691
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1663
TemplateArgumentLoc getArgLoc(unsigned i) const
Definition: TypeLoc.h:1695
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1720
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:1675
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1704
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1671
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1700
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1727
void copy(TemplateSpecializationTypeLoc Loc)
Definition: TypeLoc.h:1709
unsigned getExtraLocalDataAlignment() const
Definition: TypeLoc.h:1745
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:1659
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1679
unsigned getExtraLocalDataSize() const
Definition: TypeLoc.h:1741
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:6153
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:5778
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:1225
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:739
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:746
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:2684
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:2040
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:527
void setUnmodifiedTInfo(TypeSourceInfo *TI) const
Definition: TypeLoc.h:2061
TypeSourceInfo * getUnmodifiedTInfo() const
Definition: TypeLoc.h:2057
QualType getUnmodifiedType() const
Definition: TypeLoc.h:2053
A container of type source information.
Definition: Type.h:7326
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:6325
The base class of the type hierarchy.
Definition: Type.h:1813
TypeClass getTypeClass() const
Definition: Type.h:2300
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3433
Wrapper for source info for typedefs.
Definition: TypeLoc.h:693
TypedefNameDecl * getTypedefNameDecl() const
Definition: TypeLoc.h:695
TypedefNameDecl * getDecl() const
Definition: Type.h:5213
void setParensRange(SourceRange range)
Definition: TypeLoc.h:2020
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2025
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2000
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2008
SourceRange getParensRange() const
Definition: TypeLoc.h:2016
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2004
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:1992
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:1996
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2012
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:2029
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2146
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:2164
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:535
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:2156
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2140
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2139
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2145
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:2148
SourceRange getParensRange() const
Definition: TypeLoc.h:2160
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:2152
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2143
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2142
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:5151
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3959
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3320
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:5180
QualType getUnderlyingType() const
Definition: Type.cpp:3827
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1851
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1841
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.h:1847
SourceRange getLocalSourceRange() const
Definition: TypeLoc.h:1843
QualType getInnerType() const
Definition: TypeLoc.h:1853
SourceLocation getNameLoc() const
Definition: TypeLoc.h:1839
QualType getElementType() const
Definition: Type.h:3979
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:1772
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:47
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:50
const FunctionProtoType * T
@ None
No keyword precedes the qualified type name.
@ Other
Other implicit parameter.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
#define bool
Definition: stdbool.h:20
SourceLocation LBracketLoc
Definition: TypeLoc.h:1553
SourceLocation RBracketLoc
Definition: TypeLoc.h:1553
SourceLocation KWLoc
Definition: TypeLoc.h:2604
SourceLocation RParenLoc
Definition: TypeLoc.h:2604
SourceLocation LParenLoc
Definition: TypeLoc.h:2604
const Attr * TypeAttr
Definition: TypeLoc.h:868
ConceptReference * CR
Definition: TypeLoc.h:2180
SourceLocation RParenLoc
Definition: TypeLoc.h:2178
SourceRange BuiltinRange
Definition: TypeLoc.h:558
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation RParenLoc
Definition: TypeLoc.h:2075
SourceLocation DecltypeLoc
Definition: TypeLoc.h:2074
SourceLocation NameLoc
Definition: TypeLoc.h:2391
SourceLocation ElaboratedKWLoc
Definition: TypeLoc.h:2308
void * QualifierData
Data associated with the nested-name-specifier location.
Definition: TypeLoc.h:2311
SourceLocation LParenLoc
Definition: TypeLoc.h:1419
SourceLocation RParenLoc
Definition: TypeLoc.h:1420
SourceLocation LocalRangeEnd
Definition: TypeLoc.h:1421
SourceLocation LocalRangeBegin
Definition: TypeLoc.h:1418
SourceLocation ExpansionLoc
Definition: TypeLoc.h:1150
SourceLocation AttrLoc
Definition: TypeLoc.h:1908
SourceRange OperandParens
Definition: TypeLoc.h:1909
TypeSourceInfo * ClassTInfo
Definition: TypeLoc.h:1326
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:2100
SourceLocation LParenLoc
Definition: TypeLoc.h:1183
SourceLocation RParenLoc
Definition: TypeLoc.h:1184
SourceLocation KWLoc
Definition: TypeLoc.h:2663
SourceLocation StarLoc
Definition: TypeLoc.h:1266
Location information for a TemplateArgument.
Definition: TemplateBase.h:472
SourceLocation NameLoc
Definition: TypeLoc.h:1644
TypeSourceInfo * UnmodifiedTInfo
Definition: TypeLoc.h:1985
SourceLocation NameLoc
Definition: TypeLoc.h:520
SourceLocation RParenLoc
Definition: TypeLoc.h:1978
SourceLocation LParenLoc
Definition: TypeLoc.h:1977
SourceLocation TypeofLoc
Definition: TypeLoc.h:1976
TypeSourceInfo * UnderlyingTInfo
Definition: TypeLoc.h:2131
SourceLocation NameLoc
Definition: TypeLoc.h:1833
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:106