Import C++ vtables (#7174)

This correctly renders the vtable in SemIR, including allowing overrides
in
Carbon-derived-from-C++ classes.

It doesn't work in lowering because clang walks the methods of the
CXXRecordDecl - and we currently don't export anything into the
CXXRecordDecl's methods (we do export the fields) - so that's next.

This also doesn't teach Clang to affirmatively emit the vtable
regardless of the types use in C++ code - or to have Carbon use the
vtable in an object's initialization.
This commit is contained in:
David Blaikie
2026-05-11 17:33:08 +00:00
committed by GitHub
parent 0f5de499d6
commit df8b25522e
8 changed files with 508 additions and 46 deletions
+3
View File
@@ -709,6 +709,9 @@ auto FileContext::GetLocForDI(SemIR::InstId inst_id) -> Context::LocForDI {
auto FileContext::BuildVtable(const SemIR::Vtable& vtable,
SemIR::SpecificId specific_id)
-> llvm::GlobalVariable* {
if (!vtable.carbon_native_vtable) {
return nullptr;
}
const auto& class_info = sem_ir().classes().Get(vtable.class_id);
SemIR::Mangler m(sem_ir(), context().total_ir_count());