[PATCH] D23265: [clang-tidy] enhance readability-else-after-return

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 9 08:10:36 PDT 2016


alexfh requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: clang-tidy/readability/ElseAfterReturnCheck.cpp:25
@@ +24,3 @@
+          forEach(ifStmt(hasThen(stmt(anyOf(
+                             returnStmt().bind("return"),
+                             compoundStmt(has(returnStmt().bind("return"))),
----------------
Let's structure this differently to reduce code duplication:

  auto returnLikeStmt = stmt(anyOf(returnStmt().bind("return"), continueStmt().bind("continue"), ...));
  Finder->addMatcher(stmt(forEach(ifStmt(hasThen(anyOf(returnLikeStmt, compoundStmt(has(returnLikeStmt)))), hasElse(...


https://reviews.llvm.org/D23265





More information about the cfe-commits mailing list