[clang] [clang-tools-extra] [clang-tidy] Add readability-avoid-default-lambda-capture (PR #160150)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 15 13:30:24 PDT 2025


================
@@ -0,0 +1,179 @@
+// RUN: %check_clang_tidy %s readability-avoid-default-lambda-capture %t -- -- -Wno-vla-extension -std=c++20
----------------
localspook wrote:

This is a problem that comes up a lot of checks. There are broadly two ways you can handle it:
1. Split the C++20 tests into a different file (`avoid-default-lambda-capture-cxx20.cpp`) and at the top put:
   ```cpp
   // RUN: %check_clang_tidy -std=c++20-or-later %s readability-avoid-default-lambda-capture %t -- -- -Wno-vla-extension
   ```
2. Keep the tests in one file and at the top put:
   ```cpp
   // RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s readability-avoid-default-lambda-capture %t -- -- -Wno-vla-extension
   // RUN: %check_clang_tidy -std=c++20-or-later -check-suffixes=,20 %s readability-avoid-default-lambda-capture %t -- -- -Wno-vla-extension
   ```
   Then guard the uses of C++20 features with `#if __cplusplus >= 202002L`, and change the adjacent  `// CHECK-NOTES` and `// CHECK-FIXES`  to `// CHECK-NOTES-20` and `// CHECK-FIXES-20`.

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


More information about the cfe-commits mailing list