mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-21 16:06:37 +00:00
Support C++ friend declarations for Carbon classes (#8018)
When importing a C++ class, check for friend declarations for types and add them to the Carbon class's `friend_scopes`.
This commit is contained in:
1 parent
789f582eb1
commit
6f6a01f859
2 files changed
+39
No files matched your search
@@ -1015,6 +1015,23 @@ static auto BuildClassDefinition(Context& context,
|
||||
.vtable_id = vtable_id}));
|
||||
}
|
||||
|
||||
// Import friend declarations.
|
||||
for (const auto* f : clang_def->friends()) {
|
||||
if (const auto* type_source_info = f->getFriendType()) {
|
||||
auto [friend_type_inst_id, friend_type_id] =
|
||||
ImportCppType(context, SemIR::LocId(import_ir_inst_id),
|
||||
type_source_info->getType());
|
||||
|
||||
if (!friend_type_id.has_value()) {
|
||||
// TODO: For now, just skip over friends whose types we can't map.
|
||||
continue;
|
||||
}
|
||||
|
||||
class_info.friend_scopes.Insert(
|
||||
context.types().GetConstantId(friend_type_id));
|
||||
}
|
||||
}
|
||||
|
||||
class_info.body_block_id = context.inst_block_stack().Pop();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user