clang 17.0.0git
TypeLoc.cpp
Go to the documentation of this file.
1//===- TypeLoc.cpp - Type Source Info Wrapper -----------------------------===//
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// This file defines the TypeLoc subclasses implementations.
10//
11//===----------------------------------------------------------------------===//
12
13#include "clang/AST/TypeLoc.h"
16#include "clang/AST/Attr.h"
17#include "clang/AST/Expr.h"
24#include "llvm/Support/ErrorHandling.h"
25#include "llvm/Support/MathExtras.h"
26#include <algorithm>
27#include <cassert>
28#include <cstdint>
29#include <cstring>
30
31using namespace clang;
32
33static const unsigned TypeLocMaxDataAlign = alignof(void *);
34
35//===----------------------------------------------------------------------===//
36// TypeLoc Implementation
37//===----------------------------------------------------------------------===//
38
39namespace {
40
41class TypeLocRanger : public TypeLocVisitor<TypeLocRanger, SourceRange> {
42public:
43#define ABSTRACT_TYPELOC(CLASS, PARENT)
44#define TYPELOC(CLASS, PARENT) \
45 SourceRange Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
46 return TyLoc.getLocalSourceRange(); \
47 }
48#include "clang/AST/TypeLocNodes.def"
49};
50
51} // namespace
52
53SourceRange TypeLoc::getLocalSourceRangeImpl(TypeLoc TL) {
54 if (TL.isNull()) return SourceRange();
55 return TypeLocRanger().Visit(TL);
56}
57
58namespace {
59
60class TypeAligner : public TypeLocVisitor<TypeAligner, unsigned> {
61public:
62#define ABSTRACT_TYPELOC(CLASS, PARENT)
63#define TYPELOC(CLASS, PARENT) \
64 unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
65 return TyLoc.getLocalDataAlignment(); \
66 }
67#include "clang/AST/TypeLocNodes.def"
68};
69
70} // namespace
71
72/// Returns the alignment of the type source info data block.
74 if (Ty.isNull()) return 1;
75 return TypeAligner().Visit(TypeLoc(Ty, nullptr));
76}
77
78namespace {
79
80class TypeSizer : public TypeLocVisitor<TypeSizer, unsigned> {
81public:
82#define ABSTRACT_TYPELOC(CLASS, PARENT)
83#define TYPELOC(CLASS, PARENT) \
84 unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
85 return TyLoc.getLocalDataSize(); \
86 }
87#include "clang/AST/TypeLocNodes.def"
88};
89
90} // namespace
91
92/// Returns the size of the type source info data block.
94 unsigned Total = 0;
95 TypeLoc TyLoc(Ty, nullptr);
96 unsigned MaxAlign = 1;
97 while (!TyLoc.isNull()) {
98 unsigned Align = getLocalAlignmentForType(TyLoc.getType());
99 MaxAlign = std::max(Align, MaxAlign);
100 Total = llvm::alignTo(Total, Align);
101 Total += TypeSizer().Visit(TyLoc);
102 TyLoc = TyLoc.getNextTypeLoc();
103 }
104 Total = llvm::alignTo(Total, MaxAlign);
105 return Total;
106}
107
108namespace {
109
110class NextLoc : public TypeLocVisitor<NextLoc, TypeLoc> {
111public:
112#define ABSTRACT_TYPELOC(CLASS, PARENT)
113#define TYPELOC(CLASS, PARENT) \
114 TypeLoc Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
115 return TyLoc.getNextTypeLoc(); \
116 }
117#include "clang/AST/TypeLocNodes.def"
118};
119
120} // namespace
121
122/// Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
123/// TypeLoc is a PointerLoc and next TypeLoc is for "int".
124TypeLoc TypeLoc::getNextTypeLocImpl(TypeLoc TL) {
125 return NextLoc().Visit(TL);
126}
127
128/// Initializes a type location, and all of its children
129/// recursively, as if the entire tree had been written in the
130/// given location.
131void TypeLoc::initializeImpl(ASTContext &Context, TypeLoc TL,
132 SourceLocation Loc) {
133 while (true) {
134 switch (TL.getTypeLocClass()) {
135#define ABSTRACT_TYPELOC(CLASS, PARENT)
136#define TYPELOC(CLASS, PARENT) \
137 case CLASS: { \
138 CLASS##TypeLoc TLCasted = TL.castAs<CLASS##TypeLoc>(); \
139 TLCasted.initializeLocal(Context, Loc); \
140 TL = TLCasted.getNextTypeLoc(); \
141 if (!TL) return; \
142 continue; \
143 }
144#include "clang/AST/TypeLocNodes.def"
145 }
146 }
147}
148
149namespace {
150
151class TypeLocCopier : public TypeLocVisitor<TypeLocCopier> {
152 TypeLoc Source;
153
154public:
155 TypeLocCopier(TypeLoc source) : Source(source) {}
156
157#define ABSTRACT_TYPELOC(CLASS, PARENT)
158#define TYPELOC(CLASS, PARENT) \
159 void Visit##CLASS##TypeLoc(CLASS##TypeLoc dest) { \
160 dest.copyLocal(Source.castAs<CLASS##TypeLoc>()); \
161 }
162#include "clang/AST/TypeLocNodes.def"
163};
164
165} // namespace
166
168 assert(getFullDataSize() == other.getFullDataSize());
169
170 // If both data pointers are aligned to the maximum alignment, we
171 // can memcpy because getFullDataSize() accurately reflects the
172 // layout of the data.
173 if (reinterpret_cast<uintptr_t>(Data) ==
174 llvm::alignTo(reinterpret_cast<uintptr_t>(Data),
176 reinterpret_cast<uintptr_t>(other.Data) ==
177 llvm::alignTo(reinterpret_cast<uintptr_t>(other.Data),
179 memcpy(Data, other.Data, getFullDataSize());
180 return;
181 }
182
183 // Copy each of the pieces.
184 TypeLoc TL(getType(), Data);
185 do {
186 TypeLocCopier(other).Visit(TL);
187 other = other.getNextTypeLoc();
188 } while ((TL = TL.getNextTypeLoc()));
189}
190
192 TypeLoc Cur = *this;
193 TypeLoc LeftMost = Cur;
194 while (true) {
195 switch (Cur.getTypeLocClass()) {
196 case Elaborated:
197 if (Cur.getLocalSourceRange().getBegin().isValid()) {
198 LeftMost = Cur;
199 break;
200 }
201 Cur = Cur.getNextTypeLoc();
202 if (Cur.isNull())
203 break;
204 continue;
205 case FunctionProto:
207 ->hasTrailingReturn()) {
208 LeftMost = Cur;
209 break;
210 }
211 [[fallthrough]];
212 case FunctionNoProto:
213 case ConstantArray:
214 case DependentSizedArray:
215 case IncompleteArray:
216 case VariableArray:
217 // FIXME: Currently QualifiedTypeLoc does not have a source range
218 case Qualified:
219 Cur = Cur.getNextTypeLoc();
220 continue;
221 default:
223 LeftMost = Cur;
224 Cur = Cur.getNextTypeLoc();
225 if (Cur.isNull())
226 break;
227 continue;
228 } // switch
229 break;
230 } // while
231 return LeftMost.getLocalSourceRange().getBegin();
232}
233
235 TypeLoc Cur = *this;
237 while (true) {
238 switch (Cur.getTypeLocClass()) {
239 default:
240 if (!Last)
241 Last = Cur;
242 return Last.getLocalSourceRange().getEnd();
243 case Paren:
244 case ConstantArray:
245 case DependentSizedArray:
246 case IncompleteArray:
247 case VariableArray:
248 case FunctionNoProto:
249 // The innermost type with suffix syntax always determines the end of the
250 // type.
251 Last = Cur;
252 break;
253 case FunctionProto:
255 Last = TypeLoc();
256 else
257 Last = Cur;
258 break;
259 case ObjCObjectPointer:
260 // `id` and `id<...>` have no star location.
262 break;
263 [[fallthrough]];
264 case Pointer:
265 case BlockPointer:
266 case MemberPointer:
267 case LValueReference:
268 case RValueReference:
269 case PackExpansion:
270 // Types with prefix syntax only determine the end of the type if there
271 // is no suffix type.
272 if (!Last)
273 Last = Cur;
274 break;
275 case Qualified:
276 case Elaborated:
277 break;
278 }
279 Cur = Cur.getNextTypeLoc();
280 }
281}
282
283namespace {
284
285struct TSTChecker : public TypeLocVisitor<TSTChecker, bool> {
286 // Overload resolution does the real work for us.
287 static bool isTypeSpec(TypeSpecTypeLoc _) { return true; }
288 static bool isTypeSpec(TypeLoc _) { return false; }
289
290#define ABSTRACT_TYPELOC(CLASS, PARENT)
291#define TYPELOC(CLASS, PARENT) \
292 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
293 return isTypeSpec(TyLoc); \
294 }
295#include "clang/AST/TypeLocNodes.def"
296};
297
298} // namespace
299
300/// Determines if the given type loc corresponds to a
301/// TypeSpecTypeLoc. Since there is not actually a TypeSpecType in
302/// the type hierarchy, this is made somewhat complicated.
303///
304/// There are a lot of types that currently use TypeSpecTypeLoc
305/// because it's a convenient base class. Ideally we would not accept
306/// those here, but ideally we would have better implementations for
307/// them.
308bool TypeSpecTypeLoc::isKind(const TypeLoc &TL) {
309 if (TL.getType().hasLocalQualifiers()) return false;
310 return TSTChecker().Visit(TL);
311}
312
314 TagDecl *D = getDecl();
315 return D->isCompleteDefinition() &&
316 (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
317}
318
319// Reimplemented to account for GNU/C++ extension
320// typeof unary-expression
321// where there are no parentheses.
323 if (getRParenLoc().isValid())
325 else
326 return SourceRange(getTypeofLoc(),
327 getUnderlyingExpr()->getSourceRange().getEnd());
328}
329
330
333 return static_cast<TypeSpecifierType>(getWrittenBuiltinSpecs().Type);
334 switch (getTypePtr()->getKind()) {
335 case BuiltinType::Void:
336 return TST_void;
337 case BuiltinType::Bool:
338 return TST_bool;
339 case BuiltinType::Char_U:
340 case BuiltinType::Char_S:
341 return TST_char;
342 case BuiltinType::Char8:
343 return TST_char8;
344 case BuiltinType::Char16:
345 return TST_char16;
346 case BuiltinType::Char32:
347 return TST_char32;
348 case BuiltinType::WChar_S:
349 case BuiltinType::WChar_U:
350 return TST_wchar;
351 case BuiltinType::UChar:
352 case BuiltinType::UShort:
353 case BuiltinType::UInt:
354 case BuiltinType::ULong:
355 case BuiltinType::ULongLong:
356 case BuiltinType::UInt128:
357 case BuiltinType::SChar:
358 case BuiltinType::Short:
359 case BuiltinType::Int:
360 case BuiltinType::Long:
361 case BuiltinType::LongLong:
362 case BuiltinType::Int128:
363 case BuiltinType::Half:
364 case BuiltinType::Float:
365 case BuiltinType::Double:
366 case BuiltinType::LongDouble:
367 case BuiltinType::Float16:
368 case BuiltinType::Float128:
369 case BuiltinType::Ibm128:
370 case BuiltinType::ShortAccum:
371 case BuiltinType::Accum:
372 case BuiltinType::LongAccum:
373 case BuiltinType::UShortAccum:
374 case BuiltinType::UAccum:
375 case BuiltinType::ULongAccum:
376 case BuiltinType::ShortFract:
377 case BuiltinType::Fract:
378 case BuiltinType::LongFract:
379 case BuiltinType::UShortFract:
380 case BuiltinType::UFract:
381 case BuiltinType::ULongFract:
382 case BuiltinType::SatShortAccum:
383 case BuiltinType::SatAccum:
384 case BuiltinType::SatLongAccum:
385 case BuiltinType::SatUShortAccum:
386 case BuiltinType::SatUAccum:
387 case BuiltinType::SatULongAccum:
388 case BuiltinType::SatShortFract:
389 case BuiltinType::SatFract:
390 case BuiltinType::SatLongFract:
391 case BuiltinType::SatUShortFract:
392 case BuiltinType::SatUFract:
393 case BuiltinType::SatULongFract:
394 case BuiltinType::BFloat16:
395 llvm_unreachable("Builtin type needs extra local data!");
396 // Fall through, if the impossible happens.
397
398 case BuiltinType::NullPtr:
399 case BuiltinType::Overload:
400 case BuiltinType::Dependent:
401 case BuiltinType::BoundMember:
402 case BuiltinType::UnknownAny:
403 case BuiltinType::ARCUnbridgedCast:
404 case BuiltinType::PseudoObject:
405 case BuiltinType::ObjCId:
406 case BuiltinType::ObjCClass:
407 case BuiltinType::ObjCSel:
408#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
409 case BuiltinType::Id:
410#include "clang/Basic/OpenCLImageTypes.def"
411#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
412 case BuiltinType::Id:
413#include "clang/Basic/OpenCLExtensionTypes.def"
414 case BuiltinType::OCLSampler:
415 case BuiltinType::OCLEvent:
416 case BuiltinType::OCLClkEvent:
417 case BuiltinType::OCLQueue:
418 case BuiltinType::OCLReserveID:
419#define SVE_TYPE(Name, Id, SingletonId) \
420 case BuiltinType::Id:
421#include "clang/Basic/AArch64SVEACLETypes.def"
422#define PPC_VECTOR_TYPE(Name, Id, Size) \
423 case BuiltinType::Id:
424#include "clang/Basic/PPCTypes.def"
425#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
426#include "clang/Basic/RISCVVTypes.def"
427#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
428#include "clang/Basic/WebAssemblyReferenceTypes.def"
429 case BuiltinType::BuiltinFn:
430 case BuiltinType::IncompleteMatrixIdx:
431 case BuiltinType::OMPArraySection:
432 case BuiltinType::OMPArrayShaping:
433 case BuiltinType::OMPIterator:
434 return TST_unspecified;
435 }
436
437 llvm_unreachable("Invalid BuiltinType Kind!");
438}
439
440TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) {
441 while (ParenTypeLoc PTL = TL.getAs<ParenTypeLoc>())
442 TL = PTL.getInnerLoc();
443 return TL;
444}
445
447 if (auto ATL = getAs<AttributedTypeLoc>()) {
448 const Attr *A = ATL.getAttr();
449 if (A && (isa<TypeNullableAttr>(A) || isa<TypeNonNullAttr>(A) ||
450 isa<TypeNullUnspecifiedAttr>(A)))
451 return A->getLocation();
452 }
453
454 return {};
455}
456
458 // Qualified types.
459 if (auto qual = getAs<QualifiedTypeLoc>())
460 return qual;
461
462 TypeLoc loc = IgnoreParens();
463
464 // Attributed types.
465 if (auto attr = loc.getAs<AttributedTypeLoc>()) {
466 if (attr.isQualifier()) return attr;
467 return attr.getModifiedLoc().findExplicitQualifierLoc();
468 }
469
470 // C11 _Atomic types.
471 if (auto atomic = loc.getAs<AtomicTypeLoc>()) {
472 return atomic;
473 }
474
475 return {};
476}
477
479 SourceLocation Loc) {
480 setNameLoc(Loc);
481 if (!getNumProtocols()) return;
482
485 for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
486 setProtocolLoc(i, Loc);
487}
488
490 SourceLocation Loc) {
494 for (unsigned i = 0, e = getNumTypeArgs(); i != e; ++i) {
497 getTypePtr()->getTypeArgsAsWritten()[i], Loc));
498 }
501 for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
502 setProtocolLoc(i, Loc);
503}
504
506 // Note that this does *not* include the range of the attribute
507 // enclosure, e.g.:
508 // __attribute__((foo(bar)))
509 // ^~~~~~~~~~~~~~~ ~~
510 // or
511 // [[foo(bar)]]
512 // ^~ ~~
513 // That enclosure doesn't necessarily belong to a single attribute
514 // anyway.
515 return getAttr() ? getAttr()->getRange() : SourceRange();
516}
517
519 return getAttr() ? getAttr()->getRange() : SourceRange();
520}
521
523 SourceLocation Loc) {
525 ::initializeLocal(Context, Loc);
526 this->getLocalData()->UnmodifiedTInfo =
528}
529
531 SourceLocation Loc) {
532 setKWLoc(Loc);
533 setRParenLoc(Loc);
534 setLParenLoc(Loc);
535 this->setUnderlyingTInfo(
536 Context.getTrivialTypeSourceInfo(getTypePtr()->getBaseType(), Loc));
537}
538
540 SourceLocation Loc) {
541 if (isEmpty())
542 return;
545 Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
546 setQualifierLoc(Builder.getWithLocInContext(Context));
547}
548
550 SourceLocation Loc) {
553 Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
554 setQualifierLoc(Builder.getWithLocInContext(Context));
555 setNameLoc(Loc);
556}
557
558void
560 SourceLocation Loc) {
562 if (getTypePtr()->getQualifier()) {
564 Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
565 setQualifierLoc(Builder.getWithLocInContext(Context));
566 } else {
568 }
571 setLAngleLoc(Loc);
572 setRAngleLoc(Loc);
574 Context, getTypePtr()->template_arguments(), getArgInfos(), Loc);
575}
576
580 for (unsigned i = 0, e = Args.size(); i != e; ++i) {
581 switch (Args[i].getKind()) {
583 llvm_unreachable("Impossible TemplateArgument");
584
588 ArgInfos[i] = TemplateArgumentLocInfo();
589 break;
590
592 ArgInfos[i] = TemplateArgumentLocInfo(Args[i].getAsExpr());
593 break;
594
596 ArgInfos[i] = TemplateArgumentLocInfo(
597 Context.getTrivialTypeSourceInfo(Args[i].getAsType(),
598 Loc));
599 break;
600
604 TemplateName Template = Args[i].getAsTemplateOrTemplatePattern();
606 Builder.MakeTrivial(Context, DTN->getQualifier(), Loc);
607 else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
608 Builder.MakeTrivial(Context, QTN->getQualifier(), Loc);
609
610 ArgInfos[i] = TemplateArgumentLocInfo(
611 Context, Builder.getWithLocInContext(Context), Loc,
612 Args[i].getKind() == TemplateArgument::Template ? SourceLocation()
613 : Loc);
614 break;
615 }
616
618 ArgInfos[i] = TemplateArgumentLocInfo();
619 break;
620 }
621 }
622}
623
625 return DeclarationNameInfo(getNamedConcept()->getDeclName(),
626 getLocalData()->ConceptNameLoc);
627}
628
631 setTemplateKWLoc(Loc);
633 setFoundDecl(nullptr);
634 setRAngleLoc(Loc);
635 setLAngleLoc(Loc);
636 setRParenLoc(Loc);
638 Context, getTypePtr()->getTypeConstraintArguments(), getArgInfos(), Loc);
639 setNameLoc(Loc);
640}
641
642
643namespace {
644
645 class GetContainedAutoTypeLocVisitor :
646 public TypeLocVisitor<GetContainedAutoTypeLocVisitor, TypeLoc> {
647 public:
648 using TypeLocVisitor<GetContainedAutoTypeLocVisitor, TypeLoc>::Visit;
649
650 TypeLoc VisitAutoTypeLoc(AutoTypeLoc TL) {
651 return TL;
652 }
653
654 // Only these types can contain the desired 'auto' type.
655
656 TypeLoc VisitElaboratedTypeLoc(ElaboratedTypeLoc T) {
657 return Visit(T.getNamedTypeLoc());
658 }
659
660 TypeLoc VisitQualifiedTypeLoc(QualifiedTypeLoc T) {
661 return Visit(T.getUnqualifiedLoc());
662 }
663
664 TypeLoc VisitPointerTypeLoc(PointerTypeLoc T) {
665 return Visit(T.getPointeeLoc());
666 }
667
668 TypeLoc VisitBlockPointerTypeLoc(BlockPointerTypeLoc T) {
669 return Visit(T.getPointeeLoc());
670 }
671
672 TypeLoc VisitReferenceTypeLoc(ReferenceTypeLoc T) {
673 return Visit(T.getPointeeLoc());
674 }
675
676 TypeLoc VisitMemberPointerTypeLoc(MemberPointerTypeLoc T) {
677 return Visit(T.getPointeeLoc());
678 }
679
680 TypeLoc VisitArrayTypeLoc(ArrayTypeLoc T) {
681 return Visit(T.getElementLoc());
682 }
683
684 TypeLoc VisitFunctionTypeLoc(FunctionTypeLoc T) {
685 return Visit(T.getReturnLoc());
686 }
687
688 TypeLoc VisitParenTypeLoc(ParenTypeLoc T) {
689 return Visit(T.getInnerLoc());
690 }
691
692 TypeLoc VisitAttributedTypeLoc(AttributedTypeLoc T) {
693 return Visit(T.getModifiedLoc());
694 }
695
696 TypeLoc VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc T) {
697 return Visit(T.getWrappedLoc());
698 }
699
700 TypeLoc VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc T) {
701 return Visit(T.getInnerLoc());
702 }
703
704 TypeLoc VisitAdjustedTypeLoc(AdjustedTypeLoc T) {
705 return Visit(T.getOriginalLoc());
706 }
707
708 TypeLoc VisitPackExpansionTypeLoc(PackExpansionTypeLoc T) {
709 return Visit(T.getPatternLoc());
710 }
711 };
712
713} // namespace
714
716 TypeLoc Res = GetContainedAutoTypeLocVisitor().Visit(*this);
717 if (Res.isNull())
718 return AutoTypeLoc();
719 return Res.getAs<AutoTypeLoc>();
720}
Defines the clang::ASTContext interface.
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:1025
Defines the C++ template declaration subclasses.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
static const unsigned TypeLocMaxDataAlign
Definition: TypeLoc.cpp:33
Defines the clang::TypeLoc interface and its subclasses.
__DEVICE__ void * memcpy(void *__a, const void *__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
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1194
Wrapper for source info for arrays.
Definition: TypeLoc.h:1519
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1549
Attr - This represents one attribute.
Definition: Attr.h:40
SourceLocation getLocation() const
Definition: Attr.h:87
Type source information for an attributed type.
Definition: TypeLoc.h:863
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:882
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:877
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:505
DeclarationNameInfo getConceptNameInfo() const
Definition: TypeLoc.cpp:624
void setConceptNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2153
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:629
void setFoundDecl(NamedDecl *D)
Definition: TypeLoc.h:2161
ConceptDecl * getNamedConcept() const
Definition: TypeLoc.h:2165
void setTemplateKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2145
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2179
void setNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Definition: TypeLoc.h:2137
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2187
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2127
Type source information for an btf_tag attributed type.
Definition: TypeLoc.h:909
TypeLoc getWrappedLoc() const
Definition: TypeLoc.h:911
const BTFTypeTagAttr * getAttr() const
The btf_type_tag attribute.
Definition: TypeLoc.h:914
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:518
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1272
TypeSpecifierType getWrittenTypeSpec() const
Definition: TypeLoc.cpp:331
bool needsExtraLocalData() const
Definition: TypeLoc.h:582
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:575
Kind getKind() const
Definition: Type.h:2672
LocalData * getLocalData() const
Definition: TypeLoc.h:422
SourceLocation getLocation() const
Definition: DeclBase.h:432
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:549
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2370
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2350
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2359
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:488
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2419
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:559
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2439
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2407
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2463
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2455
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2447
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:539
bool isEmpty() const
Definition: TypeLoc.h:2312
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2270
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2308
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2284
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:4384
Wrapper for source info for functions.
Definition: TypeLoc.h:1386
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1467
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:502
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1119
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1290
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:268
Class that aids in the construction of nested-name-specifiers along with source-location information ...
A C++ nested-name-specifier augmented with source location information.
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1328
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1330
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:968
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:489
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:972
unsigned getNumProtocols() const
Definition: TypeLoc.h:1002
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:960
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:981
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:990
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:998
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:1030
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:1011
unsigned getNumProtocols() const
Definition: TypeLoc.h:797
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:806
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:783
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:478
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:793
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:773
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2541
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1174
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1240
Wrapper for source info for pointers.
Definition: TypeLoc.h:1259
A (possibly-)qualified type.
Definition: Type.h:736
bool hasLocalQualifiers() const
Determine whether this particular QualType instance has any qualifiers, without looking through any t...
Definition: Type.h:843
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:431
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition: TypeLoc.h:277
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:281
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.
SourceLocation getBegin() const
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3440
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3543
TagDecl * getDecl() const
Definition: TypeLoc.h:720
bool isDefinition() const
True if the tag was defined in this type specifier.
Definition: TypeLoc.cpp:313
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:73
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:85
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:99
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:89
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:77
@ Type
The template argument is a type.
Definition: TemplateBase.h:69
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:66
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:81
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:95
Represents a C++ template name within the type system.
Definition: TemplateName.h:202
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
static void initializeArgLocs(ASTContext &Context, ArrayRef< TemplateArgument > Args, TemplateArgumentLocInfo *ArgInfos, SourceLocation Loc)
Definition: TypeLoc.cpp:577
RetTy Visit(TypeLoc TyLoc)
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
SourceLocation findNullabilityLoc() const
Find the location of the nullability specifier (__nonnull, __nullable, or __null_unspecifier),...
Definition: TypeLoc.cpp:446
TypeLoc()=default
static unsigned getLocalAlignmentForType(QualType Ty)
Returns the alignment of type source info data block for the given type.
Definition: TypeLoc.cpp:73
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
Definition: TypeLoc.cpp:457
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:132
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:169
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:88
TypeLoc IgnoreParens() const
Definition: TypeLoc.h:1183
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition: TypeLoc.h:77
void * Data
Definition: TypeLoc.h:63
SourceRange getLocalSourceRange() const
Get the local source range.
Definition: TypeLoc.h:158
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:163
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:715
const void * Ty
Definition: TypeLoc.h:62
void copy(TypeLoc other)
Copies the other type loc into this one.
Definition: TypeLoc.cpp:167
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:115
static unsigned getFullDataSizeForType(QualType Ty)
Returns the size of type source info data block for the given type.
Definition: TypeLoc.cpp:93
bool isNull() const
Definition: TypeLoc.h:120
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:234
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:322
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1993
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:522
QualType getUnmodifiedType() const
Definition: TypeLoc.h:2006
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
Definition: TypeLoc.h:516
SourceLocation getNameLoc() const
Definition: TypeLoc.h:523
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:527
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2071
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:530
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2065
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:2077
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2068
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:52
@ TST_char32
Definition: Specifiers.h:59
@ TST_wchar
Definition: Specifiers.h:56
@ TST_char16
Definition: Specifiers.h:58
@ TST_char
Definition: Specifiers.h:55
@ TST_unspecified
Definition: Specifiers.h:53
@ TST_bool
Definition: Specifiers.h:72
@ TST_void
Definition: Specifiers.h:54
@ TST_char8
Definition: Specifiers.h:57
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Location information for a TemplateArgument.
Definition: TemplateBase.h:432