@@ -18,42 +18,52 @@ void DecomposeByAssignWarnCases() {
18
18
auto P = getPair<int , int >();
19
19
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
20
20
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
21
- int x = P.first ;
22
- int y = P.second ;
21
+ int x = P.first ; // REMOVE
22
+ // CHECK-FIXES-ALL: // REMOVE
23
+ int y = P.second ; // REMOVE
24
+ // CHECK-FIXES-ALL: // REMOVE
23
25
}
24
26
25
27
{
26
28
auto P = getPair<int , int >();
27
29
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
28
30
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
29
- int x = P.first ;
30
- auto y = P.second ;
31
+ int x = P.first ; // REMOVE
32
+ // CHECK-FIXES-ALL: // REMOVE
33
+ auto y = P.second ; // REMOVE
34
+ // CHECK-FIXES-ALL: // REMOVE
31
35
}
32
36
33
37
{
34
38
const auto P = getPair<int , int >();
35
39
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
36
40
// CHECK-FIXES-ALL: const auto [x, y] = getPair<int, int>();
37
- const int x = P.first ;
38
- const auto y = P.second ;
41
+ const int x = P.first ; // REMOVE
42
+ // CHECK-FIXES-ALL: // REMOVE
43
+ const auto y = P.second ; // REMOVE
44
+ // CHECK-FIXES-ALL: // REMOVE
39
45
}
40
46
41
47
{
42
48
std::pair<int , int > otherP;
43
49
auto & P = otherP;
44
50
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
45
51
// CHECK-FIXES-ALL: auto& [x, y] = otherP;
46
- int & x = P.first ;
47
- auto & y = P.second ;
52
+ int & x = P.first ; // REMOVE
53
+ // CHECK-FIXES-ALL: // REMOVE
54
+ auto & y = P.second ; // REMOVE
55
+ // CHECK-FIXES-ALL: // REMOVE
48
56
}
49
57
50
58
{
51
59
std::pair<int , int > otherP;
52
60
const auto & P = otherP;
53
61
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
54
62
// CHECK-FIXES-ALL: const auto& [x, y] = otherP;
55
- const int & x = P.first ;
56
- const auto & y = P.second ;
63
+ const int & x = P.first ; // REMOVE
64
+ // CHECK-FIXES-ALL: // REMOVE
65
+ const auto & y = P.second ; // REMOVE
66
+ // CHECK-FIXES-ALL: // REMOVE
57
67
}
58
68
}
59
69
@@ -62,44 +72,56 @@ void forRangeWarnCases() {
62
72
for (auto P : Pairs) {
63
73
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
64
74
// CHECK-FIXES-ALL: for (auto [x, y] : Pairs) {
65
- int x = P.first ;
66
- int y = P.second ;
75
+ int x = P.first ; // REMOVE
76
+ // CHECK-FIXES-ALL: // REMOVE
77
+ int y = P.second ; // REMOVE
78
+ // CHECK-FIXES-ALL: // REMOVE
67
79
}
68
80
69
81
for (const auto P : Pairs) {
70
82
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
71
83
// CHECK-FIXES-ALL: for (const auto [x, y] : Pairs) {
72
- const int x = P.first ;
73
- const int y = P.second ;
84
+ const int x = P.first ; // REMOVE
85
+ // CHECK-FIXES-ALL: // REMOVE
86
+ const int y = P.second ; // REMOVE
87
+ // CHECK-FIXES-ALL: // REMOVE
74
88
}
75
89
76
90
for (auto & P : Pairs) {
77
91
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
78
92
// CHECK-FIXES-ALL: for (auto& [x, y] : Pairs) {
79
- int & x = P.first ;
80
- int & y = P.second ;
93
+ int & x = P.first ; // REMOVE
94
+ // CHECK-FIXES-ALL: // REMOVE
95
+ int & y = P.second ; // REMOVE
96
+ // CHECK-FIXES-ALL: // REMOVE
81
97
}
82
98
83
99
for (const auto & P : Pairs) {
84
100
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
85
101
// CHECK-FIXES-ALL: for (const auto& [x, y] : Pairs) {
86
- const int & x = P.first ;
87
- const int & y = P.second ;
102
+ const int & x = P.first ; // REMOVE
103
+ // CHECK-FIXES-ALL: // REMOVE
104
+ const int & y = P.second ; // REMOVE
105
+ // CHECK-FIXES-ALL: // REMOVE
88
106
}
89
107
90
108
std::pair<TestClass, TestClass> ClassPairs[10 ];
91
109
for (auto P : ClassPairs) {
92
110
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
93
111
// CHECK-FIXES-ALL: for (auto [c1, c2] : ClassPairs) {
94
- TestClass c1 = P.first ;
95
- TestClass c2 = P.second ;
112
+ TestClass c1 = P.first ; // REMOVE
113
+ // CHECK-FIXES-ALL: // REMOVE
114
+ TestClass c2 = P.second ; // REMOVE
115
+ // CHECK-FIXES-ALL: // REMOVE
96
116
}
97
117
98
118
for (const auto P : ClassPairs) {
99
119
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
100
120
// CHECK-FIXES-ALL: for (const auto [c1, c2] : ClassPairs) {
101
- const TestClass c1 = P.first ;
102
- const TestClass c2 = P.second ;
121
+ const TestClass c1 = P.first ; // REMOVE
122
+ // CHECK-FIXES-ALL: // REMOVE
123
+ const TestClass c2 = P.second ; // REMOVE
124
+ // CHECK-FIXES-ALL: // REMOVE
103
125
}
104
126
}
105
127
@@ -139,20 +161,26 @@ void forRangeNotWarnCases() {
139
161
}
140
162
141
163
void stdTieWarnCases () {
142
- int a = 0 ;
143
- int b = 0 ;
164
+ int a = 0 ; // REMOVE
165
+ // CHECK-FIXES-ALL: // REMOVE
166
+ int b = 0 ; // REMOVE
167
+ // CHECK-FIXES-ALL: // REMOVE
144
168
std::tie (a, b) = getPair<int , int >();
145
169
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
146
170
// CHECK-FIXES-ALL: auto [a, b] = getPair<int, int>();
147
171
148
- int * pa = nullptr ;
149
- int * pb = nullptr ;
172
+ int * pa = nullptr ; // REMOVE
173
+ // CHECK-FIXES-ALL: // REMOVE
174
+ int * pb = nullptr ; // REMOVE
175
+ // CHECK-FIXES-ALL: // REMOVE
150
176
std::tie (pa, pb) = getPair<int *, int *>();
151
177
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
152
178
// CHECK-FIXES-ALL: auto [pa, pb] = getPair<int*, int*>();
153
179
154
- TestClass c1 (1 , 2 );
155
- TestClass c2 = TestClass {3 , 4 };
180
+ TestClass c1 (1 , 2 ); // REMOVE
181
+ // CHECK-FIXES-ALL: // REMOVE
182
+ TestClass c2 = TestClass {3 , 4 }; // REMOVE
183
+ // CHECK-FIXES-ALL: // REMOVE
156
184
std::tie (c1, c2) = getPair<TestClass, TestClass>();
157
185
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
158
186
// CHECK-FIXES-ALL: auto [c1, c2] = getPair<TestClass, TestClass>();
@@ -255,8 +283,10 @@ void captureByVal() {
255
283
auto P = getPair<int , int >();
256
284
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
257
285
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
258
- int x = P.first ;
259
- int y = P.second ;
286
+ int x = P.first ; // REMOVE
287
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
288
+ int y = P.second ; // REMOVE
289
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
260
290
261
291
auto lambda = [x]() {
262
292
int y = x;
@@ -267,8 +297,10 @@ void captureByRef() {
267
297
auto P = getPair<int , int >();
268
298
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
269
299
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
270
- int x = P.first ;
271
- int y = P.second ;
300
+ int x = P.first ; // REMOVE
301
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
302
+ int y = P.second ; // REMOVE
303
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
272
304
273
305
auto lambda = [&x]() {
274
306
x = 1 ;
@@ -279,8 +311,10 @@ void captureByAllRef() {
279
311
auto P = getPair<int , int >();
280
312
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
281
313
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
282
- int x = P.first ;
283
- int y = P.second ;
314
+ int x = P.first ; // REMOVE
315
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
316
+ int y = P.second ; // REMOVE
317
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
284
318
285
319
auto lambda = [&]() {
286
320
x = 1 ;
@@ -291,8 +325,10 @@ void deepLambda() {
291
325
auto P = getPair<int , int >();
292
326
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
293
327
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
294
- int x = P.first ;
295
- int y = P.second ;
328
+ int x = P.first ; // REMOVE
329
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
330
+ int y = P.second ; // REMOVE
331
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
296
332
297
333
{
298
334
auto lambda = [x]() {
@@ -306,8 +342,10 @@ void forRangeNotWarn() {
306
342
for (auto P : Pairs) {
307
343
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
308
344
// CHECK-FIXES-CPP20ORLATER: for (auto [x, y] : Pairs) {
309
- int x = P.first ;
310
- int y = P.second ;
345
+ int x = P.first ; // REMOVE
346
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
347
+ int y = P.second ; // REMOVE
348
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
311
349
312
350
auto lambda = [&]() {
313
351
x = 1 ;
@@ -316,8 +354,10 @@ void forRangeNotWarn() {
316
354
}
317
355
318
356
void stdTieNotWarn () {
319
- int x = 0 ;
320
- int y = 0 ;
357
+ int x = 0 ; // REMOVE
358
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
359
+ int y = 0 ; // REMOVE
360
+ // CHECK-FIXES-CPP20ORLATER: // REMOVE
321
361
std::tie (x, y) = getPair<int , int >();
322
362
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
323
363
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
0 commit comments