Skip to content

Commit 8d26252

Browse files
authored
[clang][bytecode][NFC] Dead blocks are always uninitialized (#152699)
We always call the descriptor dtor before, so they are never initialized.
1 parent 479556c commit 8d26252

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

clang/lib/AST/ByteCode/InterpBlock.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
133133
}
134134

135135
void DeadBlock::free() {
136-
if (B.IsInitialized)
137-
B.invokeDtor();
136+
assert(!B.isInitialized());
138137

139138
if (Prev)
140139
Prev->Next = Next;

clang/lib/AST/ByteCode/InterpState.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void InterpState::deallocate(Block *B) {
8585
if (B->IsInitialized)
8686
B->invokeDtor();
8787

88+
assert(!B->isInitialized());
8889
if (B->hasPointers()) {
8990
size_t Size = B->getSize();
9091
// Allocate a new block, transferring over pointers.
@@ -94,10 +95,7 @@ void InterpState::deallocate(Block *B) {
9495
// Since the block doesn't hold any actual data anymore, we can just
9596
// memcpy() everything over.
9697
std::memcpy(D->rawData(), B->rawData(), B->getSize());
97-
D->B.IsInitialized = B->IsInitialized;
98-
99-
// We moved the contents over to the DeadBlock.
100-
B->IsInitialized = false;
98+
D->B.IsInitialized = false;
10199
}
102100
}
103101

0 commit comments

Comments
 (0)