[clang] c1101b0 - [clang][bytecode] Use first decl in Record base map (#236334)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 29 01:26:51 PDT 2026


Author: Timm Baeder
Date: 2026-10-29T09:26:45+01:00
New Revision: c1101b03d685f3e73c1ec73f5e688a7b7609e982

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

LOG: [clang][bytecode] Use first decl in Record base map (#236334)

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Record.cpp
    clang/test/AST/ByteCode/cxx20.cpp

Removed: 
    


################################################################################
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;
+}


        


More information about the cfe-commits mailing list