Fix thunk generation for &&-qualified methods. (#6881)

Use the object parameter type when creating a reference to the thunk
parameter so that we create an xvalue rather than an lvalue for the
`*this` expression in the thunk.
This commit is contained in:
Richard Smith
2026-03-11 20:34:18 +00:00
committed by GitHub
parent 2e5b195813
commit 0a4fd2cb7e
2 changed files with 57 additions and 53 deletions
+4 -4
View File
@@ -500,11 +500,11 @@ static auto BuildThunkBody(clang::Sema& sema,
// the callee. Otherwise, build a regular reference to the function.
clang::ExprResult callee;
if (callee_info.has_object_parameter) {
clang::QualType object_param_type =
cast<clang::CXXMethodDecl>(callee_info.decl)
->getFunctionObjectParameterReferenceType();
auto* object_param_ref =
BuildThunkParamRef(sema, thunk_function_decl, 0,
callee_info.has_explicit_object_parameter()
? callee_info.decl->getParamDecl(0)->getType()
: clang::QualType());
BuildThunkParamRef(sema, thunk_function_decl, 0, object_param_type);
constexpr bool IsArrow = false;
auto object =
sema.PerformMemberExprBaseConversion(object_param_ref, IsArrow);