Init vptrs in Carbon initialization of Carbon-derived-from-C++ objects (#7323)

For review convenience, the Clang patch is available as an LLVM Draft PR
here: https://github.com/llvm/llvm-project/pull/202807
This commit is contained in:
David Blaikie
2026-06-16 04:50:57 +00:00
committed by GitHub
parent 88b3605eac
commit cf6a89db3f
14 changed files with 402 additions and 239 deletions
+8 -1
View File
@@ -687,7 +687,14 @@ static auto ImportClassObjectRepr(Context& context, SemIR::ClassId class_id,
static_assert(SemIR::CustomLayoutId::FirstFieldIndex == 2);
// TODO: Import vptr(s).
if (context.ast_context().getASTRecordLayout(clang_def).hasOwnVFPtr()) {
// Add a virtual function pointer to the beginning of the layout.
layout.push_back(SemIR::ObjectSize::Bytes(0));
fields.push_back(
{.name_id = SemIR::NameId::Vptr,
.type_inst_id = context.types().GetTypeInstId(
GetPointerType(context, SemIR::VtableType::TypeInstId))});
}
// The kind of base class we've picked so far. These are ordered in increasing
// preference order.