[clang] [clang][bytecode] Use `data()`-offset in `Pointer` (PR #234203)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 06:51:23 PST 2026
================
@@ -47,36 +48,54 @@ class Block final {
static constexpr uint8_t WeakFlag = 1 << 2;
public:
- static constexpr uint8_t InlineDescMD = sizeof(InlineDescriptor);
- static constexpr uint8_t GlobalMD = sizeof(GlobalInlineDescriptor);
+ enum BlockKind : uint8_t { None, Local, Global };
/// Creates a new block.
Block(unsigned EvalID, UnsignedOrNone DeclID, const Descriptor *Desc,
- unsigned MDSize = 0, bool IsStatic = false, bool IsExtern = false,
- bool IsWeak = false)
- : Desc(Desc), DeclID(DeclID), EvalID(EvalID), MDSize(MDSize),
- IsStatic(IsStatic) {
+ BlockKind K, bool IsExtern, bool IsWeak)
+
+ : Desc(Desc), DescSize(Desc->getAllocSize()), DeclID(DeclID),
+ EvalID(EvalID), Kind(K), MDSize(getMetadataSize(K)) {
assert(Desc);
AccessFlags |= (ExternFlag * IsExtern);
AccessFlags |= (WeakFlag * IsWeak);
}
- Block(unsigned EvalID, const Descriptor *Desc, unsigned MDSize = 0,
- bool IsStatic = false, bool IsExtern = false, bool IsWeak = false)
- : Desc(Desc), EvalID(EvalID), MDSize(MDSize), IsStatic(IsStatic) {
+ Block(unsigned EvalID, const Descriptor *Desc, BlockKind K,
+ bool IsExtern = false, bool IsWeak = false)
+ : Desc(Desc), DescSize(Desc->getAllocSize()), EvalID(EvalID), Kind(K),
+ MDSize(getMetadataSize(K)) {
assert(Desc);
AccessFlags |= (ExternFlag * IsExtern);
AccessFlags |= (WeakFlag * IsWeak);
}
+ /// Number of bytes needed to allocate the block.
+ static constexpr unsigned allocSize(const Descriptor *D, BlockKind K) {
+ return sizeof(Block) + getMetadataSize(K) + D->getAllocSize();
----------------
tbaederr wrote:
Should already be fixed by https://github.com/llvm/llvm-project/pull/237963
https://github.com/llvm/llvm-project/pull/234203
More information about the cfe-commits
mailing list