clang 19.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"
18#include "clang/AST/Expr.h"
25#include "llvm/Support/ErrorHandling.h"
26#include "llvm/Support/MathExtras.h"
27#include <algorithm>
28#include <cassert>
29#include <cstdint>
30#include <cstring>
31
32using namespace clang;
33
34static const unsigned TypeLocMaxDataAlign = alignof(void *);
35
36//===----------------------------------------------------------------------===//
37// TypeLoc Implementation
38//===----------------------------------------------------------------------===//
39
40namespace {
41
42class TypeLocRanger : public TypeLocVisitor<TypeLocRanger, SourceRange> {
43public:
44#define ABSTRACT_TYPELOC(CLASS, PARENT)
45#define TYPELOC(CLASS, PARENT) \
46 SourceRange Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
47 return TyLoc.getLocalSourceRange(); \
48 }
49#include "clang/AST/TypeLocNodes.def"
50};
51
52} // namespace
53
54SourceRange TypeLoc::getLocalSourceRangeImpl(TypeLoc TL) {
55 if (TL.isNull()) return SourceRange();
56 return TypeLocRanger().Visit(TL);
57}
58
59namespace {
60
61class TypeAligner : public TypeLocVisitor<TypeAligner, unsigned> {
62public:
63#define ABSTRACT_TYPELOC(CLASS, PARENT)
64#define TYPELOC(CLASS, PARENT) \
65 unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
66 return TyLoc.getLocalDataAlignment(); \
67 }
68#include "clang/AST/TypeLocNodes.def"
69};
70
71} // namespace
72
73/// Returns the alignment of the type source info data block.
75 if (Ty.isNull()) return 1;
76 return TypeAligner().Visit(TypeLoc(Ty, nullptr));
77}
78
79namespace {
80
81class TypeSizer : public TypeLocVisitor<TypeSizer, unsigned> {
82public:
83#define ABSTRACT_TYPELOC(CLASS, PARENT)
84#define TYPELOC(CLASS, PARENT) \
85 unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
86 return TyLoc.getLocalDataSize(); \
87 }
88#include "clang/AST/TypeLocNodes.def"
89};
90
91} // namespace
92
93/// Returns the size of the type source info data block.
95 unsigned Total = 0;
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();
104 }
105 Total = llvm::alignTo(Total, MaxAlign);
106 return Total;
107}
108
109namespace {
110
111class NextLoc : public TypeLocVisitor<NextLoc, TypeLoc> {
112public:
113#define ABSTRACT_TYPELOC(CLASS, PARENT)
114#define TYPELOC(CLASS, PARENT) \
115 TypeLoc Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
116 return TyLoc.getNextTypeLoc(); \
117 }
118#include "clang/AST/TypeLocNodes.def"
119};
120
121} // namespace
122
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".
125TypeLoc TypeLoc::getNextTypeLocImpl(TypeLoc TL) {
126 return NextLoc().Visit(TL);
127}
128
129/// Initializes a type location, and all of its children
130/// recursively, as if the entire tree had been written in the
131/// given location.
132void TypeLoc::initializeImpl(ASTContext &Context, TypeLoc TL,
134 while (true) {
135 switch (TL.getTypeLocClass()) {
136#define ABSTRACT_TYPELOC(CLASS, PARENT)
137#define TYPELOC(CLASS, PARENT) \
138 case CLASS: { \
139 CLASS##TypeLoc TLCasted = TL.castAs<CLASS##TypeLoc>(); \
140 TLCasted.initializeLocal(Context, Loc); \
141 TL = TLCasted.getNextTypeLoc(); \
142 if (!TL) return; \
143 continue; \
144 }
145#include "clang/AST/TypeLocNodes.def"
146 }
147 }
148}
149
150namespace {
151
152class TypeLocCopier : public TypeLocVisitor<TypeLocCopier> {
153 TypeLoc Source;
154
155public:
156 TypeLocCopier(TypeLoc source) : Source(source) {}
157
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>()); \
162 }
163#include "clang/AST/TypeLocNodes.def"
164};
165
166} // namespace
167
169 assert(getFullDataSize() == other.getFullDataSize());
170
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),
177 reinterpret_cast<uintptr_t>(other.Data) ==
178 llvm::alignTo(reinterpret_cast<uintptr_t>(other.Data),
180 memcpy(Data, other.Data, getFullDataSize());
181 return;
182 }
183
184 // Copy each of the pieces.
185 TypeLoc TL(getType(), Data);
186 do {
187 TypeLocCopier(other).Visit(TL);
188 other = other.getNextTypeLoc();
189 } while ((TL = TL.getNextTypeLoc()));
190}
191
193 TypeLoc Cur = *this;
194 TypeLoc LeftMost = Cur;
195 while (true) {
196 switch (Cur.getTypeLocClass()) {
197 case Elaborated:
198 if (Cur.getLocalSourceRange().getBegin().isValid()) {
199 LeftMost = Cur;
200 break;
201 }
202 Cur = Cur.getNextTypeLoc();
203 if (Cur.isNull())
204 break;
205 continue;
206 case FunctionProto:
208 ->hasTrailingReturn()) {
209 LeftMost = Cur;
210 break;
211 }
212 [[fallthrough]];
213 case FunctionNoProto:
214 case ConstantArray:
215 case DependentSizedArray:
216 case IncompleteArray:
217 case VariableArray:
218 // FIXME: Currently QualifiedTypeLoc does not have a source range
219 case Qualified:
220 Cur = Cur.getNextTypeLoc();
221 continue;
222 default:
224 LeftMost = Cur;
225 Cur = Cur.getNextTypeLoc();
226 if (Cur.isNull())
227 break;
228 continue;
229 } // switch
230 break;
231 } // while
232 return LeftMost.getLocalSourceRange().getBegin();
233}
234
236 TypeLoc Cur = *this;
238 while (true) {
239 switch (Cur.getTypeLocClass()) {
240 default:
241 if (!Last)
242 Last = Cur;
243 return Last.getLocalSourceRange().getEnd();
244 case Paren:
245 case ConstantArray:
246 case DependentSizedArray:
247 case IncompleteArray:
248 case VariableArray:
249 case FunctionNoProto:
250 // The innermost type with suffix syntax always determines the end of the
251 // type.
252 Last = Cur;
253 break;
254 case FunctionProto:
256 Last = TypeLoc();
257 else
258 Last = Cur;
259 break;
260 case ObjCObjectPointer:
261 // `id` and `id<...>` have no star location.
263 break;
264 [[fallthrough]];
265 case Pointer:
266 case BlockPointer:
267 case MemberPointer:
268 case LValueReference:
269 case RValueReference:
270 case PackExpansion:
271 // Types with prefix syntax only determine the end of the type if there
272 // is no suffix type.
273 if (!Last)
274 Last = Cur;
275 break;
276 case Qualified:
277 case Elaborated:
278 break;
279 }
280 Cur = Cur.getNextTypeLoc();
281 }
282}
283
284namespace {
285
286struct 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; }
290
291#define ABSTRACT_TYPELOC(CLASS, PARENT)
292#define TYPELOC(CLASS, PARENT) \
293 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
294 return isTypeSpec(TyLoc); \
295 }
296#include "clang/AST/TypeLocNodes.def"
297};
298
299} // namespace
300
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.
304///
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
308/// them.
309bool TypeSpecTypeLoc::isKind(const TypeLoc &TL) {
310 if (TL.getType().hasLocalQualifiers()) return false;
311 return TSTChecker().Visit(TL);
312}
313
315 TagDecl *D = getDecl();
316 return D->isCompleteDefinition() &&
317 (D->getIdentifier() == nullptr || D->getLocation() == getNameLoc());
318}
319
320// Reimplemented to account for GNU/C++ extension
321// typeof unary-expression
322// where there are no parentheses.
324 if (getRParenLoc().isValid())
326 else
327 return SourceRange(getTypeofLoc(),
328 getUnderlyingExpr()->getSourceRange().getEnd());
329}
330
331
334 return static_cast<TypeSpecifierType>(getWrittenBuiltinSpecs().Type);
335 switch (getTypePtr()->getKind()) {
336 case BuiltinType::Void:
337 return TST_void;
338 case BuiltinType::Bool:
339 return TST_bool;
340 case BuiltinType::Char_U:
341 case BuiltinType::Char_S:
342 return TST_char;
343 case BuiltinType::Char8:
344 return TST_char8;
345 case BuiltinType::Char16:
346 return TST_char16;
347 case BuiltinType::Char32:
348 return TST_char32;
349 case BuiltinType::WChar_S:
350 case BuiltinType::WChar_U:
351 return TST_wchar;
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.
398
399 case BuiltinType::NullPtr:
400 case BuiltinType::Overload:
401 case BuiltinType::Dependent:
402 case BuiltinType::UnresolvedTemplate:
403 case BuiltinType::BoundMember:
404 case BuiltinType::UnknownAny:
405 case BuiltinType::ARCUnbridgedCast:
406 case BuiltinType::PseudoObject:
407 case BuiltinType::ObjCId:
408 case BuiltinType::ObjCClass:
409 case BuiltinType::ObjCSel:
410#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
411 case BuiltinType::Id:
412#include "clang/Basic/OpenCLImageTypes.def"
413#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
414 case BuiltinType::Id:
415#include "clang/Basic/OpenCLExtensionTypes.def"
416 case BuiltinType::OCLSampler:
417 case BuiltinType::OCLEvent:
418 case BuiltinType::OCLClkEvent:
419 case BuiltinType::OCLQueue:
420 case BuiltinType::OCLReserveID:
421#define SVE_TYPE(Name, Id, SingletonId) \
422 case BuiltinType::Id:
423#include "clang/Basic/AArch64SVEACLETypes.def"
424#define PPC_VECTOR_TYPE(Name, Id, Size) \
425 case BuiltinType::Id:
426#include "clang/Basic/PPCTypes.def"
427#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
428#include "clang/Basic/RISCVVTypes.def"
429#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
430#include "clang/Basic/WebAssemblyReferenceTypes.def"
431 case BuiltinType::BuiltinFn:
432 case BuiltinType::IncompleteMatrixIdx:
433 case BuiltinType::ArraySection:
434 case BuiltinType::OMPArrayShaping:
435 case BuiltinType::OMPIterator:
436 return TST_unspecified;
437 }
438
439 llvm_unreachable("Invalid BuiltinType Kind!");
440}
441
442TypeLoc TypeLoc::IgnoreParensImpl(TypeLoc TL) {
443 while (ParenTypeLoc PTL = TL.getAs<ParenTypeLoc>())
444 TL = PTL.getInnerLoc();
445 return TL;
446}
447
449 if (auto ATL = getAs<AttributedTypeLoc>()) {
450 const Attr *A = ATL.getAttr();
451 if (A && (isa<TypeNullableAttr>(A) || isa<TypeNonNullAttr>(A) ||
452 isa<TypeNullUnspecifiedAttr>(A)))
453 return A->getLocation();
454 }
455
456 return {};
457}
458
460 // Qualified types.
461 if (auto qual = getAs<QualifiedTypeLoc>())
462 return qual;
463
464 TypeLoc loc = IgnoreParens();
465
466 // Attributed types.
467 if (auto attr = loc.getAs<AttributedTypeLoc>()) {
468 if (attr.isQualifier()) return attr;
469 return attr.getModifiedLoc().findExplicitQualifierLoc();
470 }
471
472 // C11 _Atomic types.
473 if (auto atomic = loc.getAs<AtomicTypeLoc>()) {
474 return atomic;
475 }
476
477 return {};
478}
479
483 if (!getNumProtocols()) return;
484
487 for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
489}
490
496 for (unsigned i = 0, e = getNumTypeArgs(); i != e; ++i) {
499 getTypePtr()->getTypeArgsAsWritten()[i], Loc));
500 }
503 for (unsigned i = 0, e = getNumProtocols(); i != e; ++i)
505}
506
508 // Note that this does *not* include the range of the attribute
509 // enclosure, e.g.:
510 // __attribute__((foo(bar)))
511 // ^~~~~~~~~~~~~~~ ~~
512 // or
513 // [[foo(bar)]]
514 // ^~ ~~
515 // That enclosure doesn't necessarily belong to a single attribute
516 // anyway.
517 return getAttr() ? getAttr()->getRange() : SourceRange();
518}
519
522}
523
525 return getAttr() ? getAttr()->getRange() : SourceRange();
526}
527
531 ::initializeLocal(Context, Loc);
532 this->getLocalData()->UnmodifiedTInfo =
534}
535
538 setKWLoc(Loc);
541 this->setUnderlyingTInfo(
542 Context.getTrivialTypeSourceInfo(getTypePtr()->getBaseType(), Loc));
543}
544
547 if (isEmpty())
548 return;
551 Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
552 setQualifierLoc(Builder.getWithLocInContext(Context));
553}
554
559 Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
560 setQualifierLoc(Builder.getWithLocInContext(Context));
562}
563
564void
568 if (getTypePtr()->getQualifier()) {
570 Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc);
571 setQualifierLoc(Builder.getWithLocInContext(Context));
572 } else {
574 }
580 Context, getTypePtr()->template_arguments(), getArgInfos(), Loc);
581}
582
586 for (unsigned i = 0, e = Args.size(); i != e; ++i) {
587 switch (Args[i].getKind()) {
589 llvm_unreachable("Impossible TemplateArgument");
590
595 ArgInfos[i] = TemplateArgumentLocInfo();
596 break;
597
599 ArgInfos[i] = TemplateArgumentLocInfo(Args[i].getAsExpr());
600 break;
601
603 ArgInfos[i] = TemplateArgumentLocInfo(
604 Context.getTrivialTypeSourceInfo(Args[i].getAsType(),
605 Loc));
606 break;
607
611 TemplateName Template = Args[i].getAsTemplateOrTemplatePattern();
613 Builder.MakeTrivial(Context, DTN->getQualifier(), Loc);
614 else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
615 Builder.MakeTrivial(Context, QTN->getQualifier(), Loc);
616
617 ArgInfos[i] = TemplateArgumentLocInfo(
618 Context, Builder.getWithLocInContext(Context), Loc,
619 Args[i].getKind() == TemplateArgument::Template ? SourceLocation()
620 : Loc);
621 break;
622 }
623
625 ArgInfos[i] = TemplateArgumentLocInfo();
626 break;
627 }
628 }
629}
630
631// Builds a ConceptReference where all locations point at the same token,
632// for use in trivial TypeSourceInfo for constrained AutoType
635 const AutoType *AT) {
639 unsigned size = AT->getTypeConstraintArguments().size();
642 Context, AT->getTypeConstraintArguments(), TALI, Loc);
644 for (unsigned i = 0; i < size; ++i) {
645 TAListI.addArgument(
647 TALI[i])); // TemplateArgumentLocInfo()
648 }
649
650 auto *ConceptRef = ConceptReference::Create(
651 Context, NestedNameSpecifierLoc{}, Loc, DNI, nullptr,
653 ASTTemplateArgumentListInfo::Create(Context, TAListI));
654 delete[] TALI;
655 return ConceptRef;
656}
657
661 setConceptReference(nullptr);
662 if (getTypePtr()->isConstrained()) {
665 }
666}
667
668namespace {
669
670 class GetContainedAutoTypeLocVisitor :
671 public TypeLocVisitor<GetContainedAutoTypeLocVisitor, TypeLoc> {
672 public:
673 using TypeLocVisitor<GetContainedAutoTypeLocVisitor, TypeLoc>::Visit;
674
675 TypeLoc VisitAutoTypeLoc(AutoTypeLoc TL) {
676 return TL;
677 }
678
679 // Only these types can contain the desired 'auto' type.
680
681 TypeLoc VisitElaboratedTypeLoc(ElaboratedTypeLoc T) {
682 return Visit(T.getNamedTypeLoc());
683 }
684
685 TypeLoc VisitQualifiedTypeLoc(QualifiedTypeLoc T) {
686 return Visit(T.getUnqualifiedLoc());
687 }
688
689 TypeLoc VisitPointerTypeLoc(PointerTypeLoc T) {
690 return Visit(T.getPointeeLoc());
691 }
692
693 TypeLoc VisitBlockPointerTypeLoc(BlockPointerTypeLoc T) {
694 return Visit(T.getPointeeLoc());
695 }
696
697 TypeLoc VisitReferenceTypeLoc(ReferenceTypeLoc T) {
698 return Visit(T.getPointeeLoc());
699 }
700
701 TypeLoc VisitMemberPointerTypeLoc(MemberPointerTypeLoc T) {
702 return Visit(T.getPointeeLoc());
703 }
704
705 TypeLoc VisitArrayTypeLoc(ArrayTypeLoc T) {
706 return Visit(T.getElementLoc());
707 }
708
709 TypeLoc VisitFunctionTypeLoc(FunctionTypeLoc T) {
710 return Visit(T.getReturnLoc());
711 }
712
713 TypeLoc VisitParenTypeLoc(ParenTypeLoc T) {
714 return Visit(T.getInnerLoc());
715 }
716
717 TypeLoc VisitAttributedTypeLoc(AttributedTypeLoc T) {
718 return Visit(T.getModifiedLoc());
719 }
720
721 TypeLoc VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc T) {
722 return Visit(T.getWrappedLoc());
723 }
724
725 TypeLoc VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc T) {
726 return Visit(T.getInnerLoc());
727 }
728
729 TypeLoc VisitAdjustedTypeLoc(AdjustedTypeLoc T) {
730 return Visit(T.getOriginalLoc());
731 }
732
733 TypeLoc VisitPackExpansionTypeLoc(PackExpansionTypeLoc T) {
734 return Visit(T.getPatternLoc());
735 }
736 };
737
738} // namespace
739
741 TypeLoc Res = GetContainedAutoTypeLocVisitor().Visit(*this);
742 if (Res.isNull())
743 return AutoTypeLoc();
744 return Res.getAs<AutoTypeLoc>();
745}
746
748 if (const auto TSTL = getAsAdjusted<TemplateSpecializationTypeLoc>())
749 return TSTL.getTemplateKeywordLoc();
750 if (const auto DTSTL =
751 getAsAdjusted<DependentTemplateSpecializationTypeLoc>())
752 return DTSTL.getTemplateKeywordLoc();
753 return SourceLocation();
754}
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:1125
Defines the C++ template declaration subclasses.
SourceLocation Loc
Definition: SemaObjC.cpp:755
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
static ConceptReference * createTrivialConceptReference(ASTContext &Context, SourceLocation Loc, const AutoType *AT)
Definition: TypeLoc.cpp:633
static const unsigned TypeLocMaxDataAlign
Definition: TypeLoc.cpp:34
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,...
Wrapper for source info for arrays.
Definition: TypeLoc.h:1561
Attr - This represents one attribute.
Definition: Attr.h:42
SourceLocation getLocation() const
Definition: Attr.h:95
Type source information for an attributed type.
Definition: TypeLoc.h:875
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:898
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:507
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:658
void setConceptReference(ConceptReference *CR)
Definition: TypeLoc.h:2201
bool isConstrained() const
Definition: TypeLoc.h:2197
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2195
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5981
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
Definition: Type.h:5991
ConceptDecl * getTypeConstraintConcept() const
Definition: Type.h:5996
Type source information for an btf_tag attributed type.
Definition: TypeLoc.h:925
const BTFTypeTagAttr * getAttr() const
The btf_type_tag attribute.
Definition: TypeLoc.h:930
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:524
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1314
TypeSpecifierType getWrittenTypeSpec() const
Definition: TypeLoc.cpp:332
bool needsExtraLocalData() const
Definition: TypeLoc.h:594
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:587
Kind getKind() const
Definition: Type.h:3023
A reference to a concept and its template args, as it appears in the code.
Definition: ASTConcept.h:128
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Definition: ASTConcept.cpp:94
LocalData * getLocalData() const
Definition: TypeLoc.h:434
Expr * getCountExpr() const
Definition: TypeLoc.h:1142
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:520
SourceLocation getLocation() const
Definition: DeclBase.h:445
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:555
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2423
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2403
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2412
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:488
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2472
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:565
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2492
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2460
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2516
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2508
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2500
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:545
bool isEmpty() const
Definition: TypeLoc.h:2365
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2323
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2337
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:5028
Wrapper for source info for functions.
Definition: TypeLoc.h:1428
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:514
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1332
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:270
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:315
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:1370
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1372
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:984
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:491
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:988
unsigned getNumProtocols() const
Definition: TypeLoc.h:1018
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:976
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
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:1046
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:1027
unsigned getNumProtocols() const
Definition: TypeLoc.h:809
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:818
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:795
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:480
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:805
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:785
Wrapper for source info for pointers.
Definition: TypeLoc.h:1301
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
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:289
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
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:326
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3584
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3687
TagDecl * getDecl() const
Definition: TypeLoc.h:732
bool isDefinition() const
True if the tag was defined in this type specifier.
Definition: TypeLoc.cpp:314
A convenient class for passing around template argument information.
Definition: TemplateBase.h:632
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:667
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:74
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:93
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
Definition: TemplateBase.h:89
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:107
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:97
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:78
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:67
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:82
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:103
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:583
RetTy Visit(TypeLoc TyLoc)
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:448
TypeLoc()=default
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:459
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
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
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
void * Data
Definition: TypeLoc.h:64
SourceRange getLocalSourceRange() const
Get the local source range.
Definition: TypeLoc.h:159
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:740
const void * Ty
Definition: TypeLoc.h:63
SourceLocation getTemplateKeywordLoc() const
Get the SourceLocation of the template keyword (if any).
Definition: TypeLoc.cpp:747
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
bool isNull() const
Definition: TypeLoc.h:121
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:235
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:192
SourceRange getLocalSourceRange() const
Definition: TypeLoc.cpp:323
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:2040
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:528
QualType getUnmodifiedType() const
Definition: TypeLoc.h:2053
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
Definition: TypeLoc.h:528
SourceLocation getNameLoc() const
Definition: TypeLoc.h:535
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:539
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2146
void initializeLocal(ASTContext &Context, SourceLocation Loc)
Definition: TypeLoc.cpp:536
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2140
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:2152
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2143
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:55
@ TST_char32
Definition: Specifiers.h:62
@ TST_wchar
Definition: Specifiers.h:59
@ TST_char16
Definition: Specifiers.h:61
@ TST_char
Definition: Specifiers.h:58
@ TST_unspecified
Definition: Specifiers.h:56
@ TST_bool
Definition: Specifiers.h:75
@ TST_void
Definition: Specifiers.h:57
@ TST_char8
Definition: Specifiers.h:60
const FunctionProtoType * T
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Location information for a TemplateArgument.
Definition: TemplateBase.h:472