Skip to content

Commit 242316e

Browse files
committed
Exit for std::tie case when DS1 has multi child decl
1 parent 00285d9 commit 242316e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ AST_MATCHER_P2(Stmt, hasPreTwoVarDecl, ast_matchers::internal::Matcher<VarDecl>,
110110
const DeclStmt *DS1 = (!DS2->isSingleDecl() || ((I + 2) == C->body_rend())
111111
? nullptr
112112
: dyn_cast<DeclStmt>(*(I + 2)));
113+
if (DS1 && !DS1->isSingleDecl())
114+
return false;
113115

114116
if (matchTwoVarDecl(DS1, DS2, InnerMatcher1, InnerMatcher2, Finder,
115117
Builder)) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ void stdTieNotWarnCases() {
230230
a = 4;
231231
std::tie(a, b) = getPair<int, int>(); // no warning
232232

233+
int c = 0, d = 0;
234+
int e = 0;
235+
std::tie(a, b) = getPair<int, int>(); // no warning
236+
233237
int* pa = nullptr;
234238
int* pb = nullptr;
235239
MarkUsed(pa);

0 commit comments

Comments
 (0)