[PATCH] D146535: [Clang] Fix evaluation of parameters of lambda call operator attributes

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 21 09:08:35 PDT 2023


cor3ntin added a comment.

Whether the assertion itself in `getCurLambda` is still pertinent, 
despite no test depending on it does require more analysis.

This comment in SemaExprCXX.cpp dissuaded to try to do more surgery as part of this fix, and in some way, that assertion firing helped us discover the bug this PR fixes, so it was useful

  // FIXME: PR 17877 showed that getCurLambda() can return a valid pointer
  // even if CurContext is not a lambda call operator. Refer to that Bug Report
  // for an example of the code that might cause this asynchrony.
  // By ensuring we are in the context of a lambda's call operator
  // we can fix the bug (we only need to check whether we need to capture
  // if we are within a lambda's body); but per the comments in that
  // PR, a proper fix would entail :
  //   "Alternative suggestion:
  //   - Add to Sema an integer holding the smallest (outermost) scope
  //     index that we are *lexically* within, and save/restore/set to
  //     FunctionScopes.size() in InstantiatingTemplate's
  //     constructor/destructor.
  //  - Teach the handful of places that iterate over FunctionScopes to
  //    stop at the outermost enclosing lexical scope."


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146535/new/

https://reviews.llvm.org/D146535



More information about the cfe-commits mailing list