diff --git a/toolchain/check/cpp_thunk.cpp b/toolchain/check/cpp_thunk.cpp index fbc94b154133..70b0497fe884 100644 --- a/toolchain/check/cpp_thunk.cpp +++ b/toolchain/check/cpp_thunk.cpp @@ -328,18 +328,16 @@ auto PerformCppThunkCall(Context& context, SemIR::LocId loc_id, CARBON_CHECK(thunk_function_params.size() == num_params); CARBON_CHECK(callee_arg_ids.size() == num_params); llvm::SmallVector thunk_arg_ids; - thunk_arg_ids.reserve(callee_arg_ids.size()); - for (size_t i = 0; i < callee_function_params.size(); ++i) { + thunk_arg_ids.reserve(num_params); + for (auto [callee_param_inst_id, thunk_param_inst_id, callee_arg_id] : + llvm::zip(callee_function_params, thunk_function_params, + callee_arg_ids)) { SemIR::TypeId callee_param_type_id = - context.insts() - .GetAs(callee_function_params[i]) - .type_id; + context.insts().GetAs(callee_param_inst_id).type_id; SemIR::TypeId thunk_param_type_id = - context.insts() - .GetAs(thunk_function_params[i]) - .type_id; + context.insts().GetAs(thunk_param_inst_id).type_id; - SemIR::InstId arg_id = callee_arg_ids[i]; + SemIR::InstId arg_id = callee_arg_id; if (callee_param_type_id != thunk_param_type_id) { CARBON_CHECK(thunk_param_type_id == GetPointerType(context, context.types().GetInstId(