-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ClangImporter] Fix dangling reference. #82708
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
Conversation
LookupOverloadedBinOp stores `Args` for later use, so store the backing array on the stack instead of using a temporary. This fixes a crash that appeared under some build configurations. Related to rdar://154291418
@swift-ci please test |
@swift-ci please test Windows |
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.
LGTM, thank you!
@@ -265,7 +265,8 @@ instantiateTemplatedOperator(ClangImporter::Implementation &impl, | |||
classDecl->getLocation(), clang::OverloadCandidateSet::CSK_Operator, | |||
clang::OverloadCandidateSet::OperatorRewriteInfo(opKind, | |||
clang::SourceLocation(), false)); | |||
clangSema.LookupOverloadedBinOp(candidateSet, opKind, ops, {arg, arg}, true); | |||
std::array<clang::Expr *, 2> args{arg, arg}; | |||
clangSema.LookupOverloadedBinOp(candidateSet, opKind, ops, args, true); |
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.
Could you elaborate on where this array gets stored and for how long? Are we storing the array in the candidateSet
?
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.
Yes, it's stored in candidateSet
so the lifetime needs to extend to the last use of candidateSet
, excluding the destructor.
@swift-ci please test windows |
@swift-ci please test Windows platform |
@swift-ci please test Windows |
LookupOverloadedBinOp
storesArgs
for later use, so store the backing array on the stack instead of using a temporary.This fixes a crash that appears under some build configurations.
Related to rdar://154291418