Rework handling of C++ references. (#6268)

For now, map C++ reference types to const-qualified Carbon pointer types
rather than picking between a (non-const) pointer or a value type. This
fixes misbehavior in lowering for reference members in classes and
reference return types.

Update the special-case handling for references as function parameters
so that it continues to map const reference parameters to Carbon
pass-by-value, and unify the code paths for `self` parameters and other
parameters, which were mostly doing the same thing but had some subtle
differences.

Add references to the list of types that we can pass to and from C++
directly, without needing an additional layer of thunks.
This commit is contained in:
Richard Smith
2025-10-28 00:33:26 +00:00
committed by GitHub
parent 33166ffc7a
commit 6011040481
17 changed files with 845 additions and 437 deletions
-11
View File
@@ -157,15 +157,4 @@ auto AddSelfParamPattern(Context& context, SemIR::LocId loc_id,
return pattern_id;
}
auto AddAddrSelfParamPattern(Context& context, SemIR::LocId loc_id,
SemIR::ExprRegionId type_expr_region_id,
SemIR::TypeInstId type_inst_id) -> SemIR::InstId {
auto pattern_id = AddSelfParamPattern(context, loc_id, type_expr_region_id,
GetPointerType(context, type_inst_id));
return AddPatternInst<SemIR::AddrPattern>(
context, loc_id,
{.type_id = GetPatternType(context, SemIR::AutoType::TypeId),
.inner_id = pattern_id});
}
} // namespace Carbon::Check