llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> The only thing in the raw data (before data()) is the block-level descriptor, and we have `Block::getBlockDesc()` for that. Use it. --- Full diff: https://github.com/llvm/llvm-project/pull/238033.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/DynamicAllocator.cpp (+11-11) - (modified) clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp (-3) ``````````diff 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); `````````` </details> https://github.com/llvm/llvm-project/pull/238033 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
