[PATCH] D16259: Add clang-tidy readability-redundant-control-flow check
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 25 07:20:21 PST 2016
aaron.ballman added inline comments.
================
Comment at: clang-tidy/readability/RedundantControlFlowCheck.cpp:24
@@ +23,3 @@
+const char *const RedundantReturnDiag =
+ "redundant return statement at the end of void function";
+const char *const RedundantContinueDiag =
----------------
void function -> function with a void return type.
================
Comment at: clang-tidy/readability/RedundantControlFlowCheck.cpp:45
@@ +44,3 @@
+ Finder->addMatcher(whileStmt(CompoundContinue), this);
+ Finder->addMatcher(doStmt(CompoundContinue), this);
+}
----------------
Instead of adding four different matchers, it would be better to add one matcher with anyOf(). e.g.,
```
Finder->addMatcher(stmt(anyOf(forStmt(), whileStmt(), doStmt(), cxxForRangeStmt()), has(compoundStmt(hasAnySubstatement(continueStmt())))), this);
```
================
Comment at: clang-tidy/readability/RedundantControlFlowCheck.cpp:59
@@ +58,3 @@
+ CompoundStmt::const_reverse_body_iterator last = Block->body_rbegin();
+ if (const auto *Return = dyn_cast<ReturnStmt>(*last)) {
+ issueDiagnostic(Result, Block, Return->getSourceRange(),
----------------
Elide braces.
================
Comment at: clang-tidy/readability/RedundantControlFlowCheck.cpp:68
@@ +67,3 @@
+ CompoundStmt::const_reverse_body_iterator last = Block->body_rbegin();
+ if (const auto *Continue = dyn_cast<ContinueStmt>(*last)) {
+ issueDiagnostic(Result, Block, Continue->getSourceRange(),
----------------
Elide braces
http://reviews.llvm.org/D16259
More information about the cfe-commits
mailing list