[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)
Nick Desaulniers via cfe-commits
cfe-commits at lists.llvm.org
Wed May 22 11:22:56 PDT 2024
================
@@ -4693,6 +4694,17 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field,
else
LambdaLV = MakeAddrLValue(AddrOfExplicitObject,
D->getType().getNonReferenceType());
+
+ // Make sure we have an lvalue to the lambda itself and not a derived class.
+ auto *ThisTy = D->getType().getNonReferenceType()->getAsCXXRecordDecl();
+ auto *LambdaTy = cast<CXXRecordDecl>(Field->getParent());
+ if (ThisTy != LambdaTy) {
+ const CXXCastPath &BasePathArray = getContext().LambdaCastPaths.at(MD);
+ Address Base = GetAddressOfBaseClass(
+ LambdaLV.getAddress(*this), ThisTy, BasePathArray.begin(),
+ BasePathArray.end(), /*NullCheckValue=*/false, SourceLocation());
----------------
nickdesaulniers wrote:
error: too many arguments to function call, expected 0, have 1
LambdaLV.getAddress(*this), ThisTy, BasePathArray.begin(),
~~~~~~~~~~~~~~~~~~~ ^~~~~
https://lab.llvm.org/buildbot/#/builders/225/builds/36615/steps/6/logs/stdio
https://github.com/llvm/llvm-project/pull/89828
More information about the cfe-commits
mailing list