Skip to content

Commit fbbbdd5

Browse files
committed
[NFC] simplify testcase: All is not needed
1 parent 720bc68 commit fbbbdd5

File tree

1 file changed

+88
-88
lines changed

1 file changed

+88
-88
lines changed

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

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %check_clang_tidy -check-suffix=ALL,CPP20ORLATER -std=c++20-or-later %s modernize-use-structured-binding %t -- -- -I %S/Inputs/use-structured-binding/
2-
// RUN: %check_clang_tidy -check-suffix=ALL -std=c++17 %s modernize-use-structured-binding %t -- -- -I %S/Inputs/use-structured-binding/
1+
// RUN: %check_clang_tidy -check-suffix=,CPP20ORLATER -std=c++20-or-later %s modernize-use-structured-binding %t -- -- -I %S/Inputs/use-structured-binding/
2+
// RUN: %check_clang_tidy -std=c++17 %s modernize-use-structured-binding %t -- -- -I %S/Inputs/use-structured-binding/
33
#include "fake_std_pair_tuple.h"
44

55
template<typename T>
@@ -16,149 +16,149 @@ struct TestClass {
1616
void DecomposeByAssignWarnCases() {
1717
{
1818
auto P = getPair<int, int>();
19-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
20-
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
19+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
20+
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
2121
int x = P.first;
2222
int y = P.second; // REMOVE
23-
// CHECK-FIXES-ALL: // REMOVE
23+
// CHECK-FIXES: // REMOVE
2424
}
2525

2626
{
2727
auto P = getPair<int, int>();
28-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
29-
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
28+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
29+
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
3030
int x = P.first, y = P.second; // REMOVE
31-
// CHECK-FIXES-ALL: // REMOVE
31+
// CHECK-FIXES: // REMOVE
3232
}
3333

3434
{
3535
auto P = getPair<int, int>();
36-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
37-
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
36+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
37+
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
3838
int x = P.first, y = P.second; // REMOVE
39-
// CHECK-FIXES-ALL: // REMOVE
39+
// CHECK-FIXES: // REMOVE
4040
int z;
4141
}
4242

4343
{
4444
auto P = getPair<int, int>();
45-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
46-
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
45+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
46+
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
4747
int x = P.first;
4848
auto y = P.second; // REMOVE
49-
// CHECK-FIXES-ALL: // REMOVE
49+
// CHECK-FIXES: // REMOVE
5050
}
5151

5252
{
5353
const auto P = getPair<int, int>();
54-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
55-
// CHECK-FIXES-ALL: const auto [x, y] = getPair<int, int>();
54+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
55+
// CHECK-FIXES: const auto [x, y] = getPair<int, int>();
5656
const int x = P.first;
5757
const auto y = P.second; // REMOVE
58-
// CHECK-FIXES-ALL: // REMOVE
58+
// CHECK-FIXES: // REMOVE
5959
}
6060

6161
{
6262
std::pair<int, int> otherP;
6363
auto& P = otherP;
64-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
65-
// CHECK-FIXES-ALL: auto& [x, y] = otherP;
64+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
65+
// CHECK-FIXES: auto& [x, y] = otherP;
6666
int& x = P.first;
6767
auto& y = P.second; // REMOVE
68-
// CHECK-FIXES-ALL: // REMOVE
68+
// CHECK-FIXES: // REMOVE
6969
}
7070

7171
{
7272
std::pair<int, int> otherP;
7373
const auto& P = otherP;
74-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
75-
// CHECK-FIXES-ALL: const auto& [x, y] = otherP;
74+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
75+
// CHECK-FIXES: const auto& [x, y] = otherP;
7676
const int& x = P.first;
7777
const auto& y = P.second; // REMOVE
78-
// CHECK-FIXES-ALL: // REMOVE
78+
// CHECK-FIXES: // REMOVE
7979
}
8080

8181
{
8282
auto P = getPair<int, int>();
83-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
84-
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
83+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
84+
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
8585
int x = P.first;
8686
int y = P.second; // REMOVE
87-
// CHECK-FIXES-ALL: // REMOVE
87+
// CHECK-FIXES: // REMOVE
8888

8989
auto another_p = getPair<int, int>();
90-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
91-
// CHECK-FIXES-ALL: auto [another_x, another_y] = getPair<int, int>();
90+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
91+
// CHECK-FIXES: auto [another_x, another_y] = getPair<int, int>();
9292
int another_x = another_p.first;
9393
int another_y = another_p.second; // REMOVE
94-
// CHECK-FIXES-ALL: // REMOVE
94+
// CHECK-FIXES: // REMOVE
9595
}
9696
}
9797

9898
void forRangeWarnCases() {
9999
std::pair<int, int> Pairs[10];
100100
for (auto P : Pairs) {
101-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
102-
// CHECK-FIXES-ALL: for (auto [x, y] : Pairs) {
101+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
102+
// CHECK-FIXES: for (auto [x, y] : Pairs) {
103103
int x = P.first;
104104
int y = P.second; // REMOVE
105-
// CHECK-FIXES-ALL: // REMOVE
105+
// CHECK-FIXES: // REMOVE
106106
}
107107

108108
for (auto P : Pairs) {
109-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
110-
// CHECK-FIXES-ALL: for (auto [x, y] : Pairs) {
109+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
110+
// CHECK-FIXES: for (auto [x, y] : Pairs) {
111111
int x = P.first, y = P.second; // REMOVE
112-
// CHECK-FIXES-ALL: // REMOVE
112+
// CHECK-FIXES: // REMOVE
113113
}
114114

115115
for (auto P : Pairs) {
116-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
117-
// CHECK-FIXES-ALL: for (auto [x, y] : Pairs) {
116+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
117+
// CHECK-FIXES: for (auto [x, y] : Pairs) {
118118
int x = P.first, y = P.second; // REMOVE
119-
// CHECK-FIXES-ALL: // REMOVE
119+
// CHECK-FIXES: // REMOVE
120120
int z;
121121
}
122122

123123
for (const auto P : Pairs) {
124-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
125-
// CHECK-FIXES-ALL: for (const auto [x, y] : Pairs) {
124+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
125+
// CHECK-FIXES: for (const auto [x, y] : Pairs) {
126126
const int x = P.first;
127127
const int y = P.second; // REMOVE
128-
// CHECK-FIXES-ALL: // REMOVE
128+
// CHECK-FIXES: // REMOVE
129129
}
130130

131131
for (auto& P : Pairs) {
132-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
133-
// CHECK-FIXES-ALL: for (auto& [x, y] : Pairs) {
132+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
133+
// CHECK-FIXES: for (auto& [x, y] : Pairs) {
134134
int& x = P.first;
135135
int& y = P.second; // REMOVE
136-
// CHECK-FIXES-ALL: // REMOVE
136+
// CHECK-FIXES: // REMOVE
137137
}
138138

139139
for (const auto& P : Pairs) {
140-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
141-
// CHECK-FIXES-ALL: for (const auto& [x, y] : Pairs) {
140+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
141+
// CHECK-FIXES: for (const auto& [x, y] : Pairs) {
142142
const int& x = P.first;
143143
const int& y = P.second; // REMOVE
144-
// CHECK-FIXES-ALL: // REMOVE
144+
// CHECK-FIXES: // REMOVE
145145
}
146146

147147
std::pair<TestClass, TestClass> ClassPairs[10];
148148
for (auto P : ClassPairs) {
149-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
150-
// CHECK-FIXES-ALL: for (auto [c1, c2] : ClassPairs) {
149+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
150+
// CHECK-FIXES: for (auto [c1, c2] : ClassPairs) {
151151
TestClass c1 = P.first;
152152
TestClass c2 = P.second; // REMOVE
153-
// CHECK-FIXES-ALL: // REMOVE
153+
// CHECK-FIXES: // REMOVE
154154
}
155155

156156
for (const auto P : ClassPairs) {
157-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
158-
// CHECK-FIXES-ALL: for (const auto [c1, c2] : ClassPairs) {
157+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
158+
// CHECK-FIXES: for (const auto [c1, c2] : ClassPairs) {
159159
const TestClass c1 = P.first;
160160
const TestClass c2 = P.second; // REMOVE
161-
// CHECK-FIXES-ALL: // REMOVE
161+
// CHECK-FIXES: // REMOVE
162162
}
163163
}
164164

@@ -200,30 +200,30 @@ void forRangeNotWarnCases() {
200200
void stdTieWarnCases() {
201201
int a = 0;
202202
int b = 0; // REMOVE
203-
// CHECK-FIXES-ALL: // REMOVE
203+
// CHECK-FIXES: // REMOVE
204204
std::tie(a, b) = getPair<int, int>();
205-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
206-
// CHECK-FIXES-ALL: auto [a, b] = getPair<int, int>();
205+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
206+
// CHECK-FIXES: auto [a, b] = getPair<int, int>();
207207

208208
int x = 0, y = 0; // REMOVE
209-
// CHECK-FIXES-ALL: // REMOVE
209+
// CHECK-FIXES: // REMOVE
210210
std::tie(x, y) = getPair<int, int>();
211-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
212-
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
211+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
212+
// CHECK-FIXES: auto [x, y] = getPair<int, int>();
213213

214214
int* pa = nullptr;
215215
int* pb = nullptr; // REMOVE
216-
// CHECK-FIXES-ALL: // REMOVE
216+
// CHECK-FIXES: // REMOVE
217217
std::tie(pa, pb) = getPair<int*, int*>();
218-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
219-
// CHECK-FIXES-ALL: auto [pa, pb] = getPair<int*, int*>();
218+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
219+
// CHECK-FIXES: auto [pa, pb] = getPair<int*, int*>();
220220

221221
TestClass c1 (1, 2);
222222
TestClass c2 = TestClass {3, 4}; // REMOVE
223-
// CHECK-FIXES-ALL: // REMOVE
223+
// CHECK-FIXES: // REMOVE
224224
std::tie(c1, c2) = getPair<TestClass, TestClass>();
225-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
226-
// CHECK-FIXES-ALL: auto [c1, c2] = getPair<TestClass, TestClass>();
225+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
226+
// CHECK-FIXES: auto [c1, c2] = getPair<TestClass, TestClass>();
227227
}
228228

229229
void stdTieNotWarnCases() {
@@ -413,39 +413,39 @@ struct otherPair {
413413
void OtherPairTest() {
414414
{
415415
auto P = otherPair();
416-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
417-
// CHECK-FIXES-ALL: auto [x, y] = otherPair();
416+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
417+
// CHECK-FIXES: auto [x, y] = otherPair();
418418
int x = P.first;
419419
int y = P.second;
420420
}
421421

422422
{
423423
const auto P = otherPair();
424-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
425-
// CHECK-FIXES-ALL: const auto [x, y] = otherPair();
424+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
425+
// CHECK-FIXES: const auto [x, y] = otherPair();
426426
const int x = P.first;
427427
const auto y = P.second; // REMOVE
428-
// CHECK-FIXES-ALL: // REMOVE
428+
// CHECK-FIXES: // REMOVE
429429
}
430430

431431
{
432432
otherPair otherP;
433433
auto& P = otherP;
434-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
435-
// CHECK-FIXES-ALL: auto& [x, y] = otherP;
434+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
435+
// CHECK-FIXES: auto& [x, y] = otherP;
436436
int& x = P.first;
437437
auto& y = P.second; // REMOVE
438-
// CHECK-FIXES-ALL: // REMOVE
438+
// CHECK-FIXES: // REMOVE
439439
}
440440

441441
{
442442
std::pair<int, int> otherP;
443443
const auto& P = otherP;
444-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
445-
// CHECK-FIXES-ALL: const auto& [x, y] = otherP;
444+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
445+
// CHECK-FIXES: const auto& [x, y] = otherP;
446446
const int& x = P.first;
447447
const auto& y = P.second; // REMOVE
448-
// CHECK-FIXES-ALL: // REMOVE
448+
// CHECK-FIXES: // REMOVE
449449
}
450450
}
451451

@@ -514,20 +514,20 @@ struct ConstFieldPair {
514514
void ConstFieldPairTests() {
515515
{
516516
const ConstFieldPair P = getCertainPair<ConstFieldPair>();
517-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
518-
// CHECK-FIXES-ALL: const auto [x, y] = getCertainPair<ConstFieldPair>();
517+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
518+
// CHECK-FIXES: const auto [x, y] = getCertainPair<ConstFieldPair>();
519519
const int x = P.first;
520520
const int y = P.second; // REMOVE
521-
// CHECK-FIXES-ALL: // REMOVE
521+
// CHECK-FIXES: // REMOVE
522522
}
523523

524524
{
525525
const ConstFieldPair& P = getCertainPair<ConstFieldPair>();
526-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
527-
// CHECK-FIXES-ALL: const auto& [x, y] = getCertainPair<ConstFieldPair>();
526+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
527+
// CHECK-FIXES: const auto& [x, y] = getCertainPair<ConstFieldPair>();
528528
const int& x = P.first;
529529
const int& y = P.second; // REMOVE
530-
// CHECK-FIXES-ALL: // REMOVE
530+
// CHECK-FIXES: // REMOVE
531531
}
532532

533533
{
@@ -545,11 +545,11 @@ struct PointerFieldPair {
545545
void PointerFieldPairTests() {
546546
{
547547
PointerFieldPair P = getCertainPair<PointerFieldPair>();
548-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
549-
// CHECK-FIXES-ALL: auto [x, y] = getCertainPair<PointerFieldPair>();
548+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
549+
// CHECK-FIXES: auto [x, y] = getCertainPair<PointerFieldPair>();
550550
int* x = P.first;
551551
int y = P.second; // REMOVE
552-
// CHECK-FIXES-ALL: // REMOVE
552+
// CHECK-FIXES: // REMOVE
553553
}
554554

555555
{
@@ -568,11 +568,11 @@ struct ConstRefFieldPair {
568568
void ConstRefFieldPairTests() {
569569
{
570570
ConstRefFieldPair P = getCertainPair<ConstRefFieldPair>();
571-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
572-
// CHECK-FIXES-ALL: auto [x, y] = getCertainPair<ConstRefFieldPair>();
571+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
572+
// CHECK-FIXES: auto [x, y] = getCertainPair<ConstRefFieldPair>();
573573
const int& x = P.first;
574574
int y = P.second; // REMOVE
575-
// CHECK-FIXES-ALL: // REMOVE
575+
// CHECK-FIXES: // REMOVE
576576
}
577577

578578
{

0 commit comments

Comments
 (0)