-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[Clang] Only remove lambda scope after computing evaluation context #154106
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 all commits
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 | ||||
---|---|---|---|---|---|---|
|
@@ -1968,14 +1968,15 @@ ExprResult Sema::BuildCaptureInit(const Capture &Cap, | |||||
} | ||||||
|
||||||
ExprResult Sema::ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body) { | ||||||
LambdaScopeInfo LSI = *cast<LambdaScopeInfo>(FunctionScopes.back()); | ||||||
LambdaScopeInfo &LSI = *cast<LambdaScopeInfo>(FunctionScopes.back()); | ||||||
|
||||||
if (LSI.CallOperator->hasAttr<SYCLKernelEntryPointAttr>()) | ||||||
SYCL().CheckSYCLEntryPointFunctionDecl(LSI.CallOperator); | ||||||
|
||||||
ActOnFinishFunctionBody(LSI.CallOperator, Body); | ||||||
ActOnFinishFunctionBody(LSI.CallOperator, Body, /*IsInstantiation=*/false, | ||||||
/*RetainFunctionScopeInfo=*/true); | ||||||
|
||||||
return BuildLambdaExpr(StartLoc, Body->getEndLoc(), &LSI); | ||||||
return BuildLambdaExpr(StartLoc, Body->getEndLoc()); | ||||||
} | ||||||
|
||||||
static LambdaCaptureDefault | ||||||
|
@@ -2132,8 +2133,9 @@ ConstructFixItRangeForUnusedCapture(Sema &S, SourceRange CaptureRange, | |||||
return SourceRange(FixItStart, FixItEnd); | ||||||
} | ||||||
|
||||||
ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, | ||||||
LambdaScopeInfo *LSI) { | ||||||
ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, | ||||||
SourceLocation EndLoc) { | ||||||
LambdaScopeInfo *LSI = cast<LambdaScopeInfo>(FunctionScopes.back()); | ||||||
// Collect information from the lambda scope. | ||||||
SmallVector<LambdaCapture, 4> Captures; | ||||||
SmallVector<Expr *, 4> CaptureInits; | ||||||
|
@@ -2170,6 +2172,12 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, | |||||
|
||||||
PopExpressionEvaluationContext(); | ||||||
|
||||||
sema::AnalysisBasedWarnings::Policy WP = | ||||||
AnalysisWarnings.getPolicyInEffectAt(EndLoc); | ||||||
// We cannot release LSI until we finish computing captures, which | ||||||
// requires the scope to be popped. | ||||||
PoppedFunctionScopePtr _ = PopFunctionScopeInfo(&WP, LSI->CallOperator); | ||||||
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. This is causing a use-after-free that CI is hitting: because llvm-project/clang/lib/Sema/SemaLambda.cpp Line 2315 in 5cc8c92
llvm-project/clang/lib/Sema/SemaLambda.cpp Line 2347 in 5cc8c92
Perhaps we should revert the changes until that's fixed? 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. Thanks, I reverted in #154382 :( |
||||||
|
||||||
// True if the current capture has a used capture or default before it. | ||||||
bool CurHasPreviousCapture = CaptureDefault != LCD_None; | ||||||
SourceLocation PrevCaptureLoc = CurHasPreviousCapture ? | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.