Move common entity fields to a 'base' struct. (#4161)

I'd considered moving DeclParams uses over, but when handling qualified
names, there's a parse node instead of an instruction. I did try to
unify a couple other uses though, including adding MergeDefinition. I
expect `interface` will use a little more once it's more completely
implemented, but maybe I'm wrong about that.
This commit is contained in:
Jon Ross-Perkins
2024-07-24 23:26:00 +00:00
committed by GitHub
parent a0973f4f47
commit bf89652a4d
21 changed files with 331 additions and 308 deletions
+10 -9
View File
@@ -1175,13 +1175,13 @@ static auto ConvertSelf(Context& context, SemIR::LocId call_loc_id,
auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
SemIR::InstId self_id,
llvm::ArrayRef<SemIR::InstId> arg_refs,
SemIR::InstId return_storage_id, SemIR::InstId callee_id,
SemIR::GenericInstanceId callee_specific_id,
SemIR::InstBlockId implicit_param_refs_id,
SemIR::InstBlockId param_refs_id) -> SemIR::InstBlockId {
SemIR::InstId return_storage_id,
const SemIR::EntityWithParamsBase& callee,
SemIR::GenericInstanceId callee_specific_id)
-> SemIR::InstBlockId {
auto implicit_param_refs =
context.inst_blocks().GetOrEmpty(implicit_param_refs_id);
auto param_refs = context.inst_blocks().GetOrEmpty(param_refs_id);
context.inst_blocks().GetOrEmpty(callee.implicit_param_refs_id);
auto param_refs = context.inst_blocks().GetOrEmpty(callee.param_refs_id);
// If sizes mismatch, fail early.
if (arg_refs.size() != param_refs.size()) {
@@ -1192,7 +1192,7 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
context.emitter()
.Build(call_loc_id, CallArgCountMismatch, arg_refs.size(),
param_refs.size())
.Note(callee_id, InCallToFunction)
.Note(callee.decl_id, InCallToFunction)
.Emit();
return SemIR::InstBlockId::Invalid;
}
@@ -1210,7 +1210,7 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
context.sem_ir(), implicit_param_id);
if (param.name_id == SemIR::NameId::SelfValue) {
auto converted_self_id =
ConvertSelf(context, call_loc_id, callee_id, callee_specific_id,
ConvertSelf(context, call_loc_id, callee.decl_id, callee_specific_id,
addr_pattern, param_id, param, self_id);
if (converted_self_id == SemIR::InstId::BuiltinError) {
return SemIR::InstBlockId::Invalid;
@@ -1229,7 +1229,8 @@ auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
CARBON_DIAGNOSTIC(
InCallToFunctionParam, Note,
"Initializing parameter {0} of function declared here.", int);
builder.Note(callee_id, InCallToFunctionParam, diag_param_index + 1);
builder.Note(callee.decl_id, InCallToFunctionParam,
diag_param_index + 1);
});
// Check type conversions per-element.