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

via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 10 09:38:49 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- clang-tools-extra/clang-tidy/readability/AvoidDefaultLambdaCaptureCheck.cpp clang-tools-extra/clang-tidy/readability/AvoidDefaultLambdaCaptureCheck.h clang-tools-extra/test/clang-tidy/checkers/readability/avoid-default-lambda-capture.cpp clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp clang/include/clang/ASTMatchers/ASTMatchers.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/readability/AvoidDefaultLambdaCaptureCheck.cpp b/clang-tools-extra/clang-tidy/readability/AvoidDefaultLambdaCaptureCheck.cpp
index 1a0af36ce..ce96edf47 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidDefaultLambdaCaptureCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/AvoidDefaultLambdaCaptureCheck.cpp
@@ -41,12 +41,11 @@ void AvoidDefaultLambdaCaptureCheck::storeOptions(
 
 void AvoidDefaultLambdaCaptureCheck::registerMatchers(MatchFinder *Finder) {
   if (IgnoreImplicitCapturesInSTL) {
-    Finder->addMatcher(
-        lambdaExpr(hasDefaultCapture(),
-                   unless(hasAncestor(
-                       callExpr(callee(functionDecl(isInStdNamespace()))))))
-            .bind("lambda"),
-        this);
+    Finder->addMatcher(lambdaExpr(hasDefaultCapture(),
+                                  unless(hasAncestor(callExpr(callee(
+                                      functionDecl(isInStdNamespace()))))))
+                           .bind("lambda"),
+                       this);
   } else {
     Finder->addMatcher(lambdaExpr(hasDefaultCapture()).bind("lambda"), this);
   }

``````````

</details>


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


More information about the cfe-commits mailing list