Skip to content

Commit 8d3054c

Browse files
committed
[NFC][TEST] check for remove of first declstmt
1 parent fbbbdd5 commit 8d3054c

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

clang-tools-extra/test/clang-tidy/checkers/modernize/use-structured-binding.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void DecomposeByAssignWarnCases() {
1818
auto P = getPair<int, int>();
1919
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
2020
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
21+
// CHECK-NEXT: // REMOVE
2122
int x = P.first;
2223
int y = P.second; // REMOVE
2324
// CHECK-FIXES: // REMOVE
@@ -44,6 +45,7 @@ void DecomposeByAssignWarnCases() {
4445
auto P = getPair<int, int>();
4546
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
4647
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
48+
// CHECK-NEXT: // REMOVE
4749
int x = P.first;
4850
auto y = P.second; // REMOVE
4951
// CHECK-FIXES: // REMOVE
@@ -53,6 +55,7 @@ void DecomposeByAssignWarnCases() {
5355
const auto P = getPair<int, int>();
5456
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
5557
// CHECK-FIXES: const auto [x, y] = getPair<int, int>();
58+
// CHECK-NEXT: // REMOVE
5659
const int x = P.first;
5760
const auto y = P.second; // REMOVE
5861
// CHECK-FIXES: // REMOVE
@@ -63,6 +66,7 @@ void DecomposeByAssignWarnCases() {
6366
auto& P = otherP;
6467
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
6568
// CHECK-FIXES: auto& [x, y] = otherP;
69+
// CHECK-NEXT: // REMOVE
6670
int& x = P.first;
6771
auto& y = P.second; // REMOVE
6872
// CHECK-FIXES: // REMOVE
@@ -73,6 +77,7 @@ void DecomposeByAssignWarnCases() {
7377
const auto& P = otherP;
7478
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
7579
// CHECK-FIXES: const auto& [x, y] = otherP;
80+
// CHECK-NEXT: // REMOVE
7681
const int& x = P.first;
7782
const auto& y = P.second; // REMOVE
7883
// CHECK-FIXES: // REMOVE
@@ -82,13 +87,15 @@ void DecomposeByAssignWarnCases() {
8287
auto P = getPair<int, int>();
8388
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
8489
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
90+
// CHECK-NEXT: // REMOVE
8591
int x = P.first;
8692
int y = P.second; // REMOVE
8793
// CHECK-FIXES: // REMOVE
8894

8995
auto another_p = getPair<int, int>();
9096
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
9197
// CHECK-FIXES: auto [another_x, another_y] = getPair<int, int>();
98+
// CHECK-NEXT: // REMOVE
9299
int another_x = another_p.first;
93100
int another_y = another_p.second; // REMOVE
94101
// CHECK-FIXES: // REMOVE
@@ -100,6 +107,7 @@ void forRangeWarnCases() {
100107
for (auto P : Pairs) {
101108
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
102109
// CHECK-FIXES: for (auto [x, y] : Pairs) {
110+
// CHECK-NEXT: // REMOVE
103111
int x = P.first;
104112
int y = P.second; // REMOVE
105113
// CHECK-FIXES: // REMOVE
@@ -123,6 +131,7 @@ void forRangeWarnCases() {
123131
for (const auto P : Pairs) {
124132
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
125133
// CHECK-FIXES: for (const auto [x, y] : Pairs) {
134+
// CHECK-NEXT: // REMOVE
126135
const int x = P.first;
127136
const int y = P.second; // REMOVE
128137
// CHECK-FIXES: // REMOVE
@@ -131,6 +140,7 @@ void forRangeWarnCases() {
131140
for (auto& P : Pairs) {
132141
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
133142
// CHECK-FIXES: for (auto& [x, y] : Pairs) {
143+
// CHECK-NEXT: // REMOVE
134144
int& x = P.first;
135145
int& y = P.second; // REMOVE
136146
// CHECK-FIXES: // REMOVE
@@ -139,6 +149,7 @@ void forRangeWarnCases() {
139149
for (const auto& P : Pairs) {
140150
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
141151
// CHECK-FIXES: for (const auto& [x, y] : Pairs) {
152+
// CHECK-NEXT: // REMOVE
142153
const int& x = P.first;
143154
const int& y = P.second; // REMOVE
144155
// CHECK-FIXES: // REMOVE
@@ -148,6 +159,7 @@ void forRangeWarnCases() {
148159
for (auto P : ClassPairs) {
149160
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
150161
// CHECK-FIXES: for (auto [c1, c2] : ClassPairs) {
162+
// CHECK-NEXT: // REMOVE
151163
TestClass c1 = P.first;
152164
TestClass c2 = P.second; // REMOVE
153165
// CHECK-FIXES: // REMOVE
@@ -156,6 +168,7 @@ void forRangeWarnCases() {
156168
for (const auto P : ClassPairs) {
157169
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
158170
// CHECK-FIXES: for (const auto [c1, c2] : ClassPairs) {
171+
// CHECK-NEXT: // REMOVE
159172
const TestClass c1 = P.first;
160173
const TestClass c2 = P.second; // REMOVE
161174
// CHECK-FIXES: // REMOVE
@@ -198,6 +211,7 @@ void forRangeNotWarnCases() {
198211
}
199212

200213
void stdTieWarnCases() {
214+
// CHECK-NEXT: // REMOVE
201215
int a = 0;
202216
int b = 0; // REMOVE
203217
// CHECK-FIXES: // REMOVE
@@ -211,13 +225,15 @@ void stdTieWarnCases() {
211225
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
212226
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
213227

228+
// CHECK-NEXT: // REMOVE
214229
int* pa = nullptr;
215230
int* pb = nullptr; // REMOVE
216231
// CHECK-FIXES: // REMOVE
217232
std::tie(pa, pb) = getPair<int*, int*>();
218233
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
219234
// CHECK-FIXES: auto [pa, pb] = getPair<int*, int*>();
220235

236+
// CHECK-NEXT: // REMOVE
221237
TestClass c1 (1, 2);
222238
TestClass c2 = TestClass {3, 4}; // REMOVE
223239
// CHECK-FIXES: // REMOVE
@@ -327,6 +343,7 @@ void captureByVal() {
327343
auto P = getPair<int, int>();
328344
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
329345
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
346+
// CHECK-NEXT-CPP20ORLATER: // REMOVE
330347
int x = P.first;
331348
int y = P.second; // REMOVE
332349
// CHECK-FIXES-CPP20ORLATER: // REMOVE
@@ -340,6 +357,7 @@ void captureByRef() {
340357
auto P = getPair<int, int>();
341358
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
342359
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
360+
// CHECK-NEXT-CPP20ORLATER: // REMOVE
343361
int x = P.first;
344362
int y = P.second; // REMOVE
345363
// CHECK-FIXES-CPP20ORLATER: // REMOVE
@@ -353,6 +371,7 @@ void captureByAllRef() {
353371
auto P = getPair<int, int>();
354372
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
355373
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
374+
// CHECK-NEXT-CPP20ORLATER: // REMOVE
356375
int x = P.first;
357376
int y = P.second; // REMOVE
358377
// CHECK-FIXES-CPP20ORLATER: // REMOVE
@@ -366,6 +385,7 @@ void deepLambda() {
366385
auto P = getPair<int, int>();
367386
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
368387
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
388+
// CHECK-NEXT-CPP20ORLATER: // REMOVE
369389
int x = P.first;
370390
int y = P.second; // REMOVE
371391
// CHECK-FIXES-CPP20ORLATER: // REMOVE
@@ -382,6 +402,7 @@ void forRangeNotWarn() {
382402
for (auto P : Pairs) {
383403
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
384404
// CHECK-FIXES-CPP20ORLATER: for (auto [x, y] : Pairs) {
405+
// CHECK-NEXT-CPP20ORLATER: // REMOVE
385406
int x = P.first;
386407
int y = P.second; // REMOVE
387408
// CHECK-FIXES-CPP20ORLATER: // REMOVE
@@ -393,6 +414,7 @@ void forRangeNotWarn() {
393414
}
394415

395416
void stdTieNotWarn() {
417+
// CHECK-NEXT-CPP20ORLATER: // REMOVE
396418
int x = 0;
397419
int y = 0; // REMOVE
398420
// CHECK-FIXES-CPP20ORLATER: // REMOVE
@@ -415,14 +437,17 @@ void OtherPairTest() {
415437
auto P = otherPair();
416438
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
417439
// CHECK-FIXES: auto [x, y] = otherPair();
440+
// CHECK-NEXT: // REMOVE
418441
int x = P.first;
419-
int y = P.second;
442+
int y = P.second; // REMOVE
443+
// CHECK-FIXES: // REMOVE
420444
}
421445

422446
{
423447
const auto P = otherPair();
424448
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
425449
// CHECK-FIXES: const auto [x, y] = otherPair();
450+
// CHECK-NEXT: // REMOVE
426451
const int x = P.first;
427452
const auto y = P.second; // REMOVE
428453
// CHECK-FIXES: // REMOVE
@@ -433,6 +458,7 @@ void OtherPairTest() {
433458
auto& P = otherP;
434459
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
435460
// CHECK-FIXES: auto& [x, y] = otherP;
461+
// CHECK-NEXT: // REMOVE
436462
int& x = P.first;
437463
auto& y = P.second; // REMOVE
438464
// CHECK-FIXES: // REMOVE
@@ -443,6 +469,7 @@ void OtherPairTest() {
443469
const auto& P = otherP;
444470
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
445471
// CHECK-FIXES: const auto& [x, y] = otherP;
472+
// CHECK-NEXT: // REMOVE
446473
const int& x = P.first;
447474
const auto& y = P.second; // REMOVE
448475
// CHECK-FIXES: // REMOVE
@@ -516,6 +543,7 @@ void ConstFieldPairTests() {
516543
const ConstFieldPair P = getCertainPair<ConstFieldPair>();
517544
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
518545
// CHECK-FIXES: const auto [x, y] = getCertainPair<ConstFieldPair>();
546+
// CHECK-NEXT: // REMOVE
519547
const int x = P.first;
520548
const int y = P.second; // REMOVE
521549
// CHECK-FIXES: // REMOVE
@@ -525,6 +553,7 @@ void ConstFieldPairTests() {
525553
const ConstFieldPair& P = getCertainPair<ConstFieldPair>();
526554
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
527555
// CHECK-FIXES: const auto& [x, y] = getCertainPair<ConstFieldPair>();
556+
// CHECK-NEXT: // REMOVE
528557
const int& x = P.first;
529558
const int& y = P.second; // REMOVE
530559
// CHECK-FIXES: // REMOVE
@@ -547,6 +576,7 @@ void PointerFieldPairTests() {
547576
PointerFieldPair P = getCertainPair<PointerFieldPair>();
548577
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
549578
// CHECK-FIXES: auto [x, y] = getCertainPair<PointerFieldPair>();
579+
// CHECK-NEXT: // REMOVE
550580
int* x = P.first;
551581
int y = P.second; // REMOVE
552582
// CHECK-FIXES: // REMOVE
@@ -570,6 +600,7 @@ void ConstRefFieldPairTests() {
570600
ConstRefFieldPair P = getCertainPair<ConstRefFieldPair>();
571601
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
572602
// CHECK-FIXES: auto [x, y] = getCertainPair<ConstRefFieldPair>();
603+
// CHECK-NEXT: // REMOVE
573604
const int& x = P.first;
574605
int y = P.second; // REMOVE
575606
// CHECK-FIXES: // REMOVE

0 commit comments

Comments
 (0)