mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 10:54:49 +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:
@@ -194,7 +194,7 @@ auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/,
|
||||
auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/,
|
||||
SemIR::ReturnExpr inst) -> void {
|
||||
auto result_type_id = context.sem_ir().insts().Get(inst.expr_id).type_id();
|
||||
switch (SemIR::GetInitRepr(context.sem_ir(), result_type_id).kind) {
|
||||
switch (SemIR::InitRepr::ForType(context.sem_ir(), result_type_id).kind) {
|
||||
case SemIR::InitRepr::None:
|
||||
// Nothing to return.
|
||||
context.builder().CreateRetVoid();
|
||||
@@ -207,6 +207,9 @@ auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/,
|
||||
// The expression produces the value representation for the type.
|
||||
context.builder().CreateRet(context.GetValue(inst.expr_id));
|
||||
return;
|
||||
case SemIR::InitRepr::Incomplete:
|
||||
CARBON_FATAL() << "Lowering return of incomplete type "
|
||||
<< context.sem_ir().types().GetAsInst(result_type_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user