[clang] [clang][bytecode][NFC] Dead blocks are always uninitialized (PR #152699)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 8 05:27:16 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
We always call the descriptor dtor before, so they are never initialized.
---
Full diff: https://github.com/llvm/llvm-project/pull/152699.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpBlock.cpp (+1-2)
- (modified) clang/lib/AST/ByteCode/InterpState.cpp (+2-4)
``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBlock.cpp b/clang/lib/AST/ByteCode/InterpBlock.cpp
index b0e048bc867e9..8b7f6a750040b 100644
--- a/clang/lib/AST/ByteCode/InterpBlock.cpp
+++ b/clang/lib/AST/ByteCode/InterpBlock.cpp
@@ -133,8 +133,7 @@ DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
}
void DeadBlock::free() {
- if (B.IsInitialized)
- B.invokeDtor();
+ assert(!B.isInitialized());
if (Prev)
Prev->Next = Next;
diff --git a/clang/lib/AST/ByteCode/InterpState.cpp b/clang/lib/AST/ByteCode/InterpState.cpp
index f7f03e593301f..5593531bdabe3 100644
--- a/clang/lib/AST/ByteCode/InterpState.cpp
+++ b/clang/lib/AST/ByteCode/InterpState.cpp
@@ -85,6 +85,7 @@ void InterpState::deallocate(Block *B) {
if (B->IsInitialized)
B->invokeDtor();
+ assert(!B->isInitialized());
if (B->hasPointers()) {
size_t Size = B->getSize();
// Allocate a new block, transferring over pointers.
@@ -94,10 +95,7 @@ void InterpState::deallocate(Block *B) {
// Since the block doesn't hold any actual data anymore, we can just
// memcpy() everything over.
std::memcpy(D->rawData(), B->rawData(), B->getSize());
- D->B.IsInitialized = B->IsInitialized;
-
- // We moved the contents over to the DeadBlock.
- B->IsInitialized = false;
+ D->B.IsInitialized = false;
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/152699
More information about the cfe-commits
mailing list