https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/236334

>From 684f0e991551d48e000a11e802ce3ffcfc9553f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Wed, 28 Oct 2026 08:29:22 +0100
Subject: [PATCH] [clang][bytecode] Use first decl in Record base map

---
 clang/lib/AST/ByteCode/Record.cpp |  8 ++++----
 clang/test/AST/ByteCode/cxx20.cpp | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Record.cpp 
b/clang/lib/AST/ByteCode/Record.cpp
index 4907f142ac3c0..897c8e2bfa15c 100644
--- a/clang/lib/AST/ByteCode/Record.cpp
+++ b/clang/lib/AST/ByteCode/Record.cpp
@@ -20,7 +20,7 @@ Record::Record(const RecordDecl *Decl, ArrayRef<Base> Bases,
       IsAnonymousUnion(IsUnion && Decl->isAnonymousStructOrUnion()),
       HasPtrField(HasPtrField) {
   for (const Base &B : this->Bases)
-    BaseMap[B.Decl] = &B;
+    BaseMap[cast<RecordDecl>(B.Decl->getFirstDecl())] = &B;
 }
 
 std::string Record::getName() const {
@@ -48,18 +48,18 @@ const Record::Field *Record::findField(unsigned Offset) 
const {
 }
 
 const Record::Base *Record::getBase(const RecordDecl *RD) const {
-  auto It = BaseMap.find(RD);
+  auto It = BaseMap.find(cast<RecordDecl>(RD->getFirstDecl()));
   assert(It != BaseMap.end() && "Missing base");
   return It->second;
 }
 
 const Record::Base *Record::getBaseOrNull(const RecordDecl *RD) const {
-  return BaseMap.lookup(RD);
+  return BaseMap.lookup(cast<RecordDecl>(RD->getFirstDecl()));
 }
 
 const Record::Base *Record::getBase(QualType T) const {
   if (auto *RD = T->getAsCXXRecordDecl())
-    return BaseMap.lookup(RD);
+    return BaseMap.lookup(cast<RecordDecl>(RD->getFirstDecl()));
   return nullptr;
 }
 
diff --git a/clang/test/AST/ByteCode/cxx20.cpp 
b/clang/test/AST/ByteCode/cxx20.cpp
index 5ef748e162a23..0c1b5e2730511 100644
--- a/clang/test/AST/ByteCode/cxx20.cpp
+++ b/clang/test/AST/ByteCode/cxx20.cpp
@@ -1598,3 +1598,23 @@ namespace ConditionalOperatorInBORHS {
   };
   static_assert(a{}.e() == 12);
 }
+
+namespace BaseRedecl {
+  struct S;
+  struct A {
+    constexpr char foo() const { return 'A'; }
+    constexpr ~A() {}
+  };
+  struct S : A {};
+  struct B : S {};
+  struct N : B {};
+  struct C : A {
+    A *a;
+    constexpr C(A *a) : a(a) {}
+  };
+  struct D : N, C {
+    constexpr D() : C((B *)this) {}
+  };
+
+  constexpr D d;
+}

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

Reply via email to