================
@@ -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:

what happens if value comes before &

https://github.com/llvm/llvm-project/pull/160150
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to