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, Integral<8, true>> ||
27 std::is_same_v<T, Integral<8, 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, Boolean>)
35 return false;
36
37 return true;
38}
39
40template <typename T>
41static void ctorTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
42 const Descriptor *) {
43 static_assert(needsCtor<T>());
44 new (Ptr) T();
45}
46
47template <typename T>
48static void dtorTy(Block *, std::byte *Ptr, const Descriptor *) {
49 static_assert(needsCtor<T>());
50 reinterpret_cast<T *>(Ptr)->~T();
51}
52
53template <typename T>
54static void ctorArrayTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
55 const Descriptor *D) {
56 new (Ptr) InitMapPtr();
57
58 if constexpr (needsCtor<T>()) {
59 Ptr += sizeof(InitMapPtr);
60 for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
61 new (&reinterpret_cast<T *>(Ptr)[I]) T();
62 }
63 }
64}
65
66template <typename T>
67static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D) {
68 InitMapPtr &IMP = *reinterpret_cast<InitMapPtr *>(Ptr);
69 IMP.deleteInitMap();
70
71 if constexpr (needsCtor<T>()) {
72 Ptr += sizeof(InitMapPtr);
73 for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
74 reinterpret_cast<T *>(Ptr)[I].~T();
75 }
76 }
77}
78
79static void ctorArrayDesc(Block *B, std::byte *Ptr, bool IsConst,
80 bool IsMutable, bool IsVolatile, bool IsActive,
81 bool InUnion, const Descriptor *D) {
82 const unsigned NumElems = D->getNumElems();
83 const unsigned ElemSize =
85
86 unsigned ElemOffset = 0;
87 for (unsigned I = 0; I != NumElems; ++I, ElemOffset += ElemSize) {
88 auto *ElemPtr = Ptr + ElemOffset;
89 auto *Desc = reinterpret_cast<InlineDescriptor *>(ElemPtr);
90 auto *SD = D->ElemDesc;
91
92 Desc->Offset = ElemOffset + sizeof(InlineDescriptor);
93 Desc->Desc = SD;
94 Desc->IsInitialized = true;
95 Desc->IsBase = false;
96 Desc->IsActive = IsActive;
97 Desc->IsConst = IsConst || D->IsConst;
98 Desc->IsFieldMutable = IsMutable || D->IsMutable;
99 Desc->InUnion = InUnion;
100 Desc->IsArrayElement = true;
101 Desc->IsVolatile = IsVolatile;
102
103 if (auto Fn = D->ElemDesc->CtorFn) {
104 auto *ElemLoc = reinterpret_cast<std::byte *>(Desc + 1);
105 Fn(B, ElemLoc, Desc->IsConst, Desc->IsFieldMutable, IsVolatile, IsActive,
106 Desc->InUnion || SD->isUnion(), D->ElemDesc);
107 }
108 }
109}
110
111static void dtorArrayDesc(Block *B, std::byte *Ptr, const Descriptor *D) {
112 const unsigned NumElems = D->getNumElems();
113 const unsigned ElemSize =
114 D->ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
115
116 unsigned ElemOffset = 0;
117 auto Dtor = D->ElemDesc->DtorFn;
118 assert(Dtor &&
119 "a composite array without an elem dtor shouldn't have a dtor itself");
120 for (unsigned I = 0; I != NumElems; ++I, ElemOffset += ElemSize) {
121 auto *ElemPtr = Ptr + ElemOffset;
122 auto *Desc = reinterpret_cast<InlineDescriptor *>(ElemPtr);
123 auto *ElemLoc = reinterpret_cast<std::byte *>(Desc + 1);
124 Dtor(B, ElemLoc, D->ElemDesc);
125 }
126}
127
128static void initField(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
129 bool IsVolatile, bool IsActive, bool IsUnionField,
130 bool InUnion, const Descriptor *D, unsigned FieldOffset) {
131 auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + FieldOffset) - 1;
132 Desc->Offset = FieldOffset;
133 Desc->Desc = D;
134 Desc->IsInitialized = D->IsArray;
135 Desc->IsBase = false;
136 Desc->IsActive = IsActive && !IsUnionField;
137 Desc->InUnion = InUnion;
138 Desc->IsConst = IsConst || D->IsConst;
139 Desc->IsFieldMutable = IsMutable || D->IsMutable;
140 Desc->IsVolatile = IsVolatile || D->IsVolatile;
141 // True if this field is const AND the parent is mutable.
142 Desc->IsConstInMutable = Desc->IsConst && IsMutable;
143
144 if (auto Fn = D->CtorFn)
145 Fn(B, Ptr + FieldOffset, Desc->IsConst, Desc->IsFieldMutable,
146 Desc->IsVolatile, Desc->IsActive, InUnion || D->isUnion(), D);
147}
148
149static void initBase(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
150 bool IsVolatile, bool IsActive, bool InUnion,
151 const Descriptor *D, unsigned FieldOffset,
152 bool IsVirtualBase) {
153 assert(D);
154 assert(D->ElemRecord);
155 assert(!D->ElemRecord->isUnion()); // Unions cannot be base classes.
156
157 auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + FieldOffset) - 1;
158 Desc->Offset = FieldOffset;
159 Desc->Desc = D;
160 Desc->IsInitialized = D->IsArray;
161 Desc->IsBase = true;
162 Desc->IsVirtualBase = IsVirtualBase;
163 Desc->IsActive = IsActive && !InUnion;
164 Desc->IsConst = IsConst || D->IsConst;
165 Desc->IsFieldMutable = IsMutable || D->IsMutable;
166 Desc->InUnion = InUnion;
167 Desc->IsVolatile = false;
168
169 for (const auto &V : D->ElemRecord->bases())
170 initBase(B, Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive,
171 InUnion, V.Desc, V.Offset, false);
172 for (const auto &F : D->ElemRecord->fields())
173 initField(B, Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive,
174 InUnion, InUnion, F.Desc, F.Offset);
175}
176
177static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
178 bool IsVolatile, bool IsActive, bool InUnion,
179 const Descriptor *D) {
180 for (const auto &V : D->ElemRecord->bases())
181 initBase(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc,
182 V.Offset,
183 /*IsVirtualBase=*/false);
184 for (const auto &F : D->ElemRecord->fields()) {
185 bool IsUnionField = D->isUnion();
186 initField(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, IsUnionField,
187 InUnion || IsUnionField, F.Desc, F.Offset);
188 }
189 for (const auto &V : D->ElemRecord->virtual_bases())
190 initBase(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc,
191 V.Offset,
192 /*IsVirtualBase=*/true);
193}
194
195static void destroyField(Block *B, std::byte *Ptr, const Descriptor *D,
196 unsigned FieldOffset) {
197 if (auto Fn = D->DtorFn)
198 Fn(B, Ptr + FieldOffset, D);
199}
200
201static void destroyBase(Block *B, std::byte *Ptr, const Descriptor *D,
202 unsigned FieldOffset) {
203 assert(D);
204 assert(D->ElemRecord);
205
206 for (const auto &V : D->ElemRecord->bases())
207 destroyBase(B, Ptr + FieldOffset, V.Desc, V.Offset);
208 for (const auto &F : D->ElemRecord->fields())
209 destroyField(B, Ptr + FieldOffset, F.Desc, F.Offset);
210}
211
212static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D) {
213 for (const auto &F : D->ElemRecord->bases())
214 destroyBase(B, Ptr, F.Desc, F.Offset);
215 for (const auto &F : D->ElemRecord->fields())
216 destroyField(B, Ptr, F.Desc, F.Offset);
217 for (const auto &F : D->ElemRecord->virtual_bases())
218 destroyBase(B, Ptr, F.Desc, F.Offset);
219}
220
221/// Whether a record needs its descriptor dtor function called.
222static bool needsRecordDtor(const Record *R) {
223 for (const auto &B : R->bases()) {
224 if (B.Desc->DtorFn)
225 return true;
226 }
227
228 for (const auto &F : R->fields()) {
229 if (F.Desc->DtorFn)
230 return true;
231 }
232
233 for (const auto &V : R->virtual_bases()) {
234 if (V.Desc->DtorFn)
235 return true;
236 }
237 return false;
238}
239
241 switch (T) {
242 case PT_Float:
244 case PT_IntAP:
246 case PT_IntAPS:
248 case PT_Ptr:
250 case PT_MemberPtr:
252 default:
253 return nullptr;
254 }
255 llvm_unreachable("Unhandled PrimType");
256}
257
259 switch (T) {
260 case PT_Float:
262 case PT_IntAP:
264 case PT_IntAPS:
266 case PT_Ptr:
268 case PT_MemberPtr:
270 default:
271 return nullptr;
272 }
273 llvm_unreachable("Unhandled PrimType");
274}
275
278 llvm_unreachable("unknown Expr");
279}
280
283 llvm_unreachable("unknown Expr");
284}
285
286/// Primitives.
287Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy, PrimType Type,
288 MetadataSize MD, bool IsConst, bool IsTemporary,
289 bool IsMutable, bool IsVolatile)
290 : Source(D), SourceType(SourceTy), ElemSize(primSize(Type)), Size(ElemSize),
291 MDSize(MD.value_or(0)), AllocSize(align(Size + MDSize)), PrimT(Type),
295 assert(AllocSize >= Size);
296 assert(Source && "Missing source");
297}
298
299/// Primitive arrays.
301 size_t NumElems, bool IsConst, bool IsTemporary,
302 bool IsMutable)
303 : Source(D), ElemSize(primSize(Type)), Size(ElemSize * NumElems),
304 MDSize(MD.value_or(0)),
305 AllocSize(align(MDSize) + align(Size) + sizeof(InitMapPtr)), PrimT(Type),
309 assert(Source && "Missing source");
310 assert(NumElems <= (MaxArrayElemBytes / ElemSize));
311}
312
313/// Primitive unknown-size arrays.
315 bool IsTemporary, bool IsConst, UnknownSize)
316 : Source(D), ElemSize(primSize(Type)), Size(UnknownSizeMark),
317 MDSize(MD.value_or(0)),
318 AllocSize(MDSize + sizeof(InitMapPtr) + alignof(void *)), PrimT(Type),
322 assert(Source && "Missing source");
323}
324
325/// Arrays of composite elements.
326Descriptor::Descriptor(const DeclTy &D, const Type *SourceTy,
327 const Descriptor *Elem, MetadataSize MD,
328 unsigned NumElems, bool IsConst, bool IsTemporary,
329 bool IsMutable)
330 : Source(D), SourceType(SourceTy),
331 ElemSize(Elem->getAllocSize() + sizeof(InlineDescriptor)),
332 Size(ElemSize * NumElems), MDSize(MD.value_or(0)),
333 AllocSize(std::max<size_t>(alignof(void *), Size) + MDSize),
337 assert(Source && "Missing source");
338}
339
340/// Unknown-size arrays of composite elements.
343 : Source(D), ElemSize(Elem->getAllocSize() + sizeof(InlineDescriptor)),
344 Size(UnknownSizeMark), MDSize(MD.value_or(0)),
345 AllocSize(MDSize + alignof(void *)), ElemDesc(Elem), IsConst(true),
348 assert(Source && "Missing source");
349}
350
351/// Composite records.
353 bool IsConst, bool IsTemporary, bool IsMutable,
354 bool IsVolatile)
355 : Source(D), ElemSize(std::max<size_t>(alignof(void *), R->getFullSize())),
356 Size(ElemSize), MDSize(MD.value_or(0)), AllocSize(Size + MDSize),
360 assert(Source && "Missing source");
361}
362
363/// Dummy.
365 : Source(D), ElemSize(1), Size(1), MDSize(MD.value_or(0)),
366 AllocSize(MDSize), ElemRecord(nullptr), IsConst(true), IsMutable(false),
368 assert(Source && "Missing source");
369}
370
372 if (SourceType)
373 return QualType(SourceType, 0);
374 if (const auto *D = asValueDecl())
375 return D->getType();
376 if (const auto *T = dyn_cast_if_present<TypeDecl>(asDecl()))
377 return T->getASTContext().getTypeDeclType(T);
378
379 // The Source sometimes has a different type than the once
380 // we really save. Try to consult the Record first.
381 if (isRecord()) {
382 const RecordDecl *RD = ElemRecord->getDecl();
383 return RD->getASTContext().getCanonicalTagType(RD);
384 }
385 if (const auto *E = asExpr())
386 return E->getType();
387 llvm_unreachable("Invalid descriptor type");
388}
389
391 assert(isArray());
392 QualType T = getType();
393 if (const auto *AT = T->getAs<AtomicType>())
394 T = AT->getValueType();
395 if (T->isPointerOrReferenceType())
396 T = T->getPointeeType();
397
398 if (const auto *AT = T->getAsArrayTypeUnsafe()) {
399 // For primitive arrays, we don't save a QualType at all,
400 // just a PrimType. Try to figure out the QualType here.
401 if (isPrimitiveArray()) {
402 while (T->isArrayType())
403 T = T->getAsArrayTypeUnsafe()->getElementType();
404 return T;
405 }
406 return AT->getElementType();
407 }
408 if (const auto *CT = T->getAs<ComplexType>())
409 return CT->getElementType();
410 if (const auto *CT = T->getAs<VectorType>())
411 return CT->getElementType();
412
413 return T;
414}
415
417 auto MakeArrayType = [&](QualType ElemType) -> QualType {
418 if (IsArray)
419 return Ctx.getConstantArrayType(
420 ElemType, APInt(64, static_cast<uint64_t>(getNumElems()), false),
421 nullptr, ArraySizeModifier::Normal, 0);
422 return ElemType;
423 };
424
425 if (const auto *E = asExpr()) {
426 if (isa<CXXNewExpr>(E))
427 return MakeArrayType(E->getType()->getPointeeType());
428
429 // std::allocator.allocate() call.
430 if (const auto *ME = dyn_cast<CXXMemberCallExpr>(E);
431 ME && ME->getRecordDecl()->getName() == "allocator" &&
432 ME->getMethodDecl()->getName() == "allocate")
433 return MakeArrayType(E->getType()->getPointeeType());
434 return E->getType();
435 }
436
437 return getType();
438}
439
441 if (const auto *E = asExpr()) {
442 if (isa<CXXNewExpr>(E))
443 return E->getType()->getPointeeType();
444
445 // std::allocator.allocate() call.
446 if (const auto *ME = dyn_cast<CXXMemberCallExpr>(E);
447 ME && ME->getRecordDecl()->getName() == "allocator" &&
448 ME->getMethodDecl()->getName() == "allocate")
449 return E->getType()->getPointeeType();
450 return E->getType();
451 }
452
453 return getType();
454}
455
457 if (auto *D = dyn_cast<const Decl *>(Source))
458 return D->getLocation();
459 if (auto *E = dyn_cast<const Expr *>(Source))
460 return E->getExprLoc();
461 llvm_unreachable("Invalid descriptor type");
462}
463
465 if (const auto *D = dyn_cast<const Decl *>(Source))
466 return SourceInfo(D);
467 if (const auto *E = dyn_cast<const Expr *>(Source))
468 return SourceInfo(E);
469 llvm_unreachable("Invalid descriptor type");
470}
471
473 if (isPrimitive() || isPrimitiveArray())
474 return true;
475
476 if (isRecord()) {
477 assert(ElemRecord);
478 return ElemRecord->hasTrivialDtor();
479 }
480
481 if (!ElemDesc)
482 return true;
483 // Composite arrays.
484 return ElemDesc->hasTrivialDtor();
485}
486
487bool Descriptor::isUnion() const { return isRecord() && ElemRecord->isUnion(); }
488
490 if ((isPrimitive() || isPrimitiveArray()) &&
492 FIXED_SIZE_INT_TYPE_SWITCH(getPrimType(), { return T::bitWidth() / 8; });
493 }
494 return ElemSize;
495}
#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:226
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.
CanQualType getCanonicalTagType(const TagDecl *TD) const
Complex values, per C99 6.2.5p11.
Definition TypeBase.h:3325
ASTContext & getASTContext() const LLVM_READONLY
Definition DeclBase.cpp:547
A (possibly-)qualified type.
Definition TypeBase.h:937
Represents a struct/union/class.
Definition Decl.h:4342
Encodes a location in the source.
The base class of the type hierarchy.
Definition TypeBase.h:1866
Represents a GCC generic vector type.
Definition TypeBase.h:4225
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:1424
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',...
#define false
Definition stdbool.h:26
#define true
Definition stdbool.h:25
Token to denote structures of unknown size.
Definition Descriptor.h:141
Describes a memory block created by an allocation site.
Definition Descriptor.h:122
const bool IsConst
Flag indicating if the block is mutable.
Definition Descriptor.h:161
unsigned getAllocSize() const
Returns the allocated size, including metadata.
Definition Descriptor.h:247
unsigned getNumElems() const
Returns the number of elements stored in the block.
Definition Descriptor.h:259
bool isPrimitive() const
Checks if the descriptor is of a primitive.
Definition Descriptor.h:273
QualType getElemQualType() const
bool hasTrivialDtor() const
Whether variables of this descriptor need their destructor called or not.
const BlockDtorFn DtorFn
Definition Descriptor.h:173
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:159
const ValueDecl * asValueDecl() const
Definition Descriptor.h:215
const BlockCtorFn CtorFn
Storage management methods.
Definition Descriptor.h:172
static constexpr unsigned MaxArrayElemBytes
Maximum number of bytes to be used for array elements.
Definition Descriptor.h:148
QualType getType() const
const Decl * asDecl() const
Definition Descriptor.h:211
const Descriptor *const ElemDesc
Descriptor of the array element.
Definition Descriptor.h:155
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:163
QualType getDataType(const ASTContext &Ctx) const
std::optional< unsigned > MetadataSize
Definition Descriptor.h:143
const bool IsArray
Flag indicating if the block is an array.
Definition Descriptor.h:168
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:264
QualType getDataElemType() const
PrimType getPrimType() const
Definition Descriptor.h:241
bool isRecord() const
Checks if the descriptor is of a record.
Definition Descriptor.h:278
const bool IsTemporary
Flag indicating if the block is a temporary.
Definition Descriptor.h:165
const Record *const ElemRecord
Pointer to the record, if block contains records.
Definition Descriptor.h:153
bool isUnion() const
Checks if the descriptor is of a union.
const Expr * asExpr() const
Definition Descriptor.h:212
bool isArray() const
Checks if the descriptor is of an array.
Definition Descriptor.h:276
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:67
unsigned Offset
Offset inside the structure/array.
Definition Descriptor.h:69