Fix calls to functions with const T&& parameters. (#7208)

This also fixes passing a value expression to a forwarding reference,
since we currently deduce a `const T&&` parameter in that case.

We were accidentally looking at the type of the thunk parameter (which
is never an rvalue reference) rather than the type of the callee
parameter.
This commit is contained in:
Richard Smith authored and GitHub committed 2026-05-14 20:22:32 +00:00
1 parent 8e371c380a
commit dd47e41da6
2 files changed
+391 -1

No files matched your search

+1 -1
View File
@@ -497,7 +497,7 @@ static auto BuildThunkParamRef(
// Cast to an xvalue when using pass-by-`var` or when initializing an rvalue
// reference (which might be passed by value if it's const-qualified).
if (passing_mode == SemIR::ClangDeclSignature::PassingMode::ByVar ||
thunk_param->getType()->isRValueReferenceType()) {
(!type.isNull() && type->isRValueReferenceType())) {
call_arg = clang::ImplicitCastExpr::Create(
sema.getASTContext(), call_arg->getType(), clang::CK_NoOp, call_arg,
nullptr, clang::ExprValueKind::VK_XValue, clang::FPOptionsOverride());