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

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 6 00:04:43 PST 2026


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/239513

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

>From efca47d00e3c76871ad37e7a44be584280a10091 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Fri, 6 Nov 2026 09:03:26 +0100
Subject: [PATCH] [clang][bytecode][NFC] Remove extra `hasPointers()` check

We already assert that `hasPointers()` is true at the beginning of this
function.
---
 clang/lib/AST/ByteCode/InterpState.cpp | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

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