Remove return_type_id from Function. (#4051)

Instead of redundantly storing both the `return_type_id` and
`return_storage_id`, where the declared return type is just the type of
the return storage, store only the `return_storage_id`.

Add a convenience property to get the declared return type of the
function.

In addition to avoiding storing redundant information, this is a
preparatory step for an upcoming change for generics support that will
make it more expensive and awkward to store `TypeId`s in places other
than the type of an instruction.
This commit is contained in:
Richard Smith
2024-06-13 22:01:21 +00:00
committed by GitHub
parent d18584c6c2
commit e3c15edb92
12 changed files with 68 additions and 59 deletions
+7
View File
@@ -38,4 +38,11 @@ auto GetCalleeFunction(const File& sem_ir, InstId callee_id) -> CalleeFunction {
return result;
}
auto Function::declared_return_type(const File& file) const -> TypeId {
if (!return_storage_id.is_valid()) {
return TypeId::Invalid;
}
return file.insts().Get(return_storage_id).type_id();
}
} // namespace Carbon::SemIR