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
+6 -4
View File
@@ -73,12 +73,13 @@ auto CheckFunctionTypeMatches(Context& context,
auto CheckFunctionReturnType(Context& context, SemIRLoc loc,
SemIR::Function& function,
SemIR::SpecificId specific_id)
-> SemIR::ReturnInfo {
auto return_info = function.GetReturnInfo(context.sem_ir(), specific_id);
-> SemIR::ReturnTypeInfo {
auto return_info = SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(),
function, specific_id);
// If we couldn't determine the return information due to the return type
// being incomplete, try to complete it now.
if (return_info.return_slot == SemIR::ReturnSlot::Incomplete) {
if (return_info.init_repr.kind == SemIR::InitRepr::Incomplete) {
auto diagnose_incomplete_return_type = [&] {
CARBON_DIAGNOSTIC(IncompleteTypeInFunctionReturnType, Error,
"Function returns incomplete type `{0}`.",
@@ -91,7 +92,8 @@ auto CheckFunctionReturnType(Context& context, SemIRLoc loc,
// definition or call to this function.
if (context.TryToCompleteType(return_info.type_id,
diagnose_incomplete_return_type)) {
return_info = function.GetReturnInfo(context.sem_ir(), specific_id);
return_info = SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(),
function, specific_id);
}
}