Skip to content

Commit f6c129b

Browse files
committed
[NFC] Change warning message to 'use structured binding to decompose a pair'
1 parent 4127b7b commit f6c129b

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ void UseStructuredBindingCheck::check(const MatchFinder::MatchResult &Result) {
365365
SecondVar->getNameAsString() + "]";
366366
if (CFRS)
367367
ReplacementText += " :";
368-
diag(DiagLoc, "Should use structured binding to decompose pair")
368+
diag(DiagLoc, "use structured binding to decompose a pair")
369369
<< FixItHint::CreateReplacement(ReplaceRange, ReplacementText) << Hints;
370370
};
371371

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: Should use structured binding to decompose pair [modernize-use-structured-binding]
19+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use 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: Should use structured binding to decompose pair [modernize-use-structured-binding]
27+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use 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: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ struct TestClass {
1515
void DecomposeByAssignWarnCases() {
1616
{
1717
auto P = getPair<int, int>();
18-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
18+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
1919
// CHECK-FIXES: {{^}} auto [x, y] = getPair<int, int>();
2020
int x = P.first;
2121
int y = P.second;
2222
}
2323

2424
{
2525
auto P = getPair<int, int>();
26-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
26+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
2727
// CHECK-FIXES: {{^}} auto [x, y] = getPair<int, int>();
2828
int x = P.first;
2929
auto y = P.second;
3030
}
3131

3232
{
3333
const auto P = getPair<int, int>();
34-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
34+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
3535
// CHECK-FIXES: {{^}} const auto [x, y] = getPair<int, int>();
3636
const int x = P.first;
3737
const auto y = P.second;
@@ -40,7 +40,7 @@ void DecomposeByAssignWarnCases() {
4040
{
4141
std::pair<int, int> otherP;
4242
auto& P = otherP;
43-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
43+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
4444
// CHECK-FIXES: {{^}} auto& [x, y] = otherP;
4545
int& x = P.first;
4646
auto& y = P.second;
@@ -49,7 +49,7 @@ void DecomposeByAssignWarnCases() {
4949
{
5050
std::pair<int, int> otherP;
5151
const auto& P = otherP;
52-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
52+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
5353
// CHECK-FIXES: {{^}} const auto& [x, y] = otherP;
5454
const int& x = P.first;
5555
const auto& y = P.second;
@@ -59,43 +59,43 @@ void DecomposeByAssignWarnCases() {
5959
void forRangeWarnCases() {
6060
std::pair<int, int> Pairs[10];
6161
for (auto P : Pairs) {
62-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
62+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
6363
// CHECK-FIXES: {{^}} for (auto [x, y] : Pairs) {
6464
int x = P.first;
6565
int y = P.second;
6666
}
6767

6868
for (const auto P : Pairs) {
69-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
69+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
7070
// CHECK-FIXES: {{^}} for (const auto [x, y] : Pairs) {
7171
const int x = P.first;
7272
const int y = P.second;
7373
}
7474

7575
for (auto& P : Pairs) {
76-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
76+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
7777
// CHECK-FIXES: {{^}} for (auto& [x, y] : Pairs) {
7878
int& x = P.first;
7979
int& y = P.second;
8080
}
8181

8282
for (const auto& P : Pairs) {
83-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
83+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
8484
// CHECK-FIXES: {{^}} for (const auto& [x, y] : Pairs) {
8585
const int& x = P.first;
8686
const int& y = P.second;
8787
}
8888

8989
std::pair<TestClass, TestClass> ClassPairs[10];
9090
for (auto P : ClassPairs) {
91-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
91+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
9292
// CHECK-FIXES: {{^}} for (auto [c1, c2] : ClassPairs) {
9393
TestClass c1 = P.first;
9494
TestClass c2 = P.second;
9595
}
9696

9797
for (const auto P : ClassPairs) {
98-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
98+
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
9999
// CHECK-FIXES: {{^}} for (const auto [c1, c2] : ClassPairs) {
100100
const TestClass c1 = P.first;
101101
const TestClass c2 = P.second;
@@ -106,19 +106,19 @@ void stdTieWarnCases() {
106106
int a = 0;
107107
int b = 0;
108108
std::tie(a, b) = getPair<int, int>();
109-
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
109+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
110110
// CHECK-FIXES: {{^}} auto [a, b] = getPair<int, int>();
111111

112112
int* pa = nullptr;
113113
int* pb = nullptr;
114114
std::tie(pa, pb) = getPair<int*, int*>();
115-
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
115+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
116116
// CHECK-FIXES: {{^}} auto [pa, pb] = getPair<int*, int*>();
117117

118118
TestClass c1 (1, 2);
119119
TestClass c2 = TestClass {3, 4};
120120
std::tie(c1, c2) = getPair<TestClass, TestClass>();
121-
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Should use structured binding to decompose pair [modernize-use-structured-binding]
121+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
122122
// CHECK-FIXES: {{^}} auto [c1, c2] = getPair<TestClass, TestClass>();
123123
}
124124

0 commit comments

Comments
 (0)