ExprCategory for guaranteed-in-place initializing expressions (#6623)

The primary change in this PR is to split the `Initializing` expression
category into separate `ReprInitializing` and `InPlaceInitializing`
categories, depending on whether initialization uses the types
initializing representation, or is guaranteed to be in place. It also
rationalizes and documents the SemIR-level semantics of those categories
(including where #5545's "ephemeral entire reference" category will
fit), and introduces two new inst kinds to close gaps exposed in the
process.

Some additional secondary changes:
- Consistently format the storage arguments of initializers with `to`,
regardless of whether initialization is in-place, and document the `to`
notation.
- Rename some inst kinds and functions, and restructure some of the
code, for clarity and consistency with the new documentation.
- Resolve a TODO to handle more category conversions in
`CategoryConverter`, in order to make it easier to reason about category
conversions.

See #6588 and the review history of this PR for background.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Geoff Romer
2026-02-04 02:27:12 +00:00
committed by GitHub
co-authored by Richard Smith
parent 2980e6bcbb
commit e5b05a1fac
127 changed files with 1352 additions and 926 deletions
+4 -4
View File
@@ -731,10 +731,10 @@ auto PerformCppThunkCall(Context& context, SemIR::LocId loc_id,
// Produce the result of the call, taking the value from the return storage.
if (thunk_takes_return_address) {
result_id = AddInst<SemIR::InPlaceInit>(context, loc_id,
{.type_id = return_type_id,
.src_id = result_id,
.dest_id = return_slot_id});
result_id = AddInst<SemIR::MarkInPlaceInit>(context, loc_id,
{.type_id = return_type_id,
.src_id = result_id,
.dest_id = return_slot_id});
}
return result_id;