Move imported C++ entities to the import block (#5616)

This mirrors how imports work in general, that the imported declarations
shouldn't belong to the first referencing scope (particularly apparent
when referenced across multiple scopes). I think this was just an
oversight here.
This commit is contained in:
Jon Ross-Perkins
2025-06-05 18:44:27 +00:00
committed by GitHub
parent 51b4abec20
commit 9b1a0729a1
11 changed files with 280 additions and 277 deletions
+5 -3
View File
@@ -459,7 +459,8 @@ static auto ImportFunctionDecl(Context& context, SemIR::LocId loc_id,
auto function_decl = SemIR::FunctionDecl{
SemIR::TypeId::None, SemIR::FunctionId::None, SemIR::InstBlockId::Empty};
auto decl_id =
AddPlaceholderInst(context, Parse::NodeId::None, function_decl);
AddPlaceholderInstInNoBlock(context, Parse::NodeId::None, function_decl);
context.import_ref_ids().push_back(decl_id);
auto function_info = SemIR::Function{
{.name_id = name_id,
@@ -517,8 +518,9 @@ static auto BuildClassDecl(Context& context, SemIR::NameScopeId parent_scope_id,
.class_id = SemIR::ClassId::None,
.decl_block_id = SemIR::InstBlockId::None};
// TODO: Consider setting a proper location.
auto class_decl_id =
AddPlaceholderInst(context, SemIR::LocIdAndInst::NoLoc(class_decl));
auto class_decl_id = AddPlaceholderInstInNoBlock(
context, SemIR::LocIdAndInst::NoLoc(class_decl));
context.import_ref_ids().push_back(class_decl_id);
SemIR::Class class_info = {
{.name_id = name_id,