[clang] [Clang] Only remove lambda scope after computing evaluation context (PR #154106)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 18 06:42:15 PDT 2025
================
@@ -2134,6 +2135,11 @@ ConstructFixItRangeForUnusedCapture(Sema &S, SourceRange CaptureRange,
ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
LambdaScopeInfo *LSI) {
+ // Copy the LSI before PopFunctionScopeInfo removes it.
+ // FIXME: This is dumb. Store the lambda information somewhere that outlives
+ // the call operator.
+ LambdaScopeInfo LSICopy = *LSI;
+ LSI = &LSICopy;
----------------
erichkeane wrote:
This seems awful strange. I don't think this is 'the way', and since it changes the address of `LSI`, doesn't it cause any other links of it to break? That doesn't seem right.
I DO find myself wondering whether we need to spend some effort just managing the `LambdaScopeInfo` in 1 place (push, do thing, pop) instead? Also-also, other than making this variable, we aren't actually referencing LSICopy again? What is going on?
https://github.com/llvm/llvm-project/pull/154106
More information about the cfe-commits
mailing list