mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 11:11:05 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user