[clang] 7e4047e - [clang][bytecode] Stop accessing Block::rawData() directly (#238033)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 23:00:20 PST 2026
Author: Timm Baeder
Date: 2026-11-03T08:00:14+01:00
New Revision: 7e4047e8c6f5a23cdf5174251051895e97bebb75
URL: https://github.com/llvm/llvm-project/commit/7e4047e8c6f5a23cdf5174251051895e97bebb75
DIFF: https://github.com/llvm/llvm-project/commit/7e4047e8c6f5a23cdf5174251051895e97bebb75.diff
LOG: [clang][bytecode] Stop accessing Block::rawData() directly (#238033)
The only thing in the raw data (before data()) is the block-level
descriptor, and we have `Block::getBlockDesc()` for that. Use it.
Added:
Modified:
clang/lib/AST/ByteCode/DynamicAllocator.cpp
clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/DynamicAllocator.cpp b/clang/lib/AST/ByteCode/DynamicAllocator.cpp
index b2f5260483d89..730889bdaf14e 100644
--- a/clang/lib/AST/ByteCode/DynamicAllocator.cpp
+++ b/clang/lib/AST/ByteCode/DynamicAllocator.cpp
@@ -72,20 +72,20 @@ Block *DynamicAllocator::allocate(const Descriptor *D, unsigned EvalID,
std::make_unique<std::byte[]>(Block::allocSize(D, Block::Local));
auto *B = new (Memory.get()) Block(EvalID, D, Block::Local);
B->invokeCtorNoMemset();
- InlineDescriptor *ID = reinterpret_cast<InlineDescriptor *>(B->rawData());
- ID->Desc = D;
- ID->IsActive = true;
- ID->Offset = sizeof(InlineDescriptor);
- ID->IsBase = false;
- ID->IsFieldMutable = false;
- ID->IsConst = false;
- ID->IsInitialized = false;
- ID->IsVolatile = false;
+ InlineDescriptor &ID = B->getBlockDesc<InlineDescriptor>();
+ ID.Desc = D;
+ ID.IsActive = true;
+ ID.Offset = sizeof(InlineDescriptor);
+ ID.IsBase = false;
+ ID.IsFieldMutable = false;
+ ID.IsConst = false;
+ ID.IsInitialized = false;
+ ID.IsVolatile = false;
if (D->isCompositeArray())
- ID->LifeState = Lifetime::Started;
+ ID.LifeState = Lifetime::Started;
else
- ID->LifeState =
+ ID.LifeState =
AllocForm == Form::Operator ? Lifetime::Ended : Lifetime::Started;
if (auto It = AllocationSites.find(D->asExpr());
diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
index 247176a900956..32343e8d79b72 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
@@ -102,13 +102,10 @@ convertToBlockPointer(const Context &Ctx, const StringPointer &SP) {
// Allocate storage for the string.
// The byte length does not include the null terminator.
- // unsigned GlobalIndex = Globals.size();
auto *Memory = new std::byte[sizeof(Block) + Desc->getAllocSize()];
auto *B = new (Memory) Block(Ctx.getEvalID(), Desc.get(), Block::None);
B->invokeCtor();
- new (B->rawData()) GlobalInlineDescriptor{GlobalInitState::Initialized};
-
Pointer Ptr(B);
if (CharWidth == 1) {
std::memcpy(&Ptr.elem<char>(0), S->getString().data(), StringLength);
More information about the cfe-commits
mailing list