-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang] Fix constant evaluating a captured variable in a lambda #68090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8366,8 +8366,14 @@ bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) { | |||||||||||
return false; | ||||||||||||
|
||||||||||||
if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) { | ||||||||||||
auto *MD = cast<CXXMethodDecl>(Info.CurrentCall->Callee); | ||||||||||||
// Start with 'Result' referring to the complete closure object... | ||||||||||||
Result = *Info.CurrentCall->This; | ||||||||||||
if (MD->isExplicitObjectMemberFunction()) { | ||||||||||||
APValue *RefValue = | ||||||||||||
Info.getParamSlot(Info.CurrentCall->Arguments, MD->getParamDecl(0)); | ||||||||||||
Result.setFrom(Info.Ctx, *RefValue); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So what is the difference between calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LValue has no assignment operator from APValue (because sometimes you need an ASTContext) |
||||||||||||
} else | ||||||||||||
Result = *Info.CurrentCall->This; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather not pretend that there is a
Comment on lines
+8375
to
+8376
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think LLVM code style suggests curleys in case other branch had them
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will fix, thanks! |
||||||||||||
// ... then update it to refer to the field of the closure object | ||||||||||||
// that represents the capture. | ||||||||||||
if (!HandleLValueMember(Info, E, Result, FD)) | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that work?