clang 23.0.0git
Descriptor.cpp
Go to the documentation of this file.
1//===--- Descriptor.cpp - Types for the constexpr VM ------------*- 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#include "Descriptor.h"
10#include "Boolean.h"
11#include "Char.h"
12#include "FixedPoint.h"
13#include "Floating.h"
14#include "IntegralAP.h"
15#include "MemberPointer.h"
16#include "Pointer.h"
17#include "PrimType.h"
18#include "Record.h"
19#include "Source.h"
20#include "clang/AST/ExprCXX.h"
21
22using namespace clang;
23using namespace clang::interp;
24
25template <typename T> static constexpr bool needsCtor() {
26 if constexpr (std::is_same_v<T, Char<true>> ||
27 std::is_same_v<T, Char<false>> ||
28 std::is_same_v<T, Integral<16, true>> ||
29 std::is_same_v<T, Integral<16, false>> ||
30 std::is_same_v<T, Integral<32, true>> ||
31 std::is_same_v<T, Integral<32, false>> ||
32 std::is_same_v<T, Integral<64, true>> ||
33 std::is_same_v<T, Integral<64, false>> ||
34 std::is_same_v<T, Integral<64, false>> ||
35 std::is_same_v<T, IntegralAP<false>> ||
36 std::is_same_v<T, IntegralAP<true>> ||
37 std::is_same_v<T, Floating> || std::is_same_v<T, Boolean>)
38 return false;
39
40 return true;
41}
42
43template <typename T>
44static void ctorTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
45 const Descriptor *) {
46 static_assert(needsCtor<T>());
47 new (Ptr) T();
48}
49
50template <typename T>
51static void dtorTy(Block *, std::byte *Ptr, const Descriptor *) {
52 static_assert(needsCtor<T>());
53 reinterpret_cast<T *>(Ptr)->~T();
54}
55
56template <typename T>
57static void ctorArrayTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
58 const Descriptor *D) {
59 new (Ptr) InitMapPtr();
60
61 if constexpr (needsCtor<T>()) {
62 Ptr += sizeof(InitMapPtr);
63 for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
64 new (&reinterpret_cast<T *>(Ptr)[I]) T();
65 }
66 }
67}
68
69template <typename T>
70static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D) {
71 InitMapPtr &IMP = *reinterpret_cast<InitMapPtr *>(Ptr);
72 IMP.deleteInitMap();
73
74 if constexpr (needsCtor<T>()) {
75 Ptr += sizeof(InitMapPtr);
76 for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
77 reinterpret_cast<T *>(Ptr)[I].~T();
78 }
79 }
80}
81
82static void ctorArrayDesc(Block *B, std::byte *Ptr, bool IsConst,
83 bool IsMutable, bool IsVolatile, bool IsActive,
84 bool InUnion, const Descriptor *D) {
85 const unsigned NumElems = D->getNumElems();
86 const unsigned ElemSize =
88
89 unsigned ElemOffset = 0;
90 for (unsigned I = 0; I != NumElems; ++I, ElemOffset += ElemSize) {
91 auto *ElemPtr = Ptr + ElemOffset;
92 auto *Desc = reinterpret_cast<InlineDescriptor *>(ElemPtr);
93 auto *SD = D->ElemDesc;
94
95 Desc->Offset = ElemOffset + sizeof(InlineDescriptor);
96 Desc->Desc = SD;
97 Desc->IsInitialized = true;
98 Desc->IsBase = false;
99 Desc->IsActive = IsActive;
100 Desc->IsConst = IsConst || D->IsConst;
101 Desc->IsFieldMutable = IsMutable || D->IsMutable;
102 Desc->InUnion = InUnion;
103 Desc->IsArrayElement = true;
104 Desc->IsVolatile = IsVolatile;
105
106 if (auto Fn = D->ElemDesc->CtorFn) {
107 auto *ElemLoc = reinterpret_cast<std::byte *>(Desc + 1);
108 Fn(B, ElemLoc, Desc->IsConst, Desc->IsFieldMutable, IsVolatile, IsActive,
109 Desc->InUnion || SD->isUnion(), D->ElemDesc);
110 }
111 }
112}
113
114static void dtorArrayDesc(Block *B, std::byte *Ptr, const Descriptor *D) {
115 const unsigned NumElems = D->getNumElems();
116 const unsigned ElemSize =
117 D->ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
118
119 unsigned ElemOffset = 0;
120 auto Dtor = D->ElemDesc->DtorFn;
121 assert(Dtor &&
122 "a composite array without an elem dtor shouldn't have a dtor itself");
123 for (unsigned I = 0; I != NumElems; ++I, ElemOffset += ElemSize) {
124 auto *ElemPtr = Ptr + ElemOffset;
125 auto *Desc = reinterpret_cast<InlineDescriptor *>(ElemPtr);
126 auto *ElemLoc = reinterpret_cast<std::byte *>(Desc + 1);
127 Dtor(B, ElemLoc, D->ElemDesc);
128 }
129}
130
131static void initField(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
132 bool IsVolatile, bool IsActive, bool IsUnionField,
133 bool InUnion, const Descriptor *D, unsigned FieldOffset) {
134 auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + FieldOffset) - 1;
135 Desc->Offset = FieldOffset;
136 Desc->Desc = D;
137 Desc->IsInitialized = D->IsArray;
138 Desc->IsBase = false;
139 Desc->IsActive = IsActive && !IsUnionField;
140 Desc->InUnion = InUnion;
141 Desc->IsConst = IsConst || D->IsConst;
142 Desc->IsFieldMutable = IsMutable || D->IsMutable;
143 Desc->IsVolatile = IsVolatile || D->IsVolatile;
144 // True if this field is const AND the parent is mutable.
145 Desc->IsConstInMutable = Desc->IsConst && IsMutable;
146 Desc->LifeState =
149 : (Desc->IsActive ? Lifetime::NotStarted : Lifetime::Started);
150
151 if (auto Fn = D->CtorFn)
152 Fn(B, Ptr + FieldOffset, Desc->IsConst, Desc->IsFieldMutable,
153 Desc->IsVolatile, Desc->IsActive, InUnion || D->isUnion(), D);
154}
155
156static void initBase(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
157 bool IsVolatile, bool IsActive, bool InUnion,
158 const Descriptor *D, unsigned FieldOffset,
159 bool IsVirtualBase) {
160 assert(D);
161 assert(D->ElemRecord);
162 assert(!D->ElemRecord->isUnion()); // Unions cannot be base classes.
163
164 auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + FieldOffset) - 1;
165 Desc->Offset = FieldOffset;
166 Desc->Desc = D;
167 Desc->IsInitialized = D->IsArray;
168 Desc->IsBase = true;
169 Desc->IsVirtualBase = IsVirtualBase;
170 Desc->IsActive = IsActive && !InUnion;
171 Desc->IsConst = IsConst || D->IsConst;
172 Desc->IsFieldMutable = IsMutable || D->IsMutable;
173 Desc->InUnion = InUnion;
174 Desc->IsVolatile = false;
175
176 for (const auto &V : D->ElemRecord->bases())
177 initBase(B, Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive,
178 InUnion, V.Desc, V.Offset, false);
179 for (const auto &F : D->ElemRecord->fields())
180 initField(B, Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive,
181 InUnion, InUnion, F.Desc, F.Offset);
182}
183
184static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
185 bool IsVolatile, bool IsActive, bool InUnion,
186 const Descriptor *D) {
187 for (const auto &V : D->ElemRecord->bases())
188 initBase(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc,
189 V.Offset,
190 /*IsVirtualBase=*/false);
191 for (const auto &F : D->ElemRecord->fields()) {
192 bool IsUnionField = D->isUnion();
193 initField(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, IsUnionField,
194 InUnion || IsUnionField, F.Desc, F.Offset);
195 }
196 for (const auto &V : D->ElemRecord->virtual_bases())
197 initBase(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc,
198 V.Offset,
199 /*IsVirtualBase=*/true);
200}
201
202static void destroyField(Block *B, std::byte *Ptr, const Descriptor *D,
203 unsigned FieldOffset) {
204 if (auto Fn = D->DtorFn)
205 Fn(B, Ptr + FieldOffset, D);
206}
207
208static void destroyBase(Block *B, std::byte *Ptr, const Descriptor *D,
209 unsigned FieldOffset) {
210 assert(D);
211 assert(D->ElemRecord);
212
213 for (const auto &V : D->ElemRecord->bases())
214 destroyBase(B, Ptr + FieldOffset, V.Desc, V.Offset);
215 for (const auto &F : D->ElemRecord->fields())
216 destroyField(B, Ptr + FieldOffset, F.Desc, F.Offset);
217}
218
219static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D) {
220 for (const auto &F : D->ElemRecord->bases())
221 destroyBase(B, Ptr, F.Desc, F.Offset);
222 for (const auto &F : D->ElemRecord->fields())
223 destroyField(B, Ptr, F.Desc, F.Offset);
224 for (const auto &F : D->ElemRecord->virtual_bases())
225 destroyBase(B, Ptr, F.Desc, F.Offset);
226}
227
228/// Whether a record needs its descriptor dtor function called.
229static bool needsRecordDtor(const Record *R) {
230 for (const auto &B : R->bases()) {
231 if (B.Desc->DtorFn)
232 return true;
233 }
234
235 for (const auto &F : R->fields()) {
236 if (F.Desc->DtorFn)
237 return true;
238 }
239
240 for (const auto &V : R->virtual_bases()) {
241 if (V.Desc->DtorFn)
242 return true;
243 }
244 return false;
245}
246
248 switch (T) {
249 case PT_Ptr:
251 case PT_MemberPtr:
253 default:
254 return nullptr;
255 }
256 llvm_unreachable("Unhandled PrimType");
257}
258
260 switch (T) {
261 case PT_Ptr:
263 case PT_MemberPtr:
265 default:
266 return nullptr;
267 }
268 llvm_unreachable("Unhandled PrimType");
269}
270
272 TYPE_SWITCH(Type, if constexpr (!needsCtor<T>()) return nullptr;
273 return ctorArrayTy<T>);
274 llvm_unreachable("unknown Expr");
275}
276
279 llvm_unreachable("unknown Expr");
280}
281
282/// Primitives.
283Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy, PrimType Type,
284 MetadataSize MD, bool IsConst, bool IsTemporary,
285 bool IsMutable, bool IsVolatile)
286 : Source(D), SourceType(SourceTy), ElemSize(primSize(Type)), Size(ElemSize),
287 MDSize(MD.value_or(0)), AllocSize(align(Size + MDSize)), PrimT(Type),
291 assert(AllocSize >= Size);
292 assert(Source && "Missing source");
293}
294
295/// Primitive arrays.
296Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy, PrimType Type,
297 MetadataSize MD, size_t NumElems, bool IsConst,
298 bool IsTemporary, bool IsMutable, bool IsVolatile)
299 : Source(D), SourceType(SourceTy), ElemSize(primSize(Type)),
300 Size(ElemSize * NumElems), MDSize(MD.value_or(0)),
301 AllocSize(align(MDSize) + align(Size) + sizeof(InitMapPtr)), PrimT(Type),
305 assert(Source && "Missing source");
306 assert(NumElems <= (MaxArrayElemBytes / ElemSize));
307}
308
309/// Primitive unknown-size arrays.
311 bool IsTemporary, bool IsConst, UnknownSize)
312 : Source(D), ElemSize(primSize(Type)), Size(UnknownSizeMark),
313 MDSize(MD.value_or(0)),
314 AllocSize(MDSize + sizeof(InitMapPtr) + alignof(void *)), PrimT(Type),
318 assert(Source && "Missing source");
319}
320
321/// Arrays of composite elements.
322Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy,
323 const Descriptor *Elem, MetadataSize MD,
324 unsigned NumElems, bool IsConst, bool IsTemporary,
325 bool IsMutable)
326 : Source(D), SourceType(SourceTy),
327 ElemSize(Elem->getAllocSize() + sizeof(InlineDescriptor)),
328 Size(ElemSize * NumElems), MDSize(MD.value_or(0)),
329 AllocSize(std::max<size_t>(alignof(void *), Size) + MDSize),
333 assert(Source && "Missing source");
334}
335
336/// Unknown-size arrays of composite elements.
339 : Source(D), ElemSize(Elem->getAllocSize() + sizeof(InlineDescriptor)),
340 Size(UnknownSizeMark), MDSize(MD.value_or(0)),
341 AllocSize(MDSize + alignof(void *)), ElemDesc(Elem), IsConst(true),
344 assert(Source && "Missing source");
345}
346
347/// Composite records.
349 bool IsConst, bool IsTemporary, bool IsMutable,
350 bool IsVolatile)
351 : Source(D), ElemSize(std::max<size_t>(alignof(void *), R->getFullSize())),
352 Size(ElemSize), MDSize(MD.value_or(0)), AllocSize(Size + MDSize),
356 assert(Source && "Missing source");
357}
358
359/// Dummy.
361 : Source(D), ElemSize(1), Size(1), MDSize(MD.value_or(0)),
362 AllocSize(MDSize), ElemRecord(nullptr), IsConst(true), IsMutable(false),
364 assert(Source && "Missing source");
365}
366
368 if (SourceType)
369 return QualType(SourceType, 0);
370
371 if (const auto *T = dyn_cast_if_present<TypeDecl>(asDecl()))
372 return T->getASTContext().getTypeDeclType(T);
373
374 // The Source sometimes has a different type than the once
375 // we really save. Try to consult the Record first.
376 if (isRecord()) {
377 const RecordDecl *RD = ElemRecord->getDecl();
379 std::nullopt, RD, false);
380 if (IsConst)
381 return T.withConst();
382 return T;
383 }
384
385 if (const auto *E = asExpr()) {
386 if (isa<CXXNewExpr>(E))
387 return E->getType()->getPointeeType();
388
389 // std::allocator.allocate() call.
390 if (const auto *ME = dyn_cast<CXXMemberCallExpr>(E);
391 ME && ME->getRecordDecl()->getName() == "allocator" &&
392 ME->getMethodDecl()->getName() == "allocate")
393 return E->getType()->getPointeeType();
394 return E->getType();
395 }
396
397 if (const auto *D = asValueDecl())
398 return D->getType();
399
400 llvm_unreachable("Invalid descriptor type");
401}
402
404 assert(isArray());
405 QualType T = getType();
406 if (const auto *AT = T->getAs<AtomicType>())
407 T = AT->getValueType();
408 if (T->isPointerOrReferenceType())
409 T = T->getPointeeType();
410
411 if (const auto *AT = T->getAsArrayTypeUnsafe()) {
412 // For primitive arrays, we don't save a QualType at all,
413 // just a PrimType. Try to figure out the QualType here.
414 if (isPrimitiveArray()) {
415 while (T->isArrayType())
416 T = T->getAsArrayTypeUnsafe()->getElementType();
417 return T;
418 }
419 return AT->getElementType();
420 }
421 if (const auto *CT = T->getAs<ComplexType>())
422 return CT->getElementType();
423 if (const auto *CT = T->getAs<VectorType>())
424 return CT->getElementType();
425
426 return T;
427}
428
430 auto MakeArrayType = [&](QualType ElemType) -> QualType {
431 if (IsArray)
432 return Ctx.getConstantArrayType(
433 ElemType, APInt(64, static_cast<uint64_t>(getNumElems()), false),
434 nullptr, ArraySizeModifier::Normal, 0);
435 return ElemType;
436 };
437
438 if (const auto *E = asExpr()) {
439 if (isa<CXXNewExpr>(E))
440 return MakeArrayType(E->getType()->getPointeeType());
441
442 // std::allocator.allocate() call.
443 if (const auto *ME = dyn_cast<CXXMemberCallExpr>(E);
444 ME && ME->getRecordDecl()->getName() == "allocator" &&
445 ME->getMethodDecl()->getName() == "allocate")
446 return MakeArrayType(E->getType()->getPointeeType());
447 return E->getType();
448 }
449
450 return getType();
451}
452
454 if (auto *D = dyn_cast<const Decl *>(Source))
455 return D->getLocation();
456 if (auto *E = dyn_cast<const Expr *>(Source))
457 return E->getExprLoc();
458 llvm_unreachable("Invalid descriptor type");
459}
460
462 if (const auto *D = dyn_cast<const Decl *>(Source))
463 return SourceInfo(D);
464 if (const auto *E = dyn_cast<const Expr *>(Source))
465 return SourceInfo(E);
466 llvm_unreachable("Invalid descriptor type");
467}
468
470 if (isPrimitive() || isPrimitiveArray())
471 return true;
472
473 if (isRecord()) {
474 assert(ElemRecord);
475 return ElemRecord->hasTrivialDtor();
476 }
477
478 if (!ElemDesc)
479 return true;
480 // Composite arrays.
481 return ElemDesc->hasTrivialDtor();
482}
483
484bool Descriptor::isUnion() const { return isRecord() && ElemRecord->isUnion(); }
485
487 if ((isPrimitive() || isPrimitiveArray()) &&
489 if (getPrimType() == PT_Bool)
490 return 1;
491 FIXED_SIZE_INT_TYPE_SWITCH(getPrimType(), { return T::bitWidth() / 8; });
492 }
493 return ElemSize;
494}
#define V(N, I)
static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsVolatile, bool IsActive, bool InUnion, const Descriptor *D)
static void dtorTy(Block *, std::byte *Ptr, const Descriptor *)
static BlockCtorFn getCtorArrayPrim(PrimType Type)
static void destroyField(Block *B, std::byte *Ptr, const Descriptor *D, unsigned FieldOffset)
static void initField(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsVolatile, bool IsActive, bool IsUnionField, bool InUnion, const Descriptor *D, unsigned FieldOffset)
static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D)
static void ctorTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool, const Descriptor *)
static void ctorArrayDesc(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsVolatile, bool IsActive, bool InUnion, const Descriptor *D)
static void destroyBase(Block *B, std::byte *Ptr, const Descriptor *D, unsigned FieldOffset)
static constexpr bool needsCtor()
static void dtorArrayDesc(Block *B, std::byte *Ptr, const Descriptor *D)
static BlockCtorFn getCtorPrim(PrimType T)
static bool needsRecordDtor(const Record *R)
Whether a record needs its descriptor dtor function called.
static BlockDtorFn getDtorArrayPrim(PrimType Type)
static void ctorArrayTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool, const Descriptor *D)
static BlockDtorFn getDtorPrim(PrimType T)
static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D)
static void initBase(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsVolatile, bool IsActive, bool InUnion, const Descriptor *D, unsigned FieldOffset, bool IsVirtualBase)
Defines the clang::Expr interface and subclasses for C++ expressions.
#define FIXED_SIZE_INT_TYPE_SWITCH(Expr, B)
Definition PrimType.h:263
#define TYPE_SWITCH(Expr, B)
Definition PrimType.h:223
__DEVICE__ int max(int __a, int __b)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:223
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
Complex values, per C99 6.2.5p11.
Definition TypeBase.h:3339
ASTContext & getASTContext() const LLVM_READONLY
Definition DeclBase.cpp:547
A (possibly-)qualified type.
Definition TypeBase.h:937
QualType withConst() const
Definition TypeBase.h:1174
Represents a struct/union/class.
Definition Decl.h:4356
Encodes a location in the source.
The base class of the type hierarchy.
Definition TypeBase.h:1875
Represents a GCC generic vector type.
Definition TypeBase.h:4239
A memory block, either on the stack or in the heap.
Definition InterpBlock.h:44
Structure/Class descriptor.
Definition Record.h:25
bool isUnion() const
Checks if the record is a union.
Definition Record.h:69
llvm::iterator_range< const_virtual_iter > virtual_bases() const
Definition Record.h:117
llvm::iterator_range< const_base_iter > bases() const
Definition Record.h:102
llvm::iterator_range< const_field_iter > fields() const
Definition Record.h:90
Describes the statement/declaration an opcode was generated from.
Definition Source.h:74
void(*)(Block *Storage, std::byte *FieldPtr, const Descriptor *FieldDesc) BlockDtorFn
Invoked when a block is destroyed.
Definition Descriptor.h:40
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
bool NE(InterpState &S, CodePtr OpPC)
Definition Interp.h:1499
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
Definition PrimType.h:201
constexpr bool isIntegerOrBoolType(PrimType T)
Definition PrimType.h:52
llvm::APInt APInt
Definition FixedPoint.h:19
PrimType
Enumeration of the primitive types of the VM.
Definition PrimType.h:34
size_t primSize(PrimType Type)
Returns the size of a primitive type in bytes.
Definition PrimType.cpp:24
void(*)(Block *Storage, std::byte *FieldPtr, bool IsConst, bool IsMutable, bool IsVolatile, bool IsActive, bool InUnion, const Descriptor *FieldDesc) BlockCtorFn
Invoked whenever a block is created.
Definition Descriptor.h:34
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ None
No keyword precedes the qualified type name.
Definition TypeBase.h:5991
#define false
Definition stdbool.h:26
#define true
Definition stdbool.h:25
Token to denote structures of unknown size.
Definition Descriptor.h:142
Describes a memory block created by an allocation site.
Definition Descriptor.h:123
const bool IsConst
Flag indicating if the block is mutable.
Definition Descriptor.h:162
unsigned getAllocSize() const
Returns the allocated size, including metadata.
Definition Descriptor.h:248
unsigned getNumElems() const
Returns the number of elements stored in the block.
Definition Descriptor.h:260
bool isPrimitive() const
Checks if the descriptor is of a primitive.
Definition Descriptor.h:274
QualType getElemQualType() const
bool hasTrivialDtor() const
Whether variables of this descriptor need their destructor called or not.
const BlockDtorFn DtorFn
Definition Descriptor.h:174
const OptPrimType PrimT
The primitive type this descriptor was created for, or the primitive element type in case this is a p...
Definition Descriptor.h:160
const ValueDecl * asValueDecl() const
Definition Descriptor.h:216
const BlockCtorFn CtorFn
Storage management methods.
Definition Descriptor.h:173
static constexpr unsigned MaxArrayElemBytes
Maximum number of bytes to be used for array elements.
Definition Descriptor.h:149
QualType getType() const
const Decl * asDecl() const
Definition Descriptor.h:212
const Descriptor *const ElemDesc
Descriptor of the array element.
Definition Descriptor.h:156
SourceInfo getLoc() const
Descriptor(const DeclTy &D, const Type *SourceTy, PrimType Type, MetadataSize MD, bool IsConst, bool IsTemporary, bool IsMutable, bool IsVolatile)
Allocates a descriptor for a primitive.
SourceLocation getLocation() const
const bool IsMutable
Flag indicating if a field is mutable.
Definition Descriptor.h:164
QualType getDataType(const ASTContext &Ctx) const
std::optional< unsigned > MetadataSize
Definition Descriptor.h:144
const bool IsArray
Flag indicating if the block is an array.
Definition Descriptor.h:169
unsigned getElemDataSize() const
Returns the element data size, i.e.
bool isPrimitiveArray() const
Checks if the descriptor is of an array of primitives.
Definition Descriptor.h:265
PrimType getPrimType() const
Definition Descriptor.h:242
bool isRecord() const
Checks if the descriptor is of a record.
Definition Descriptor.h:279
const bool IsTemporary
Flag indicating if the block is a temporary.
Definition Descriptor.h:166
const Record *const ElemRecord
Pointer to the record, if block contains records.
Definition Descriptor.h:154
bool isUnion() const
Checks if the descriptor is of a union.
const Expr * asExpr() const
Definition Descriptor.h:213
bool isArray() const
Checks if the descriptor is of an array.
Definition Descriptor.h:277
A pointer-sized struct we use to allocate into data storage.
Definition InitMap.h:79
void deleteInitMap()
Delete the InitMap if one exists.
Definition InitMap.h:113
Inline descriptor embedded in structures and arrays.
Definition Descriptor.h:68
unsigned Offset
Offset inside the structure/array.
Definition Descriptor.h:70