Refactor ReturnTypeInfo and InitRepr. (#4169)

Rename `ReturnInfo` to `ReturnTypeInfo`. Move it and `InitRepr` into
`type_info.h` alongside `ValueRepr`. Replace `ReturnSlot` with
`InitRepr`, and extend `InitRepr` to be able to represent the
incomplete-type case instead of CHECK-failing. Remove `has_return_slot`
from `InitRepr` and instead only provide that as part of
`ReturnTypeInfo`.
This commit is contained in:
Richard Smith
2024-07-25 21:41:33 +00:00
committed by GitHub
parent 2ef1d1f8b9
commit 37a8bfa488
19 changed files with 194 additions and 194 deletions
-16
View File
@@ -68,20 +68,4 @@ auto Function::GetDeclaredReturnType(const File& file,
file.insts().Get(return_storage_id).type_id());
}
auto ReturnInfo::ForType(const File& file, TypeId type_id) -> ReturnInfo {
if (!type_id.is_valid()) {
// Implicit `-> ()` has no return slot.
return {.type_id = type_id, .return_slot = ReturnSlot::Absent};
}
if (!file.types().IsComplete(type_id)) {
return {.type_id = type_id, .return_slot = ReturnSlot::Incomplete};
}
return {.type_id = type_id,
.return_slot = GetInitRepr(file, type_id).has_return_slot()
? SemIR::ReturnSlot::Present
: SemIR::ReturnSlot::Absent};
}
} // namespace Carbon::SemIR