1
- // RUN: %check_clang_tidy %s bugprone -default-lambda-capture %t
1
+ // RUN: %check_clang_tidy %s readability -default-lambda-capture %t
2
2
3
3
void test_default_captures () {
4
4
int value = 42 ;
5
5
int another = 10 ;
6
6
7
7
auto lambda1 = [=](int x) { return value + x; };
8
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
8
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
9
9
10
10
auto lambda2 = [&](int x) { return value + x; };
11
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
11
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
12
12
13
13
auto lambda3 = [=, &another](int x) { return value + another + x; };
14
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
14
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
15
15
16
16
auto lambda4 = [&, value](int x) { return value + another + x; };
17
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
17
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
18
18
}
19
19
20
20
void test_acceptable_captures () {
@@ -42,10 +42,10 @@ void test_nested_lambdas() {
42
42
int inner_var = 3 ;
43
43
44
44
auto outer = [=]() {
45
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
45
+ // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
46
46
47
47
auto inner = [&](int x) { return outer_var + middle_var + inner_var + x; };
48
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
48
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
49
49
50
50
return inner (10 );
51
51
};
@@ -55,15 +55,15 @@ void test_lambda_returns() {
55
55
int a = 1 , b = 2 , c = 3 ;
56
56
57
57
auto create_adder = [=](int x) {
58
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
58
+ // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
59
59
return [x](int y) { return x + y; }; // Inner lambda is fine - explicit capture
60
60
};
61
61
62
62
auto func1 = [&]() { return a; };
63
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
63
+ // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
64
64
65
65
auto func2 = [=]() { return b; };
66
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
66
+ // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
67
67
}
68
68
69
69
class TestClass {
@@ -74,10 +74,10 @@ class TestClass {
74
74
int local = 10 ;
75
75
76
76
auto lambda1 = [=]() { return member + local; };
77
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
77
+ // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
78
78
79
79
auto lambda2 = [&]() { return member + local; };
80
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
80
+ // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
81
81
82
82
auto lambda3 = [this , local]() { return member + local; };
83
83
auto lambda4 = [this , &local]() { return member + local; };
@@ -89,7 +89,7 @@ void test_template_lambdas() {
89
89
T value{};
90
90
91
91
auto lambda = [=](T x) { return value + x; };
92
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [bugprone -default-lambda-capture]
92
+ // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: lambda default captures are discouraged; prefer to capture specific variables explicitly [readability -default-lambda-capture]
93
93
}
94
94
95
95
void instantiate_templates () {
0 commit comments