[llvm] [clang] [clang-tools-extra] [clang] reject to capture variable in `RequiresExprBodyDecl` (PR #78598)

via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 4 01:31:11 PST 2024


cor3ntin wrote:

> > Thanks for the patch!
> > Requires Expressions should be in an unevaluated context, so we should never try to capture variables they mentioned.
> > Maybe we need to test the evaluation context in either `tryCaptureVariable` or `NeedToCaptureVariable`, rather than a specific handling for requires expressions
> > https://eel.is/c++draft/expr.prim.lambda.capture#7.sentence-2
> > WDYT?
> > @erichkeane
> 
> We will use `tryCaptureVariable` to diagnose `-Wunused-lambda-capture`. So simply ignoring them in an unevaluated context is not a good idea. I have changed the PR to match this function work even for `RequiresExprBodyDecl`.

You have an example of that? There may be further bugs there.
id-expression that appear in any unevaluated context should not be captured ( typeid being an exception
https://eel.is/c++draft/expr.prim.lambda.capture#7.sentence-2 )

https://github.com/llvm/llvm-project/pull/78598


More information about the cfe-commits mailing list