Skip to content

Commit 6d44ea0

Browse files
committed
[NFC] Add test for multi checked cases in one scope
1 parent d091ff4 commit 6d44ea0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ void DecomposeByAssignWarnCases() {
7777
const auto& y = P.second; // REMOVE
7878
// CHECK-FIXES-ALL: // REMOVE
7979
}
80+
81+
{
82+
auto P = getPair<int, int>(); // match
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>(); // match
85+
int x = P.first;
86+
int y = P.second; // REMOVE
87+
// CHECK-FIXES-ALL: // REMOVE
88+
89+
// maybe match with `hasParent` but NOT with `has(declStmt())`
90+
auto another_p = getPair<int, int>();
91+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: use a structured binding to decompose a pair [modernize-use-structured-binding]
92+
// CHECK-FIXES-ALL: auto [another_x, another_y] = getPair<int, int>();
93+
int another_x = another_p.first;
94+
int another_y = another_p.second; // REMOVE
95+
// CHECK-FIXES-ALL: // REMOVE
96+
}
8097
}
8198

8299
void forRangeWarnCases() {

0 commit comments

Comments
 (0)