1 //===- TypeLoc.cpp - Type Source Info Wrapper -----------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines the TypeLoc subclasses implementations.
11 //===----------------------------------------------------------------------===//
13 #include "clang/AST/TypeLoc.h"
14 #include "clang/AST/ASTConcept.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Attr.h"
17 #include "clang/AST/DeclTemplate.h"
18 #include "clang/AST/Expr.h"
19 #include "clang/AST/NestedNameSpecifier.h"
20 #include "clang/AST/TemplateBase.h"
21 #include "clang/AST/TemplateName.h"
22 #include "clang/AST/TypeLocVisitor.h"
23 #include "clang/Basic/SourceLocation.h"
24 #include "clang/Basic/Specifiers.h"
25 #include "llvm/Support/ErrorHandling.h"
26 #include "llvm/Support/MathExtras.h"
32 using namespace clang
;
34 static const unsigned TypeLocMaxDataAlign
= alignof(void *);
36 //===----------------------------------------------------------------------===//
37 // TypeLoc Implementation
38 //===----------------------------------------------------------------------===//
42 class TypeLocRanger
: public TypeLocVisitor
<TypeLocRanger
, SourceRange
> {
44 #define ABSTRACT_TYPELOC(CLASS, PARENT)
45 #define TYPELOC(CLASS, PARENT) \
46 SourceRange Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
47 return TyLoc.getLocalSourceRange(); \
49 #include "clang/AST/TypeLocNodes.def"
54 SourceRange
TypeLoc::getLocalSourceRangeImpl(TypeLoc TL
) {
55 if (TL
.isNull()) return SourceRange();
56 return TypeLocRanger().Visit(TL
);
61 class TypeAligner
: public TypeLocVisitor
<TypeAligner
, unsigned> {
63 #define ABSTRACT_TYPELOC(CLASS, PARENT)
64 #define TYPELOC(CLASS, PARENT) \
65 unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
66 return TyLoc.getLocalDataAlignment(); \
68 #include "clang/AST/TypeLocNodes.def"
73 /// Returns the alignment of the type source info data block.
74 unsigned TypeLoc::getLocalAlignmentForType(QualType Ty
) {
75 if (Ty
.isNull()) return 1;
76 return TypeAligner().Visit(TypeLoc(Ty
, nullptr));
81 class TypeSizer
: public TypeLocVisitor
<TypeSizer
, unsigned> {
83 #define ABSTRACT_TYPELOC(CLASS, PARENT)
84 #define TYPELOC(CLASS, PARENT) \
85 unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
86 return TyLoc.getLocalDataSize(); \
88 #include "clang/AST/TypeLocNodes.def"
93 /// Returns the size of the type source info data block.
94 unsigned TypeLoc::getFullDataSizeForType(QualType Ty
) {
96 TypeLoc
TyLoc(Ty
, nullptr);
97 unsigned MaxAlign
= 1;
98 while (!TyLoc
.isNull()) {
99 unsigned Align
= getLocalAlignmentForType(TyLoc
.getType());
100 MaxAlign
= std::max(Align
, MaxAlign
);
101 Total
= llvm::alignTo(Total
, Align
);
102 Total
+= TypeSizer().Visit(TyLoc
);
103 TyLoc
= TyLoc
.getNextTypeLoc();
105 Total
= llvm::alignTo(Total
, MaxAlign
);
111 class NextLoc
: public TypeLocVisitor
<NextLoc
, TypeLoc
> {
113 #define ABSTRACT_TYPELOC(CLASS, PARENT)
114 #define TYPELOC(CLASS, PARENT) \
115 TypeLoc Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
116 return TyLoc.getNextTypeLoc(); \
118 #include "clang/AST/TypeLocNodes.def"
123 /// Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
124 /// TypeLoc is a PointerLoc and next TypeLoc is for "int".
125 TypeLoc
TypeLoc::getNextTypeLocImpl(TypeLoc TL
) {
126 return NextLoc().Visit(TL
);
129 /// Initializes a type location, and all of its children
130 /// recursively, as if the entire tree had been written in the
132 void TypeLoc::initializeImpl(ASTContext
&Context
, TypeLoc TL
,
133 SourceLocation Loc
) {
135 switch (TL
.getTypeLocClass()) {
136 #define ABSTRACT_TYPELOC(CLASS, PARENT)
137 #define TYPELOC(CLASS, PARENT) \
139 CLASS##TypeLoc TLCasted = TL.castAs<CLASS##TypeLoc>(); \
140 TLCasted.initializeLocal(Context, Loc); \
141 TL = TLCasted.getNextTypeLoc(); \
145 #include "clang/AST/TypeLocNodes.def"
152 class TypeLocCopier
: public TypeLocVisitor
<TypeLocCopier
> {
156 TypeLocCopier(TypeLoc source
) : Source(source
) {}
158 #define ABSTRACT_TYPELOC(CLASS, PARENT)
159 #define TYPELOC(CLASS, PARENT) \
160 void Visit##CLASS##TypeLoc(CLASS##TypeLoc dest) { \
161 dest.copyLocal(Source.castAs<CLASS##TypeLoc>()); \
163 #include "clang/AST/TypeLocNodes.def"
168 void TypeLoc::copy(TypeLoc other
) {
169 assert(getFullDataSize() == other
.getFullDataSize());
171 // If both data pointers are aligned to the maximum alignment, we
172 // can memcpy because getFullDataSize() accurately reflects the
173 // layout of the data.
174 if (reinterpret_cast<uintptr_t>(Data
) ==
175 llvm::alignTo(reinterpret_cast<uintptr_t>(Data
),
176 TypeLocMaxDataAlign
) &&
177 reinterpret_cast<uintptr_t>(other
.Data
) ==
178 llvm::alignTo(reinterpret_cast<uintptr_t>(other
.Data
),
179 TypeLocMaxDataAlign
)) {
180 memcpy(Data
, other
.Data
, getFullDataSize());
184 // Copy each of the pieces.
185 TypeLoc
TL(getType(), Data
);
187 TypeLocCopier(other
).Visit(TL
);
188 other
= other
.getNextTypeLoc();
189 } while ((TL
= TL
.getNextTypeLoc()));
192 SourceLocation
TypeLoc::getBeginLoc() const {
194 TypeLoc LeftMost
= Cur
;
196 switch (Cur
.getTypeLocClass()) {
198 if (Cur
.getLocalSourceRange().getBegin().isValid()) {
202 Cur
= Cur
.getNextTypeLoc();
207 if (Cur
.castAs
<FunctionProtoTypeLoc
>().getTypePtr()
208 ->hasTrailingReturn()) {
213 case FunctionNoProto
:
215 case DependentSizedArray
:
216 case IncompleteArray
:
218 // FIXME: Currently QualifiedTypeLoc does not have a source range
220 Cur
= Cur
.getNextTypeLoc();
223 if (Cur
.getLocalSourceRange().getBegin().isValid())
225 Cur
= Cur
.getNextTypeLoc();
232 return LeftMost
.getLocalSourceRange().getBegin();
235 SourceLocation
TypeLoc::getEndLoc() const {
239 switch (Cur
.getTypeLocClass()) {
243 return Last
.getLocalSourceRange().getEnd();
246 case DependentSizedArray
:
247 case IncompleteArray
:
249 case FunctionNoProto
:
250 // The innermost type with suffix syntax always determines the end of the
255 if (Cur
.castAs
<FunctionProtoTypeLoc
>().getTypePtr()->hasTrailingReturn())
260 case ObjCObjectPointer
:
261 // `id` and `id<...>` have no star location.
262 if (Cur
.castAs
<ObjCObjectPointerTypeLoc
>().getStarLoc().isInvalid())
268 case LValueReference
:
269 case RValueReference
:
271 // Types with prefix syntax only determine the end of the type if there
272 // is no suffix type.
280 Cur
= Cur
.getNextTypeLoc();
286 struct TSTChecker
: public TypeLocVisitor
<TSTChecker
, bool> {
287 // Overload resolution does the real work for us.
288 static bool isTypeSpec(TypeSpecTypeLoc _
) { return true; }
289 static bool isTypeSpec(TypeLoc _
) { return false; }
291 #define ABSTRACT_TYPELOC(CLASS, PARENT)
292 #define TYPELOC(CLASS, PARENT) \
293 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
294 return isTypeSpec(TyLoc); \
296 #include "clang/AST/TypeLocNodes.def"
301 /// Determines if the given type loc corresponds to a
302 /// TypeSpecTypeLoc. Since there is not actually a TypeSpecType in
303 /// the type hierarchy, this is made somewhat complicated.
305 /// There are a lot of types that currently use TypeSpecTypeLoc
306 /// because it's a convenient base class. Ideally we would not accept
307 /// those here, but ideally we would have better implementations for
309 bool TypeSpecTypeLoc::isKind(const TypeLoc
&TL
) {
310 if (TL
.getType().hasLocalQualifiers()) return false;
311 return TSTChecker().Visit(TL
);
314 bool TagTypeLoc::isDefinition() const {
315 TagDecl
*D
= getDecl();
316 return D
->isCompleteDefinition() &&
317 (D
->getIdentifier() == nullptr || D
->getLocation() == getNameLoc());
320 // Reimplemented to account for GNU/C++ extension
321 // typeof unary-expression
322 // where there are no parentheses.
323 SourceRange
TypeOfExprTypeLoc::getLocalSourceRange() const {
324 if (getRParenLoc().isValid())
325 return SourceRange(getTypeofLoc(), getRParenLoc());
327 return SourceRange(getTypeofLoc(),
328 getUnderlyingExpr()->getSourceRange().getEnd());
332 TypeSpecifierType
BuiltinTypeLoc::getWrittenTypeSpec() const {
333 if (needsExtraLocalData())
334 return static_cast<TypeSpecifierType
>(getWrittenBuiltinSpecs().Type
);
335 switch (getTypePtr()->getKind()) {
336 case BuiltinType::Void
:
338 case BuiltinType::Bool
:
340 case BuiltinType::Char_U
:
341 case BuiltinType::Char_S
:
343 case BuiltinType::Char8
:
345 case BuiltinType::Char16
:
347 case BuiltinType::Char32
:
349 case BuiltinType::WChar_S
:
350 case BuiltinType::WChar_U
:
352 case BuiltinType::UChar
:
353 case BuiltinType::UShort
:
354 case BuiltinType::UInt
:
355 case BuiltinType::ULong
:
356 case BuiltinType::ULongLong
:
357 case BuiltinType::UInt128
:
358 case BuiltinType::SChar
:
359 case BuiltinType::Short
:
360 case BuiltinType::Int
:
361 case BuiltinType::Long
:
362 case BuiltinType::LongLong
:
363 case BuiltinType::Int128
:
364 case BuiltinType::Half
:
365 case BuiltinType::Float
:
366 case BuiltinType::Double
:
367 case BuiltinType::LongDouble
:
368 case BuiltinType::Float16
:
369 case BuiltinType::Float128
:
370 case BuiltinType::Ibm128
:
371 case BuiltinType::ShortAccum
:
372 case BuiltinType::Accum
:
373 case BuiltinType::LongAccum
:
374 case BuiltinType::UShortAccum
:
375 case BuiltinType::UAccum
:
376 case BuiltinType::ULongAccum
:
377 case BuiltinType::ShortFract
:
378 case BuiltinType::Fract
:
379 case BuiltinType::LongFract
:
380 case BuiltinType::UShortFract
:
381 case BuiltinType::UFract
:
382 case BuiltinType::ULongFract
:
383 case BuiltinType::SatShortAccum
:
384 case BuiltinType::SatAccum
:
385 case BuiltinType::SatLongAccum
:
386 case BuiltinType::SatUShortAccum
:
387 case BuiltinType::SatUAccum
:
388 case BuiltinType::SatULongAccum
:
389 case BuiltinType::SatShortFract
:
390 case BuiltinType::SatFract
:
391 case BuiltinType::SatLongFract
:
392 case BuiltinType::SatUShortFract
:
393 case BuiltinType::SatUFract
:
394 case BuiltinType::SatULongFract
:
395 case BuiltinType::BFloat16
:
396 llvm_unreachable("Builtin type needs extra local data!");
397 // Fall through, if the impossible happens.
399 case BuiltinType::NullPtr
:
400 case BuiltinType::Overload
:
401 case BuiltinType::Dependent
:
402 case BuiltinType::BoundMember
:
403 case BuiltinType::UnknownAny
:
404 case BuiltinType::ARCUnbridgedCast
:
405 case BuiltinType::PseudoObject
:
406 case BuiltinType::ObjCId
:
407 case BuiltinType::ObjCClass
:
408 case BuiltinType::ObjCSel
:
409 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
410 case BuiltinType::Id:
411 #include "clang/Basic/OpenCLImageTypes.def"
412 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
413 case BuiltinType::Id:
414 #include "clang/Basic/OpenCLExtensionTypes.def"
415 case BuiltinType::OCLSampler
:
416 case BuiltinType::OCLEvent
:
417 case BuiltinType::OCLClkEvent
:
418 case BuiltinType::OCLQueue
:
419 case BuiltinType::OCLReserveID
:
420 #define SVE_TYPE(Name, Id, SingletonId) \
421 case BuiltinType::Id:
422 #include "clang/Basic/AArch64SVEACLETypes.def"
423 #define PPC_VECTOR_TYPE(Name, Id, Size) \
424 case BuiltinType::Id:
425 #include "clang/Basic/PPCTypes.def"
426 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
427 #include "clang/Basic/RISCVVTypes.def"
428 #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
429 #include "clang/Basic/WebAssemblyReferenceTypes.def"
430 case BuiltinType::BuiltinFn
:
431 case BuiltinType::IncompleteMatrixIdx
:
432 case BuiltinType::OMPArraySection
:
433 case BuiltinType::OMPArrayShaping
:
434 case BuiltinType::OMPIterator
:
435 return TST_unspecified
;
438 llvm_unreachable("Invalid BuiltinType Kind!");
441 TypeLoc
TypeLoc::IgnoreParensImpl(TypeLoc TL
) {
442 while (ParenTypeLoc PTL
= TL
.getAs
<ParenTypeLoc
>())
443 TL
= PTL
.getInnerLoc();
447 SourceLocation
TypeLoc::findNullabilityLoc() const {
448 if (auto ATL
= getAs
<AttributedTypeLoc
>()) {
449 const Attr
*A
= ATL
.getAttr();
450 if (A
&& (isa
<TypeNullableAttr
>(A
) || isa
<TypeNonNullAttr
>(A
) ||
451 isa
<TypeNullUnspecifiedAttr
>(A
)))
452 return A
->getLocation();
458 TypeLoc
TypeLoc::findExplicitQualifierLoc() const {
460 if (auto qual
= getAs
<QualifiedTypeLoc
>())
463 TypeLoc loc
= IgnoreParens();
466 if (auto attr
= loc
.getAs
<AttributedTypeLoc
>()) {
467 if (attr
.isQualifier()) return attr
;
468 return attr
.getModifiedLoc().findExplicitQualifierLoc();
471 // C11 _Atomic types.
472 if (auto atomic
= loc
.getAs
<AtomicTypeLoc
>()) {
479 void ObjCTypeParamTypeLoc::initializeLocal(ASTContext
&Context
,
480 SourceLocation Loc
) {
482 if (!getNumProtocols()) return;
484 setProtocolLAngleLoc(Loc
);
485 setProtocolRAngleLoc(Loc
);
486 for (unsigned i
= 0, e
= getNumProtocols(); i
!= e
; ++i
)
487 setProtocolLoc(i
, Loc
);
490 void ObjCObjectTypeLoc::initializeLocal(ASTContext
&Context
,
491 SourceLocation Loc
) {
492 setHasBaseTypeAsWritten(true);
493 setTypeArgsLAngleLoc(Loc
);
494 setTypeArgsRAngleLoc(Loc
);
495 for (unsigned i
= 0, e
= getNumTypeArgs(); i
!= e
; ++i
) {
497 Context
.getTrivialTypeSourceInfo(
498 getTypePtr()->getTypeArgsAsWritten()[i
], Loc
));
500 setProtocolLAngleLoc(Loc
);
501 setProtocolRAngleLoc(Loc
);
502 for (unsigned i
= 0, e
= getNumProtocols(); i
!= e
; ++i
)
503 setProtocolLoc(i
, Loc
);
506 SourceRange
AttributedTypeLoc::getLocalSourceRange() const {
507 // Note that this does *not* include the range of the attribute
509 // __attribute__((foo(bar)))
510 // ^~~~~~~~~~~~~~~ ~~
514 // That enclosure doesn't necessarily belong to a single attribute
516 return getAttr() ? getAttr()->getRange() : SourceRange();
519 SourceRange
BTFTagAttributedTypeLoc::getLocalSourceRange() const {
520 return getAttr() ? getAttr()->getRange() : SourceRange();
523 void TypeOfTypeLoc::initializeLocal(ASTContext
&Context
,
524 SourceLocation Loc
) {
525 TypeofLikeTypeLoc
<TypeOfTypeLoc
, TypeOfType
, TypeOfTypeLocInfo
>
526 ::initializeLocal(Context
, Loc
);
527 this->getLocalData()->UnmodifiedTInfo
=
528 Context
.getTrivialTypeSourceInfo(getUnmodifiedType(), Loc
);
531 void UnaryTransformTypeLoc::initializeLocal(ASTContext
&Context
,
532 SourceLocation Loc
) {
536 this->setUnderlyingTInfo(
537 Context
.getTrivialTypeSourceInfo(getTypePtr()->getBaseType(), Loc
));
540 void ElaboratedTypeLoc::initializeLocal(ASTContext
&Context
,
541 SourceLocation Loc
) {
544 setElaboratedKeywordLoc(Loc
);
545 NestedNameSpecifierLocBuilder Builder
;
546 Builder
.MakeTrivial(Context
, getTypePtr()->getQualifier(), Loc
);
547 setQualifierLoc(Builder
.getWithLocInContext(Context
));
550 void DependentNameTypeLoc::initializeLocal(ASTContext
&Context
,
551 SourceLocation Loc
) {
552 setElaboratedKeywordLoc(Loc
);
553 NestedNameSpecifierLocBuilder Builder
;
554 Builder
.MakeTrivial(Context
, getTypePtr()->getQualifier(), Loc
);
555 setQualifierLoc(Builder
.getWithLocInContext(Context
));
560 DependentTemplateSpecializationTypeLoc::initializeLocal(ASTContext
&Context
,
561 SourceLocation Loc
) {
562 setElaboratedKeywordLoc(Loc
);
563 if (getTypePtr()->getQualifier()) {
564 NestedNameSpecifierLocBuilder Builder
;
565 Builder
.MakeTrivial(Context
, getTypePtr()->getQualifier(), Loc
);
566 setQualifierLoc(Builder
.getWithLocInContext(Context
));
568 setQualifierLoc(NestedNameSpecifierLoc());
570 setTemplateKeywordLoc(Loc
);
571 setTemplateNameLoc(Loc
);
574 TemplateSpecializationTypeLoc::initializeArgLocs(
575 Context
, getTypePtr()->template_arguments(), getArgInfos(), Loc
);
578 void TemplateSpecializationTypeLoc::initializeArgLocs(
579 ASTContext
&Context
, ArrayRef
<TemplateArgument
> Args
,
580 TemplateArgumentLocInfo
*ArgInfos
, SourceLocation Loc
) {
581 for (unsigned i
= 0, e
= Args
.size(); i
!= e
; ++i
) {
582 switch (Args
[i
].getKind()) {
583 case TemplateArgument::Null
:
584 llvm_unreachable("Impossible TemplateArgument");
586 case TemplateArgument::Integral
:
587 case TemplateArgument::Declaration
:
588 case TemplateArgument::NullPtr
:
589 ArgInfos
[i
] = TemplateArgumentLocInfo();
592 case TemplateArgument::Expression
:
593 ArgInfos
[i
] = TemplateArgumentLocInfo(Args
[i
].getAsExpr());
596 case TemplateArgument::Type
:
597 ArgInfos
[i
] = TemplateArgumentLocInfo(
598 Context
.getTrivialTypeSourceInfo(Args
[i
].getAsType(),
602 case TemplateArgument::Template
:
603 case TemplateArgument::TemplateExpansion
: {
604 NestedNameSpecifierLocBuilder Builder
;
605 TemplateName Template
= Args
[i
].getAsTemplateOrTemplatePattern();
606 if (DependentTemplateName
*DTN
= Template
.getAsDependentTemplateName())
607 Builder
.MakeTrivial(Context
, DTN
->getQualifier(), Loc
);
608 else if (QualifiedTemplateName
*QTN
= Template
.getAsQualifiedTemplateName())
609 Builder
.MakeTrivial(Context
, QTN
->getQualifier(), Loc
);
611 ArgInfos
[i
] = TemplateArgumentLocInfo(
612 Context
, Builder
.getWithLocInContext(Context
), Loc
,
613 Args
[i
].getKind() == TemplateArgument::Template
? SourceLocation()
618 case TemplateArgument::Pack
:
619 ArgInfos
[i
] = TemplateArgumentLocInfo();
625 // Builds a ConceptReference where all locations point at the same token,
626 // for use in trivial TypeSourceInfo for constrained AutoType
627 static ConceptReference
*createTrivialConceptReference(ASTContext
&Context
,
629 const AutoType
*AT
) {
630 DeclarationNameInfo DNI
=
631 DeclarationNameInfo(AT
->getTypeConstraintConcept()->getDeclName(), Loc
,
632 AT
->getTypeConstraintConcept()->getDeclName());
633 unsigned size
= AT
->getTypeConstraintArguments().size();
634 TemplateArgumentLocInfo
*TALI
= new TemplateArgumentLocInfo
[size
];
635 TemplateSpecializationTypeLoc::initializeArgLocs(
636 Context
, AT
->getTypeConstraintArguments(), TALI
, Loc
);
637 TemplateArgumentListInfo TAListI
;
638 for (unsigned i
= 0; i
< size
; ++i
) {
640 TemplateArgumentLoc(AT
->getTypeConstraintArguments()[i
],
641 TALI
[i
])); // TemplateArgumentLocInfo()
644 auto *ConceptRef
= ConceptReference::Create(
645 Context
, NestedNameSpecifierLoc
{}, Loc
, DNI
, nullptr,
646 AT
->getTypeConstraintConcept(),
647 ASTTemplateArgumentListInfo::Create(Context
, TAListI
));
652 void AutoTypeLoc::initializeLocal(ASTContext
&Context
, SourceLocation Loc
) {
655 setConceptReference(nullptr);
656 if (getTypePtr()->isConstrained()) {
658 createTrivialConceptReference(Context
, Loc
, getTypePtr()));
664 class GetContainedAutoTypeLocVisitor
:
665 public TypeLocVisitor
<GetContainedAutoTypeLocVisitor
, TypeLoc
> {
667 using TypeLocVisitor
<GetContainedAutoTypeLocVisitor
, TypeLoc
>::Visit
;
669 TypeLoc
VisitAutoTypeLoc(AutoTypeLoc TL
) {
673 // Only these types can contain the desired 'auto' type.
675 TypeLoc
VisitElaboratedTypeLoc(ElaboratedTypeLoc T
) {
676 return Visit(T
.getNamedTypeLoc());
679 TypeLoc
VisitQualifiedTypeLoc(QualifiedTypeLoc T
) {
680 return Visit(T
.getUnqualifiedLoc());
683 TypeLoc
VisitPointerTypeLoc(PointerTypeLoc T
) {
684 return Visit(T
.getPointeeLoc());
687 TypeLoc
VisitBlockPointerTypeLoc(BlockPointerTypeLoc T
) {
688 return Visit(T
.getPointeeLoc());
691 TypeLoc
VisitReferenceTypeLoc(ReferenceTypeLoc T
) {
692 return Visit(T
.getPointeeLoc());
695 TypeLoc
VisitMemberPointerTypeLoc(MemberPointerTypeLoc T
) {
696 return Visit(T
.getPointeeLoc());
699 TypeLoc
VisitArrayTypeLoc(ArrayTypeLoc T
) {
700 return Visit(T
.getElementLoc());
703 TypeLoc
VisitFunctionTypeLoc(FunctionTypeLoc T
) {
704 return Visit(T
.getReturnLoc());
707 TypeLoc
VisitParenTypeLoc(ParenTypeLoc T
) {
708 return Visit(T
.getInnerLoc());
711 TypeLoc
VisitAttributedTypeLoc(AttributedTypeLoc T
) {
712 return Visit(T
.getModifiedLoc());
715 TypeLoc
VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc T
) {
716 return Visit(T
.getWrappedLoc());
719 TypeLoc
VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc T
) {
720 return Visit(T
.getInnerLoc());
723 TypeLoc
VisitAdjustedTypeLoc(AdjustedTypeLoc T
) {
724 return Visit(T
.getOriginalLoc());
727 TypeLoc
VisitPackExpansionTypeLoc(PackExpansionTypeLoc T
) {
728 return Visit(T
.getPatternLoc());
734 AutoTypeLoc
TypeLoc::getContainedAutoTypeLoc() const {
735 TypeLoc Res
= GetContainedAutoTypeLocVisitor().Visit(*this);
737 return AutoTypeLoc();
738 return Res
.getAs
<AutoTypeLoc
>();