mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 16:01:05 +01:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user