mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-20 20:56:47 +00:00
Replace GetCurrentReturnSlot with GetReturnedVarParam (#6571)
Not all functions have a return slot, and once we have composite forms, functions will be able to have any number of return slots. Obtaining a unique return slot for a function only makes sense in `returned var` handling.
This commit is contained in:
1 parent
3c70a9f59b
commit
6985ecb1d4
219 files changed
+1097
-1089
No files matched your search
@@ -103,16 +103,15 @@ auto AddBindingPattern(Context& context, SemIR::LocId name_loc,
|
||||
}
|
||||
|
||||
// Returns a VarStorage inst for the given `var` pattern. If the pattern
|
||||
// is the body of a returned var, this reuses the return slot, and otherwise it
|
||||
// adds a new inst.
|
||||
// is the body of a returned var, this reuses the return parameter, and
|
||||
// otherwise it adds a new inst.
|
||||
static auto GetOrAddVarStorage(Context& context, SemIR::InstId var_pattern_id,
|
||||
bool is_returned_var) -> SemIR::InstId {
|
||||
if (is_returned_var) {
|
||||
auto& function = GetCurrentFunctionForReturn(context);
|
||||
auto return_info =
|
||||
SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(), function);
|
||||
if (return_info.has_return_slot()) {
|
||||
return GetCurrentReturnSlot(context);
|
||||
if (auto return_param_id =
|
||||
GetReturnedVarParam(context, GetCurrentFunctionForReturn(context));
|
||||
return_param_id.has_value()) {
|
||||
return return_param_id;
|
||||
}
|
||||
}
|
||||
auto pattern = context.insts().GetWithLocId(var_pattern_id);
|
||||
|
||||
Reference in new issue
Block a user