mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 17:13:16 +01:00
Model the return slot as an output parameter (#4432)
Also fix `Param` insts to have meaningful names in pretty-printing, to help clarify relationship with return slot.
This commit is contained in:
@@ -95,6 +95,9 @@ auto Function::GetNameFromPatternId(const File& sem_ir, InstId pattern_id)
|
||||
inst_id = param_pattern_inst.subpattern_id;
|
||||
inst = sem_ir.insts().Get(inst_id);
|
||||
|
||||
if (inst.Is<ReturnSlotPattern>()) {
|
||||
return SemIR::NameId::ReturnSlot;
|
||||
}
|
||||
auto binding_pattern = inst.As<AnyBindingPattern>();
|
||||
return sem_ir.entity_names().Get(binding_pattern.entity_name_id).name_id;
|
||||
}
|
||||
@@ -115,11 +118,11 @@ auto Function::GetParamFromParamRefId(const File& sem_ir, InstId param_ref_id)
|
||||
|
||||
auto Function::GetDeclaredReturnType(const File& file,
|
||||
SpecificId specific_id) const -> TypeId {
|
||||
if (!return_storage_id.is_valid()) {
|
||||
if (!return_slot_id.is_valid()) {
|
||||
return TypeId::Invalid;
|
||||
}
|
||||
return GetTypeInSpecific(file, specific_id,
|
||||
file.insts().Get(return_storage_id).type_id());
|
||||
file.insts().Get(return_slot_id).type_id());
|
||||
}
|
||||
|
||||
} // namespace Carbon::SemIR
|
||||
|
||||
Reference in New Issue
Block a user