[clang] [clang][bytecode][NFC] Remove extra `hasPointers()` check (PR #239513)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 6 00:05:17 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
We already assert that `hasPointers()` is true at the beginning of this function.
---
Full diff: https://github.com/llvm/llvm-project/pull/239513.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpState.cpp (+9-11)
``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpState.cpp b/clang/lib/AST/ByteCode/InterpState.cpp
index 5816311ade340..e6a743a1f2154 100644
--- a/clang/lib/AST/ByteCode/InterpState.cpp
+++ b/clang/lib/AST/ByteCode/InterpState.cpp
@@ -101,17 +101,15 @@ void InterpState::deallocateWithPointers(Block *B) {
assert(!B->isDead());
assert(!B->isInitialized());
- if (B->hasPointers()) {
- size_t Size = B->getAllocSize();
- // Allocate a new block, transferring over pointers.
- char *Memory =
- reinterpret_cast<char *>(std::malloc(sizeof(DeadBlock) + Size));
- auto *D = new (Memory) DeadBlock(DeadBlocks, B);
- // Since the block doesn't hold any actual data anymore, we can just
- // memcpy() everything over.
- std::memcpy(D->rawData(), B->rawData(), Size);
- D->B.IsInitialized = false;
- }
+ size_t Size = B->getAllocSize();
+ // Allocate a new block, transferring over pointers.
+ char *Memory =
+ reinterpret_cast<char *>(std::malloc(sizeof(DeadBlock) + Size));
+ auto *D = new (Memory) DeadBlock(DeadBlocks, B);
+ // Since the block doesn't hold any actual data anymore, we can just
+ // memcpy() everything over.
+ std::memcpy(D->rawData(), B->rawData(), Size);
+ D->B.IsInitialized = false;
}
bool InterpState::maybeDiagnoseDanglingAllocations() {
``````````
</details>
https://github.com/llvm/llvm-project/pull/239513
More information about the cfe-commits
mailing list