Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,9 @@ void CIRRecordLowering::computeVolatileBitfields() {
void CIRRecordLowering::accumulateBases() {
// If we've got a primary virtual base, we need to add it with the bases.
if (astRecordLayout.isPrimaryBaseVirtual()) {
cirGenTypes.getCGModule().errorNYI(recordDecl->getSourceRange(),
"accumulateBases: primary virtual base");
const CXXRecordDecl *baseDecl = astRecordLayout.getPrimaryBase();
members.push_back(MemberInfo(CharUnits::Zero(), MemberInfo::InfoKind::Base,
getStorageType(baseDecl), baseDecl));
}

// Accumulate the non-virtual bases.
Expand Down
23 changes: 23 additions & 0 deletions clang/test/CIR/CodeGen/vbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG

// Test the record layout for a class with a primary virtual base.
class Base {
public:
virtual void f();
};

class Derived : public virtual Base {};

// This is just here to force the record types to be emitted.
void f() {
Derived d;
}

// CIR: !rec_Base = !cir.record<class "Base" {!cir.vptr}>
// CIR: !rec_Derived = !cir.record<class "Derived" {!rec_Base}>

// LLVM: %class.Derived = type { %class.Base }
// LLVM: %class.Base = type { ptr }

// OGCG: %class.Derived = type { %class.Base }
// OGCG: %class.Base = type { ptr }

// Test the constructor handling for a class with a virtual base.
struct A {
int a;
};
Expand Down