Skip to content

Commit ce6bf91

Browse files
authored
Avoid extra work when thunk_required is already true in IsCppThunkRequired() (#6150)
Also set `thunk_required` in a more consistent way, to avoid bugs like the one fixed in #6152. Part #6148.
1 parent 0c761a9 commit ce6bf91

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

toolchain/check/cpp/thunk.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ auto IsCppThunkRequired(Context& context, const SemIR::Function& function)
110110
for (auto* param : decl->parameters()) {
111111
if (param->getType()->isReferenceType()) {
112112
thunk_required = true;
113+
break;
113114
}
114115
}
115116
}
@@ -129,12 +130,10 @@ auto IsCppThunkRequired(Context& context, const SemIR::Function& function)
129130
if (param_id == SemIR::ErrorInst::InstId) {
130131
return false;
131132
}
132-
if (!thunk_required &&
133+
thunk_required =
134+
thunk_required ||
133135
IsThunkRequiredForType(
134-
context,
135-
context.insts().GetAs<SemIR::AnyParam>(param_id).type_id)) {
136-
thunk_required = true;
137-
}
136+
context, context.insts().GetAs<SemIR::AnyParam>(param_id).type_id);
138137
}
139138

140139
return thunk_required;

0 commit comments

Comments
 (0)