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

JJ Marr via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 25 06:57:57 PDT 2025


================
@@ -0,0 +1,43 @@
+.. title:: clang-tidy - readability-default-lambda-capture
+
+readability-default-lambda-capture
+==================================
+
+Warns on default lambda captures (e.g. ``[&](){ ... }``, ``[=](){ ... }``)
+  
+Default captures can lead to subtle bugs including dangling references with
+``[&]``, unnecessary copies with ``[=]``, and make code less maintainable by
+hiding which variables are actually being captured.
+
+Implements Item 31 of Effective Modern C++ by Scott Meyers.
----------------
jjmarr-amd wrote:

This should also reference AUTOSAR C++14 Rule A5-1-2, which has publicly accessible documentation.

https://www.mathworks.com/help//releases/R2021a/bugfinder/ref/autosarc14rulea512.html

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


More information about the cfe-commits mailing list