diff clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 1d019706d866
children c4bab56944e8
line wrap: on
line diff
--- a/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp	Tue Jun 15 19:13:43 2021 +0900
+++ b/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp	Tue Jun 15 19:15:29 2021 +0900
@@ -32,16 +32,15 @@
 
 void RedundantControlFlowCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-      functionDecl(
-          isDefinition(), returns(voidType()),
-          has(compoundStmt(hasAnySubstatement(returnStmt(unless(has(expr())))))
-                  .bind("return"))),
+      functionDecl(isDefinition(), returns(voidType()),
+                   hasBody(compoundStmt(hasAnySubstatement(
+                                            returnStmt(unless(has(expr())))))
+                               .bind("return"))),
       this);
-  auto CompoundContinue =
-      has(compoundStmt(hasAnySubstatement(continueStmt())).bind("continue"));
   Finder->addMatcher(
-      stmt(anyOf(forStmt(), cxxForRangeStmt(), whileStmt(), doStmt()),
-           CompoundContinue),
+      mapAnyOf(forStmt, cxxForRangeStmt, whileStmt, doStmt)
+          .with(hasBody(compoundStmt(hasAnySubstatement(continueStmt()))
+                            .bind("continue"))),
       this);
 }
 
@@ -55,16 +54,16 @@
 
 void RedundantControlFlowCheck::checkRedundantReturn(
     const MatchFinder::MatchResult &Result, const CompoundStmt *Block) {
-  CompoundStmt::const_reverse_body_iterator last = Block->body_rbegin();
-  if (const auto *Return = dyn_cast<ReturnStmt>(*last))
+  CompoundStmt::const_reverse_body_iterator Last = Block->body_rbegin();
+  if (const auto *Return = dyn_cast<ReturnStmt>(*Last))
     issueDiagnostic(Result, Block, Return->getSourceRange(),
                     RedundantReturnDiag);
 }
 
 void RedundantControlFlowCheck::checkRedundantContinue(
     const MatchFinder::MatchResult &Result, const CompoundStmt *Block) {
-  CompoundStmt::const_reverse_body_iterator last = Block->body_rbegin();
-  if (const auto *Continue = dyn_cast<ContinueStmt>(*last))
+  CompoundStmt::const_reverse_body_iterator Last = Block->body_rbegin();
+  if (const auto *Continue = dyn_cast<ContinueStmt>(*Last))
     issueDiagnostic(Result, Block, Continue->getSourceRange(),
                     RedundantContinueDiag);
 }