Skip to content

Commit c97ce9b

Browse files
committed
[NFC] Test removed lines
1 parent aa3bf50 commit c97ce9b

File tree

1 file changed

+80
-40
lines changed

1 file changed

+80
-40
lines changed

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

Lines changed: 80 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,52 @@ void DecomposeByAssignWarnCases() {
1818
auto P = getPair<int, int>();
1919
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
2020
// 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
2325
}
2426

2527
{
2628
auto P = getPair<int, int>();
2729
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
2830
// 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
3135
}
3236

3337
{
3438
const auto P = getPair<int, int>();
3539
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
3640
// 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
3945
}
4046

4147
{
4248
std::pair<int, int> otherP;
4349
auto& P = otherP;
4450
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
4551
// 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
4856
}
4957

5058
{
5159
std::pair<int, int> otherP;
5260
const auto& P = otherP;
5361
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
5462
// 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
5767
}
5868
}
5969

@@ -62,44 +72,56 @@ void forRangeWarnCases() {
6272
for (auto P : Pairs) {
6373
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
6474
// 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
6779
}
6880

6981
for (const auto P : Pairs) {
7082
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
7183
// 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
7488
}
7589

7690
for (auto& P : Pairs) {
7791
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
7892
// 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
8197
}
8298

8399
for (const auto& P : Pairs) {
84100
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
85101
// 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
88106
}
89107

90108
std::pair<TestClass, TestClass> ClassPairs[10];
91109
for (auto P : ClassPairs) {
92110
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
93111
// 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
96116
}
97117

98118
for (const auto P : ClassPairs) {
99119
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
100120
// 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
103125
}
104126
}
105127

@@ -139,20 +161,26 @@ void forRangeNotWarnCases() {
139161
}
140162

141163
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
144168
std::tie(a, b) = getPair<int, int>();
145169
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
146170
// CHECK-FIXES-ALL: auto [a, b] = getPair<int, int>();
147171

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
150176
std::tie(pa, pb) = getPair<int*, int*>();
151177
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
152178
// CHECK-FIXES-ALL: auto [pa, pb] = getPair<int*, int*>();
153179

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
156184
std::tie(c1, c2) = getPair<TestClass, TestClass>();
157185
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
158186
// CHECK-FIXES-ALL: auto [c1, c2] = getPair<TestClass, TestClass>();
@@ -255,8 +283,10 @@ void captureByVal() {
255283
auto P = getPair<int, int>();
256284
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
257285
// 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
260290

261291
auto lambda = [x]() {
262292
int y = x;
@@ -267,8 +297,10 @@ void captureByRef() {
267297
auto P = getPair<int, int>();
268298
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
269299
// 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
272304

273305
auto lambda = [&x]() {
274306
x = 1;
@@ -279,8 +311,10 @@ void captureByAllRef() {
279311
auto P = getPair<int, int>();
280312
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
281313
// 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
284318

285319
auto lambda = [&]() {
286320
x = 1;
@@ -291,8 +325,10 @@ void deepLambda() {
291325
auto P = getPair<int, int>();
292326
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
293327
// 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
296332

297333
{
298334
auto lambda = [x]() {
@@ -306,8 +342,10 @@ void forRangeNotWarn() {
306342
for (auto P : Pairs) {
307343
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
308344
// 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
311349

312350
auto lambda = [&]() {
313351
x = 1;
@@ -316,8 +354,10 @@ void forRangeNotWarn() {
316354
}
317355

318356
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
321361
std::tie(x, y) = getPair<int, int>();
322362
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
323363
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();

0 commit comments

Comments
 (0)