[clang] ca0e352 - [clang][bytecode][NFC] Remove extra `hasPointers()` check (#239513)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 6 01:54:47 PST 2026


Author: Timm Baeder
Date: 2026-11-06T10:54:43+01:00
New Revision: ca0e352c291ff663bfc54ba99829cc8734e9f0f0

URL: https://github.com/llvm/llvm-project/commit/ca0e352c291ff663bfc54ba99829cc8734e9f0f0
DIFF: https://github.com/llvm/llvm-project/commit/ca0e352c291ff663bfc54ba99829cc8734e9f0f0.diff

LOG: [clang][bytecode][NFC] Remove extra `hasPointers()` check (#239513)

We already assert that `hasPointers()` is true at the beginning of this
function.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/InterpState.cpp

Removed: 
    


################################################################################
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() {


        


More information about the cfe-commits mailing list