[clang] [clang][bytecode] Support virtual bases in C++26 (PR #204289)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 25 09:57:29 PDT 2026


Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/204289 at github.com>


================
@@ -863,17 +863,20 @@ bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD,
     // Accumulate and sort bases, in order to visit them in address order, which
     // may not be the same as declaration order.
     SmallVector<BaseInfo, 8> Bases;
-    Bases.reserve(CD->getNumBases());
+    Bases.reserve(Val.getStructNumBases());
     unsigned BaseNo = 0;
-    for (CXXRecordDecl::base_class_const_iterator Base = CD->bases_begin(),
-         BaseEnd = CD->bases_end(); Base != BaseEnd; ++Base, ++BaseNo) {
-      assert(!Base->isVirtual() && "should not have virtual bases here");
-      const CXXRecordDecl *BD = Base->getType()->getAsCXXRecordDecl();
+    for (const CXXBaseSpecifier &Base : CD->bases()) {
+      if (Base.isVirtual())
+        continue;
+      const CXXRecordDecl *BD = Base.getType()->getAsCXXRecordDecl();
       CharUnits BaseOffset = Layout.getBaseClassOffset(BD);
       Bases.push_back(BaseInfo(BD, BaseOffset, BaseNo));
+      ++BaseNo;
     }
     llvm::stable_sort(Bases);
 
+    // FIXME: Virtual bases?
+
----------------
tbaederr wrote:

@efriedma-quic Any idea where I could look for inspiration on how to test this? And the expected output in `virtual-bases-codegen.cpp`?

https://github.com/llvm/llvm-project/pull/204289


More information about the cfe-commits mailing list