mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 21:35:01 +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:
@@ -133,7 +133,7 @@ auto FunctionContext::MakeSyntheticBlock() -> llvm::BasicBlock* {
|
||||
|
||||
auto FunctionContext::FinishInit(SemIR::TypeId type_id, SemIR::InstId dest_id,
|
||||
SemIR::InstId source_id) -> void {
|
||||
switch (SemIR::GetInitRepr(sem_ir(), type_id).kind) {
|
||||
switch (SemIR::InitRepr::ForType(sem_ir(), type_id).kind) {
|
||||
case SemIR::InitRepr::None:
|
||||
break;
|
||||
case SemIR::InitRepr::InPlace:
|
||||
@@ -146,12 +146,15 @@ auto FunctionContext::FinishInit(SemIR::TypeId type_id, SemIR::InstId dest_id,
|
||||
case SemIR::InitRepr::ByCopy:
|
||||
CopyValue(type_id, source_id, dest_id);
|
||||
break;
|
||||
case SemIR::InitRepr::Incomplete:
|
||||
CARBON_FATAL() << "Lowering aggregate initialization of incomplete type "
|
||||
<< sem_ir().types().GetAsInst(type_id);
|
||||
}
|
||||
}
|
||||
|
||||
auto FunctionContext::CopyValue(SemIR::TypeId type_id, SemIR::InstId source_id,
|
||||
SemIR::InstId dest_id) -> void {
|
||||
switch (auto rep = SemIR::GetValueRepr(sem_ir(), type_id); rep.kind) {
|
||||
switch (auto rep = SemIR::ValueRepr::ForType(sem_ir(), type_id); rep.kind) {
|
||||
case SemIR::ValueRepr::Unknown:
|
||||
CARBON_FATAL() << "Attempt to copy incomplete type";
|
||||
case SemIR::ValueRepr::None:
|
||||
|
||||
Reference in New Issue
Block a user