@@ -63,12 +63,12 @@ static auto CopyValueToTemporary(Context& context, SemIR::InstId init_id)
63
63
// TODO: Consider using `None` to mean that we immediately materialize and
64
64
// initialize a temporary, rather than two separate instructions.
65
65
auto init = context.sem_ir ().insts ().Get (init_id);
66
- auto temporary_id = AddInstWithCleanup <SemIR::TemporaryStorage>(
66
+ auto temporary_id = AddInst <SemIR::TemporaryStorage>(
67
67
context, SemIR::LocId (init_id), {.type_id = init.type_id ()});
68
- return AddInst <SemIR::Temporary>(context, SemIR::LocId (init_id),
69
- {.type_id = init.type_id (),
70
- .storage_id = temporary_id,
71
- .init_id = init_id});
68
+ return AddInstWithCleanup <SemIR::Temporary>(context, SemIR::LocId (init_id),
69
+ {.type_id = init.type_id (),
70
+ .storage_id = temporary_id,
71
+ .init_id = init_id});
72
72
}
73
73
74
74
// Commits to using a temporary to store the result of the initializing
@@ -88,10 +88,11 @@ static auto FinalizeTemporary(Context& context, SemIR::InstId init_id,
88
88
" initialized multiple times? Have {0}" ,
89
89
sem_ir.insts ().Get (return_slot_arg_id));
90
90
auto init = sem_ir.insts ().Get (init_id);
91
- return AddInst<SemIR::Temporary>(context, SemIR::LocId (init_id),
92
- {.type_id = init.type_id (),
93
- .storage_id = return_slot_arg_id,
94
- .init_id = init_id});
91
+ return AddInstWithCleanup<SemIR::Temporary>(
92
+ context, SemIR::LocId (init_id),
93
+ {.type_id = init.type_id (),
94
+ .storage_id = return_slot_arg_id,
95
+ .init_id = init_id});
95
96
}
96
97
97
98
if (discarded) {
@@ -261,9 +262,8 @@ static auto ConvertTupleToArray(Context& context, SemIR::TupleType tuple_type,
261
262
// destination for the array initialization if we weren't given one.
262
263
SemIR::InstId return_slot_arg_id = target.init_id ;
263
264
if (!target.init_id .has_value ()) {
264
- return_slot_arg_id =
265
- target_block->AddInstWithCleanup <SemIR::TemporaryStorage>(
266
- value_loc_id, {.type_id = target.type_id });
265
+ return_slot_arg_id = target_block->AddInst <SemIR::TemporaryStorage>(
266
+ value_loc_id, {.type_id = target.type_id });
267
267
}
268
268
269
269
// Initialize each element of the array from the corresponding element of the
@@ -607,7 +607,7 @@ static auto ConvertStructToClass(Context& context, SemIR::StructType src_type,
607
607
if (need_temporary) {
608
608
target.kind = ConversionTarget::Initializer;
609
609
target.init_block = &target_block;
610
- target.init_id = target_block.AddInstWithCleanup <SemIR::TemporaryStorage>(
610
+ target.init_id = target_block.AddInst <SemIR::TemporaryStorage>(
611
611
SemIR::LocId (value_id), {.type_id = target.type_id });
612
612
}
613
613
@@ -617,10 +617,11 @@ static auto ConvertStructToClass(Context& context, SemIR::StructType src_type,
617
617
618
618
if (need_temporary) {
619
619
target_block.InsertHere ();
620
- result_id = AddInst<SemIR::Temporary>(context, SemIR::LocId (value_id),
621
- {.type_id = target.type_id ,
622
- .storage_id = target.init_id ,
623
- .init_id = result_id});
620
+ result_id =
621
+ AddInstWithCleanup<SemIR::Temporary>(context, SemIR::LocId (value_id),
622
+ {.type_id = target.type_id ,
623
+ .storage_id = target.init_id ,
624
+ .init_id = result_id});
624
625
}
625
626
return result_id;
626
627
}
0 commit comments