Skip to content

Commit fd3eb13

Browse files
authored
Use llvm::zip() to iterate over callee_function_params, thunk_function_params and callee_arg_ids (#5940)
1 parent e0de9dd commit fd3eb13

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

toolchain/check/cpp_thunk.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,18 +328,16 @@ auto PerformCppThunkCall(Context& context, SemIR::LocId loc_id,
328328
CARBON_CHECK(thunk_function_params.size() == num_params);
329329
CARBON_CHECK(callee_arg_ids.size() == num_params);
330330
llvm::SmallVector<SemIR::InstId> thunk_arg_ids;
331-
thunk_arg_ids.reserve(callee_arg_ids.size());
332-
for (size_t i = 0; i < callee_function_params.size(); ++i) {
331+
thunk_arg_ids.reserve(num_params);
332+
for (auto [callee_param_inst_id, thunk_param_inst_id, callee_arg_id] :
333+
llvm::zip(callee_function_params, thunk_function_params,
334+
callee_arg_ids)) {
333335
SemIR::TypeId callee_param_type_id =
334-
context.insts()
335-
.GetAs<SemIR::AnyParam>(callee_function_params[i])
336-
.type_id;
336+
context.insts().GetAs<SemIR::AnyParam>(callee_param_inst_id).type_id;
337337
SemIR::TypeId thunk_param_type_id =
338-
context.insts()
339-
.GetAs<SemIR::AnyParam>(thunk_function_params[i])
340-
.type_id;
338+
context.insts().GetAs<SemIR::AnyParam>(thunk_param_inst_id).type_id;
341339

342-
SemIR::InstId arg_id = callee_arg_ids[i];
340+
SemIR::InstId arg_id = callee_arg_id;
343341
if (callee_param_type_id != thunk_param_type_id) {
344342
CARBON_CHECK(thunk_param_type_id ==
345343
GetPointerType(context, context.types().GetInstId(

0 commit comments

Comments
 (0)