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

The Record constructor has a parameter and a class member of the same name. 
Also include composite array element types in the calculation in Program.cpp.

>From 5505ad4efeb3ed9c6d4750dfad98826f2ca0149c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Wed, 4 Mar 2026 08:08:24 +0100
Subject: [PATCH] [clang][bytecode] Fix a mishap in HasPtrField calculation

The Record constructor has a parameter and a class member of the same
name. Also include composite array element types in the calculation in
Program.cpp.
---
 clang/lib/AST/ByteCode/Program.cpp | 14 ++++++++------
 clang/lib/AST/ByteCode/Record.cpp  |  8 ++++----
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Program.cpp 
b/clang/lib/AST/ByteCode/Program.cpp
index 7eebb303d8553..7364e9405efe2 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -376,14 +376,16 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
       Desc = createDescriptor(FD, *T, nullptr, std::nullopt, IsConst,
                               /*isTemporary=*/false, IsMutable, IsVolatile);
       HasPtrField = HasPtrField || (T == PT_Ptr);
+    } else if ((Desc = createDescriptor(
+                    FD, FT.getTypePtr(), std::nullopt, IsConst,
+                    /*isTemporary=*/false, IsMutable, IsVolatile))) {
+      HasPtrField =
+          HasPtrField ||
+          (Desc->isPrimitiveArray() && Desc->getPrimType() == PT_Ptr) ||
+          (Desc->ElemRecord && Desc->ElemRecord->hasPtrField());
     } else {
-      Desc = createDescriptor(FD, FT.getTypePtr(), std::nullopt, IsConst,
-                              /*isTemporary=*/false, IsMutable, IsVolatile);
-      HasPtrField = HasPtrField || (Desc && Desc->isPrimitiveArray() &&
-                                    Desc->getPrimType() == PT_Ptr);
-    }
-    if (!Desc)
       return nullptr;
+    }
     Fields.emplace_back(FD, Desc, BaseSize);
     BaseSize += align(Desc->getAllocSize());
   }
diff --git a/clang/lib/AST/ByteCode/Record.cpp 
b/clang/lib/AST/ByteCode/Record.cpp
index f0ec33f54901c..13a5ffb85787c 100644
--- a/clang/lib/AST/ByteCode/Record.cpp
+++ b/clang/lib/AST/ByteCode/Record.cpp
@@ -24,13 +24,13 @@ Record::Record(const RecordDecl *Decl, BaseList &&SrcBases,
 
   for (Base &B : Bases) {
     BaseMap[B.Decl] = &B;
-    if (!HasPtrField)
-      HasPtrField |= B.R->hasPtrField();
+    if (!this->HasPtrField)
+      this->HasPtrField |= B.R->hasPtrField();
   }
   for (Base &V : VirtualBases) {
     VirtualBaseMap[V.Decl] = &V;
-    if (!HasPtrField)
-      HasPtrField |= V.R->hasPtrField();
+    if (!this->HasPtrField)
+      this->HasPtrField |= V.R->hasPtrField();
   }
 }
 

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

Reply via email to