Skip to content

Commit a5222a2

Browse files
committed
[NFC] Add some tests about two VarDecl in one DeclStmt.
1 parent 3f95a69 commit a5222a2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ void DecomposeByAssignWarnCases() {
2424
// CHECK-FIXES-ALL: // REMOVE
2525
}
2626

27+
{
28+
auto P = getPair<int, int>();
29+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
30+
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
31+
int x = P.first, y = P.second; // REMOVE
32+
// CHECK-FIXES-ALL: // REMOVE
33+
}
34+
2735
{
2836
auto P = getPair<int, int>();
2937
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
@@ -78,6 +86,13 @@ void forRangeWarnCases() {
7886
// CHECK-FIXES-ALL: // REMOVE
7987
}
8088

89+
for (auto P : Pairs) {
90+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
91+
// CHECK-FIXES-ALL: for (auto [x, y] : Pairs) {
92+
int x = P.first, y = P.second; // REMOVE
93+
// CHECK-FIXES-ALL: // REMOVE
94+
}
95+
8196
for (const auto P : Pairs) {
8297
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:8: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
8398
// CHECK-FIXES-ALL: for (const auto [x, y] : Pairs) {
@@ -169,6 +184,12 @@ void stdTieWarnCases() {
169184
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
170185
// CHECK-FIXES-ALL: auto [a, b] = getPair<int, int>();
171186

187+
int x = 0, y = 0; // REMOVE
188+
// CHECK-FIXES-ALL: // REMOVE
189+
std::tie(x, y) = getPair<int, int>();
190+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:3: warning: use structured binding to decompose a pair [modernize-use-structured-binding]
191+
// CHECK-FIXES-ALL: auto [x, y] = getPair<int, int>();
192+
172193
int* pa = nullptr; // REMOVE
173194
// CHECK-FIXES-ALL: // REMOVE
174195
int* pb = nullptr; // REMOVE

0 commit comments

Comments
 (0)