[clang-tools-extra] [clang-tidy] Add `AllowExplicitObjectParameters` option to `avoid-capturing-lambda-coroutines` (PR #182916)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 27 07:06:58 PDT 2026


================
@@ -52,3 +52,35 @@ captures or ensuring the lambda closure object has a guaranteed lifetime.
 
 Following these guidelines can help ensure the safe and reliable use of
 coroutine lambdas in C++ code.
+
+Options
+-------
+
+.. option:: AllowExplicitObjectParameters
+
+   When set to `true`, lambda coroutines that use C++23 "deducing this"
+   (explicit object parameter, e.g. ``this auto``) are not flagged by this
+   check, because the captures are moved into the coroutine frame, decoupling
+   their lifetime from the lambda object. Additionally, when compiling in C++23
+   mode or later, the check will provide fix-it hints to add ``this auto`` as
+   the first parameter to lambda coroutines that do not already use it.
----------------
vbvictor wrote:

I think providing fixits should go into another option. It's not always right to force usage of `this auto`, another way to mitigate the warning is still to remove the capture, right?



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


More information about the cfe-commits mailing list