Add fields for extern to EntityWithParamsBase (#4206)

This adds fields to `EntityWithParamsBase` to reflect the intention with
`extern library` design. I'm renaming `decl_id` because it shouldn't be
expected to be assigned anymore. import_ref.cpp I'm deliberately keeping
on `first_owning_decl_id` (which will break when importing `extern
library` declarations). Most other cases are for diagnostics, and I'm
using `latest_decl_id` to try and get the closest declaration to the
error. Note I'm partly splitting out this PR to show the test effect,
which apparently we don't test related cases.
This commit is contained in:
Jon Ross-Perkins authored and GitHub committed 2024-08-12 19:50:15 +00:00
1 parent c5b5d36e8b
commit 0feb757de0
14 files changed
+80 -54

No files matched your search

+3 -3
View File
@@ -75,7 +75,7 @@ static auto BuildInterfaceDecl(Context& context,
{.loc = node_id,
.is_definition = is_definition,
.is_extern = false},
{.loc = existing_interface.decl_id,
{.loc = existing_interface.latest_decl_id(),
.is_definition = existing_interface.is_defined(),
.is_extern = false},
/*prev_import_ir_id=*/SemIR::ImportIRId::Invalid);
@@ -103,8 +103,8 @@ static auto BuildInterfaceDecl(Context& context,
// there was an error in the qualifier, we will have lost track of the
// interface name here. We should keep track of it even if the name is
// invalid.
SemIR::Interface interface_info = {
name_context.MakeEntityWithParamsBase(interface_decl_id, name)};
SemIR::Interface interface_info = {name_context.MakeEntityWithParamsBase(
name, interface_decl_id, /*is_extern=*/false)};
interface_info.generic_id = FinishGenericDecl(context, interface_decl_id);
interface_decl.interface_id = context.interfaces().Add(interface_info);
if (interface_info.has_parameters()) {