mrcvtl wrote: I’ve taken some time to better understand the code and think through the solution.
I tried using `isInLifetimeExtendingContext()`, but it still returns false, and I believe I now understand why. In your PR, the flag is set here: https://github.com/llvm/llvm-project/blob/b581f9d056babadf55098b9d5d100271621b90db/clang/lib/Parse/ParseDecl.cpp#L2314-L2318 However, the warning is actually triggered starting from this location: https://github.com/llvm/llvm-project/blob/b581f9d056babadf55098b9d5d100271621b90db/clang/lib/Parse/ParseDecl.cpp#L2266 An alternative approach to apply your logic and set again the flag in here: https://github.com/llvm/llvm-project/blob/43d042b350af8ee8c7401d6b102df68d6c176b5a/clang/lib/Parse/ParseStmt.cpp#L2174-L2179 Maybe we could act on `ForRangeInfo.LifetimeExtendTemps.back()`, or even directly on `Actions.currentEvaluationContext();`. If that works, we might be able to rely solely on `isInLifetimeExtendingContext()` and remove the need for `isRangeBasedForLoopVariable` altogether. What do you think? I'm absolutely open to every approach (the cleaner, the better!). https://github.com/llvm/llvm-project/pull/145164 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits