Skip to content

Commit 0b007e8

Browse files
committed
[NFC] Rename warning message to use a structured binding...
1 parent edac2d4 commit 0b007e8

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

clang-tools-extra/clang-tidy/modernize/UseStructuredBindingCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void UseStructuredBindingCheck::check(const MatchFinder::MatchResult &Result) {
360360
(Twine(Prefix) + " [" + FirstVar->getNameAsString() + ", " +
361361
SecondVar->getNameAsString() + "]" + (CFRS ? " :" : ""))
362362
.str();
363-
diag(DiagLoc, "use structured binding to decompose a pair")
363+
diag(DiagLoc, "use a structured binding to decompose a pair")
364364
<< FixItHint::CreateReplacement(ReplaceRange, ReplacementText)
365365
<< FixItHint::CreateRemoval(
366366
SourceRange{BeginDS->getBeginLoc(), EndDS->getEndLoc()});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ struct otherPair {
1616
void OptionTest() {
1717
{
1818
auto P = custom::pair();
19-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
19+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
2020
// CHECK-FIXES: auto [x, y] = custom::pair();
2121
int x = P.first;
2222
int y = P.second;
2323
}
2424

2525
{
2626
auto P = otherPair();
27-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
27+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
2828
// CHECK-FIXES: auto [x, y] = otherPair();
2929
int x = P.first;
3030
int y = P.second;

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct TestClass {
1616
void DecomposeByAssignWarnCases() {
1717
{
1818
auto P = getPair<int, int>();
19-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
19+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
2020
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
2121
int x = P.first;
2222
int y = P.second; // REMOVE
@@ -25,15 +25,15 @@ void DecomposeByAssignWarnCases() {
2525

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

3434
{
3535
auto P = getPair<int, int>();
36-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
36+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
3737
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
3838
int x = P.first, y = P.second; // REMOVE
3939
// CHECK-FIXES-ALL: // REMOVE
@@ -42,7 +42,7 @@ void DecomposeByAssignWarnCases() {
4242

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

5252
{
5353
const auto P = getPair<int, int>();
54-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
54+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
5555
// CHECK-FIXES-ALL: const auto [x, y] = getPair<int, int>();
5656
const int x = P.first;
5757
const auto y = P.second; // REMOVE
@@ -61,7 +61,7 @@ void DecomposeByAssignWarnCases() {
6161
{
6262
std::pair<int, int> otherP;
6363
auto& P = otherP;
64-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
64+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
6565
// CHECK-FIXES-ALL: auto& [x, y] = otherP;
6666
int& x = P.first;
6767
auto& y = P.second; // REMOVE
@@ -71,7 +71,7 @@ void DecomposeByAssignWarnCases() {
7171
{
7272
std::pair<int, int> otherP;
7373
const auto& P = otherP;
74-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
74+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
7575
// CHECK-FIXES-ALL: const auto& [x, y] = otherP;
7676
const int& x = P.first;
7777
const auto& y = P.second; // REMOVE
@@ -82,46 +82,46 @@ void DecomposeByAssignWarnCases() {
8282
void forRangeWarnCases() {
8383
std::pair<int, int> Pairs[10];
8484
for (auto P : Pairs) {
85-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
85+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
8686
// CHECK-FIXES-ALL: for (auto [x, y] : Pairs) {
8787
int x = P.first;
8888
int y = P.second; // REMOVE
8989
// CHECK-FIXES-ALL: // REMOVE
9090
}
9191

9292
for (auto P : Pairs) {
93-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
93+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
9494
// CHECK-FIXES-ALL: for (auto [x, y] : Pairs) {
9595
int x = P.first, y = P.second; // REMOVE
9696
// CHECK-FIXES-ALL: // REMOVE
9797
}
9898

9999
for (auto P : Pairs) {
100-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
100+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
101101
// CHECK-FIXES-ALL: for (auto [x, y] : Pairs) {
102102
int x = P.first, y = P.second; // REMOVE
103103
// CHECK-FIXES-ALL: // REMOVE
104104
int z;
105105
}
106106

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

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

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

131131
std::pair<TestClass, TestClass> ClassPairs[10];
132132
for (auto P : ClassPairs) {
133-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
133+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
134134
// CHECK-FIXES-ALL: for (auto [c1, c2] : ClassPairs) {
135135
TestClass c1 = P.first;
136136
TestClass c2 = P.second; // REMOVE
137137
// CHECK-FIXES-ALL: // REMOVE
138138
}
139139

140140
for (const auto P : ClassPairs) {
141-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
141+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
142142
// CHECK-FIXES-ALL: for (const auto [c1, c2] : ClassPairs) {
143143
const TestClass c1 = P.first;
144144
const TestClass c2 = P.second; // REMOVE
@@ -186,27 +186,27 @@ void stdTieWarnCases() {
186186
int b = 0; // REMOVE
187187
// CHECK-FIXES-ALL: // REMOVE
188188
std::tie(a, b) = getPair<int, int>();
189-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
189+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
190190
// CHECK-FIXES-ALL: auto [a, b] = getPair<int, int>();
191191

192192
int x = 0, y = 0; // REMOVE
193193
// CHECK-FIXES-ALL: // REMOVE
194194
std::tie(x, y) = getPair<int, int>();
195-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
195+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
196196
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
197197

198198
int* pa = nullptr;
199199
int* pb = nullptr; // REMOVE
200200
// CHECK-FIXES-ALL: // REMOVE
201201
std::tie(pa, pb) = getPair<int*, int*>();
202-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
202+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
203203
// CHECK-FIXES-ALL: auto [pa, pb] = getPair<int*, int*>();
204204

205205
TestClass c1 (1, 2);
206206
TestClass c2 = TestClass {3, 4}; // REMOVE
207207
// CHECK-FIXES-ALL: // REMOVE
208208
std::tie(c1, c2) = getPair<TestClass, TestClass>();
209-
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
209+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
210210
// CHECK-FIXES-ALL: auto [c1, c2] = getPair<TestClass, TestClass>();
211211
}
212212

@@ -309,7 +309,7 @@ void NotWarnForMacro2() {
309309

310310
void captureByVal() {
311311
auto P = getPair<int, int>();
312-
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
312+
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
313313
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
314314
int x = P.first;
315315
int y = P.second; // REMOVE
@@ -322,7 +322,7 @@ void captureByVal() {
322322

323323
void captureByRef() {
324324
auto P = getPair<int, int>();
325-
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
325+
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
326326
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
327327
int x = P.first;
328328
int y = P.second; // REMOVE
@@ -335,7 +335,7 @@ void captureByRef() {
335335

336336
void captureByAllRef() {
337337
auto P = getPair<int, int>();
338-
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
338+
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
339339
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
340340
int x = P.first;
341341
int y = P.second; // REMOVE
@@ -348,7 +348,7 @@ void captureByAllRef() {
348348

349349
void deepLambda() {
350350
auto P = getPair<int, int>();
351-
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
351+
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
352352
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
353353
int x = P.first;
354354
int y = P.second; // REMOVE
@@ -364,7 +364,7 @@ void deepLambda() {
364364
void forRangeNotWarn() {
365365
std::pair<int, int> Pairs[10];
366366
for (auto P : Pairs) {
367-
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
367+
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:8: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
368368
// CHECK-FIXES-CPP20ORLATER: for (auto [x, y] : Pairs) {
369369
int x = P.first;
370370
int y = P.second; // REMOVE
@@ -381,7 +381,7 @@ void stdTieNotWarn() {
381381
int y = 0; // REMOVE
382382
// CHECK-FIXES-CPP20ORLATER: // REMOVE
383383
std::tie(x, y) = getPair<int, int>();
384-
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
384+
// CHECK-MESSAGES-CPP20ORLATER: :[[@LINE-1]]:3: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
385385
// CHECK-FIXES-CPP20ORLATER: auto [x, y] = getPair<int, int>();
386386

387387
auto lambda = [&x]() {

0 commit comments

Comments
 (0)