================
@@ -0,0 +1,98 @@
+// RUN: %check_clang_tidy %s readability-avoid-default-lambda-capture %t
+
+void test_default_captures() {
+ int value = 42;
+ int another = 10;
+
+ auto lambda1 = [=](int x) { return value + x; };
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are
discouraged; prefer to capture specific variables explicitly
[readability-avoid-default-lambda-capture]
+
+ auto lambda2 = [&](int x) { return value + x; };
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are
discouraged; prefer to capture specific variables explicitly
[readability-avoid-default-lambda-capture]
+
+ auto lambda3 = [=, &another](int x) { return value + another + x; };
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are
discouraged; prefer to capture specific variables explicitly
[readability-avoid-default-lambda-capture]
+
+ auto lambda4 = [&, value](int x) { return value + another + x; };
----------------
jjmarr-amd wrote:
turns out what happens is a compilation error.
https://github.com/llvm/llvm-project/pull/160150
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits