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