Skip to content

Commit 5a3799e

Browse files
committed
[NFC] cleanup
1 parent 0b007e8 commit 5a3799e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static bool matchNVarDeclStartingWith(
5555
BeginDS = EndDS;
5656

5757
auto Matches = [&](const Decl *VD) {
58+
// We don't want redundant decls in DeclStmt.
5859
if (Count == N)
5960
return false;
6061

@@ -113,7 +114,7 @@ AST_MATCHER_P(Stmt, hasPreTwoVarDecl,
113114
if (Parents.size() != 1)
114115
return false;
115116

116-
auto *C = Parents[0].get<CompoundStmt>();
117+
const auto *C = Parents[0].get<CompoundStmt>();
117118
if (!C)
118119
return false;
119120

@@ -128,12 +129,11 @@ AST_MATCHER_P(Stmt, hasPreTwoVarDecl,
128129
AST_MATCHER_P(Stmt, hasNextTwoVarDecl,
129130
llvm::SmallVector<ast_matchers::internal::Matcher<VarDecl>>,
130131
InnerMatchers) {
131-
132132
const DynTypedNodeList Parents = Finder->getASTContext().getParents(Node);
133133
if (Parents.size() != 1)
134134
return false;
135135

136-
auto *C = Parents[0].get<CompoundStmt>();
136+
const auto *C = Parents[0].get<CompoundStmt>();
137137
if (!C)
138138
return false;
139139

@@ -274,7 +274,8 @@ void UseStructuredBindingCheck::registerMatchers(MatchFinder *Finder) {
274274
hasType(qualType(anyOf(PairType, lValueReferenceType(
275275
pointee(PairType))))
276276
.bind(PairVarTypeName)),
277-
hasInitializer(expr(ignoringCopyCtorAndImplicitCast(expr().bind(InitExprName)))))
277+
hasInitializer(expr(ignoringCopyCtorAndImplicitCast(
278+
expr().bind(InitExprName)))))
278279
.bind(PairDeclName)),
279280
hasNextTwoVarDecl(
280281
llvm::SmallVector<ast_matchers::internal::Matcher<VarDecl>>{
@@ -294,7 +295,8 @@ void UseStructuredBindingCheck::registerMatchers(MatchFinder *Finder) {
294295
varDecl(hasType(qualType(anyOf(PairType, lValueReferenceType(
295296
pointee(PairType))))
296297
.bind(PairVarTypeName)),
297-
hasInitializer(expr(ignoringCopyCtorAndImplicitCast(expr().bind(InitExprName)))))
298+
hasInitializer(expr(ignoringCopyCtorAndImplicitCast(
299+
expr().bind(InitExprName)))))
298300
.bind(PairDeclName)),
299301
hasBody(
300302
compoundStmt(
@@ -376,10 +378,10 @@ void UseStructuredBindingCheck::check(const MatchFinder::MatchResult &Result) {
376378
// Check whether PairVar, FirstVar and SecondVar have the same transfer type,
377379
// so they can be combined to structured binding.
378380
const auto *PairVar = Result.Nodes.getNodeAs<VarDecl>(PairDeclName);
379-
const Expr *InitE = Result.Nodes.getNodeAs<Expr>(InitExprName);
380381

381382
const std::optional<TransferType> PairCaptureType =
382-
getTransferType(*Result.Context, PairVar->getType(), InitE->getType());
383+
getTransferType(*Result.Context, PairVar->getType(),
384+
Result.Nodes.getNodeAs<Expr>(InitExprName)->getType());
383385
const std::optional<TransferType> FirstVarCaptureType =
384386
getTransferType(*Result.Context, FirstVar->getType(),
385387
*Result.Nodes.getNodeAs<QualType>(FirstTypeName));

0 commit comments

Comments
 (0)