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

We don't need the `Block*` parameter in the descriptor ctor/dtor functions.

>From e5645b0da3630788cfab1697d54175d821869b39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Mon, 26 Oct 2026 06:16:36 +0100
Subject: [PATCH] [clang][bytecode][NFC] Remove unused parameter from
 ctors/dtors

---
 clang/lib/AST/ByteCode/Block.h        |  5 +--
 clang/lib/AST/ByteCode/Descriptor.cpp | 63 ++++++++++++---------------
 clang/lib/AST/ByteCode/Descriptor.h   | 10 ++---
 3 files changed, 35 insertions(+), 43 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Block.h b/clang/lib/AST/ByteCode/Block.h
index cac9d683bc1395..83d26f587230ad 100644
--- a/clang/lib/AST/ByteCode/Block.h
+++ b/clang/lib/AST/ByteCode/Block.h
@@ -140,8 +140,7 @@ class Block final {
   void invokeCtorNoMemset() {
     assert(!IsInitialized);
     if (Desc->CtorFn)
-      Desc->CtorFn(this, data(), Desc->IsConst, Desc->IsMutable,
-                   Desc->IsVolatile,
+      Desc->CtorFn(data(), Desc->IsConst, Desc->IsMutable, Desc->IsVolatile,
                    /*isActive=*/true, /*InUnion=*/false, Desc);
 
     IsInitialized = true;
@@ -151,7 +150,7 @@ class Block final {
   void invokeDtor() {
     assert(IsInitialized);
     if (Desc->DtorFn)
-      Desc->DtorFn(this, data(), Desc);
+      Desc->DtorFn(data(), Desc);
     IsInitialized = false;
   }
 
diff --git a/clang/lib/AST/ByteCode/Descriptor.cpp 
b/clang/lib/AST/ByteCode/Descriptor.cpp
index 2c8e3c0da7f9d2..16baad40fdee72 100644
--- a/clang/lib/AST/ByteCode/Descriptor.cpp
+++ b/clang/lib/AST/ByteCode/Descriptor.cpp
@@ -7,7 +7,6 @@
 
//===----------------------------------------------------------------------===//
 
 #include "Descriptor.h"
-#include "Boolean.h"
 #include "Char.h"
 #include "ExprConstShared.h"
 #include "FixedPoint.h"
@@ -18,11 +17,8 @@
 #include "Pointer.h"
 #include "PrimType.h"
 #include "Record.h"
-#include "Reflect.h"
 #include "Source.h"
 #include "clang/AST/ExprCXX.h"
-#include "clang/Basic/TargetInfo.h"
-#include "llvm/Support/ErrorHandling.h"
 
 using namespace clang;
 using namespace clang::interp;
@@ -31,14 +27,13 @@ template <typename T> static constexpr bool needsDtor() {
   return std::is_same_v<T, Pointer> || std::is_same_v<T, MemberPointer>;
 }
 
-template <typename T>
-static void dtorTy(Block *, std::byte *Ptr, const Descriptor *) {
+template <typename T> static void dtorTy(std::byte *Ptr, const Descriptor *) {
   static_assert(needsDtor<T>());
   reinterpret_cast<T *>(Ptr)->~T();
 }
 
 template <typename T>
-static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D) {
+static void dtorArrayTy(std::byte *Ptr, const Descriptor *D) {
   InitMapPtr &IMP = *reinterpret_cast<InitMapPtr *>(Ptr);
   IMP.deleteInitMap();
 
@@ -50,9 +45,9 @@ static void dtorArrayTy(Block *, std::byte *Ptr, const 
Descriptor *D) {
   }
 }
 
-static void ctorArrayDesc(Block *B, std::byte *Ptr, bool IsConst,
-                          bool IsMutable, bool IsVolatile, bool IsActive,
-                          bool InUnion, const Descriptor *D) {
+static void ctorArrayDesc(std::byte *Ptr, bool IsConst, bool IsMutable,
+                          bool IsVolatile, bool IsActive, bool InUnion,
+                          const Descriptor *D) {
   const unsigned NumElems = D->getNumElems();
   const unsigned ElemSize =
       D->ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
@@ -76,13 +71,13 @@ static void ctorArrayDesc(Block *B, std::byte *Ptr, bool 
IsConst,
 
     if (auto Fn = D->ElemDesc->CtorFn) {
       auto *ElemLoc = reinterpret_cast<std::byte *>(Desc + 1);
-      Fn(B, ElemLoc, Desc->IsConst, Desc->IsFieldMutable, IsVolatile, IsActive,
+      Fn(ElemLoc, Desc->IsConst, Desc->IsFieldMutable, IsVolatile, IsActive,
          Desc->InUnion || SD->isUnion(), D->ElemDesc);
     }
   }
 }
 
-static void dtorArrayDesc(Block *B, std::byte *Ptr, const Descriptor *D) {
+static void dtorArrayDesc(std::byte *Ptr, const Descriptor *D) {
   const unsigned NumElems = D->getNumElems();
   const unsigned ElemSize =
       D->ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
@@ -95,11 +90,11 @@ static void dtorArrayDesc(Block *B, std::byte *Ptr, const 
Descriptor *D) {
     auto *ElemPtr = Ptr + ElemOffset;
     auto *Desc = reinterpret_cast<InlineDescriptor *>(ElemPtr);
     auto *ElemLoc = reinterpret_cast<std::byte *>(Desc + 1);
-    Dtor(B, ElemLoc, D->ElemDesc);
+    Dtor(ElemLoc, D->ElemDesc);
   }
 }
 
-static void initField(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
+static void initField(std::byte *Ptr, bool IsConst, bool IsMutable,
                       bool IsVolatile, bool IsActive, bool IsUnionField,
                       bool InUnion, const Descriptor *D, unsigned FieldOffset) 
{
   auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + FieldOffset) - 1;
@@ -120,11 +115,11 @@ static void initField(Block *B, std::byte *Ptr, bool 
IsConst, bool IsMutable,
           : (Desc->IsActive ? Lifetime::NotStarted : Lifetime::Started);
 
   if (auto Fn = D->CtorFn)
-    Fn(B, Ptr + FieldOffset, Desc->IsConst, Desc->IsFieldMutable,
-       Desc->IsVolatile, Desc->IsActive, InUnion || D->isUnion(), D);
+    Fn(Ptr + FieldOffset, Desc->IsConst, Desc->IsFieldMutable, 
Desc->IsVolatile,
+       Desc->IsActive, InUnion || D->isUnion(), D);
 }
 
-static void initBase(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
+static void initBase(std::byte *Ptr, bool IsConst, bool IsMutable,
                      bool IsVolatile, bool IsActive, bool InUnion,
                      const Descriptor *D, unsigned FieldOffset,
                      bool IsVirtualBase) {
@@ -145,55 +140,55 @@ static void initBase(Block *B, std::byte *Ptr, bool 
IsConst, bool IsMutable,
   Desc->IsVolatile = false;
 
   for (const auto &V : D->ElemRecord->bases())
-    initBase(B, Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive,
+    initBase(Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive,
              InUnion, V.Desc, V.Offset, false);
   for (const auto &F : D->ElemRecord->fields())
-    initField(B, Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive,
+    initField(Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive,
               InUnion, InUnion, F.Desc, F.Offset);
 }
 
-static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
+static void ctorRecord(std::byte *Ptr, bool IsConst, bool IsMutable,
                        bool IsVolatile, bool IsActive, bool InUnion,
                        const Descriptor *D) {
   for (const auto &V : D->ElemRecord->bases())
-    initBase(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc,
+    initBase(Ptr, IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc,
              V.Offset,
              /*IsVirtualBase=*/false);
   for (const auto &F : D->ElemRecord->fields()) {
     bool IsUnionField = D->isUnion();
-    initField(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, IsUnionField,
+    initField(Ptr, IsConst, IsMutable, IsVolatile, IsActive, IsUnionField,
               InUnion || IsUnionField, F.Desc, F.Offset);
   }
   for (const auto &V : D->ElemRecord->virtual_bases())
-    initBase(B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc,
+    initBase(Ptr, IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc,
              V.Offset,
              /*IsVirtualBase=*/true);
 }
 
-static void destroyField(Block *B, std::byte *Ptr, const Descriptor *D,
+static void destroyField(std::byte *Ptr, const Descriptor *D,
                          unsigned FieldOffset) {
   if (auto Fn = D->DtorFn)
-    Fn(B, Ptr + FieldOffset, D);
+    Fn(Ptr + FieldOffset, D);
 }
 
-static void destroyBase(Block *B, std::byte *Ptr, const Descriptor *D,
+static void destroyBase(std::byte *Ptr, const Descriptor *D,
                         unsigned FieldOffset) {
   assert(D);
   assert(D->ElemRecord);
 
   for (const auto &V : D->ElemRecord->bases())
-    destroyBase(B, Ptr + FieldOffset, V.Desc, V.Offset);
+    destroyBase(Ptr + FieldOffset, V.Desc, V.Offset);
   for (const auto &F : D->ElemRecord->fields())
-    destroyField(B, Ptr + FieldOffset, F.Desc, F.Offset);
+    destroyField(Ptr + FieldOffset, F.Desc, F.Offset);
 }
 
-static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D) {
+static void dtorRecord(std::byte *Ptr, const Descriptor *D) {
   for (const auto &F : D->ElemRecord->bases())
-    destroyBase(B, Ptr, F.Desc, F.Offset);
+    destroyBase(Ptr, F.Desc, F.Offset);
   for (const auto &F : D->ElemRecord->fields())
-    destroyField(B, Ptr, F.Desc, F.Offset);
+    destroyField(Ptr, F.Desc, F.Offset);
   for (const auto &F : D->ElemRecord->virtual_bases())
-    destroyBase(B, Ptr, F.Desc, F.Offset);
+    destroyBase(Ptr, F.Desc, F.Offset);
 }
 
 /// Whether a record needs its descriptor dtor function called.
@@ -270,7 +265,7 @@ static BlockCtorFn getCtorPrim(PrimType T) {
 
 
 template <typename T>
-static void ctorArrayTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
+static void ctorArrayTy(std::byte *Ptr, bool, bool, bool, bool, bool,
                         const Descriptor *D) {
   new (Ptr) InitMapPtr();
 
@@ -282,7 +277,7 @@ static void ctorArrayTy(Block *, std::byte *Ptr, bool, 
bool, bool, bool, bool,
   }
 }
 template <typename T>
-static void ctorTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
+static void ctorTy(std::byte *Ptr, bool, bool, bool, bool, bool,
                    const Descriptor *) {
   static_assert(needsCtor<T>());
   new (Ptr) T();
diff --git a/clang/lib/AST/ByteCode/Descriptor.h 
b/clang/lib/AST/ByteCode/Descriptor.h
index 567d08c4507d7b..7af548df7c4817 100644
--- a/clang/lib/AST/ByteCode/Descriptor.h
+++ b/clang/lib/AST/ByteCode/Descriptor.h
@@ -22,7 +22,6 @@
 
 namespace clang {
 namespace interp {
-class Block;
 class Record;
 class SourceInfo;
 struct Descriptor;
@@ -31,14 +30,13 @@ enum PrimType : uint8_t;
 /// Invoked whenever a block is created. The constructor method fills in the
 /// inline descriptors of all fields and array elements. It also initializes
 /// all the fields which contain non-trivial types.
-using BlockCtorFn = void (*)(Block *Storage, std::byte *FieldPtr, bool IsConst,
-                             bool IsMutable, bool IsVolatile, bool IsActive,
-                             bool InUnion, const Descriptor *FieldDesc);
+using BlockCtorFn = void (*)(std::byte *FieldPtr, bool IsConst, bool IsMutable,
+                             bool IsVolatile, bool IsActive, bool InUnion,
+                             const Descriptor *FieldDesc);
 
 /// Invoked when a block is destroyed. Invokes the destructors of all
 /// non-trivial nested fields of arrays and records.
-using BlockDtorFn = void (*)(Block *Storage, std::byte *FieldPtr,
-                             const Descriptor *FieldDesc);
+using BlockDtorFn = void (*)(std::byte *FieldPtr, const Descriptor *FieldDesc);
 
 enum class GlobalInitState {
   Initialized,

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to