[PATCH] Enhance clang-tidy readability-simplify-boolean-expr to handle 'if (e) return true; return false; ' and improve replacement expressions.

Richard legalize at xmission.com
Fri Jun 5 22:32:57 PDT 2015


================
Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:554
@@ +553,3 @@
+  CompoundStmt::const_body_iterator After = Compound->body_begin();
+  for (++After; After != Compound->body_end() && *Current != Ret;
+       ++Current, ++After) {
----------------
alexfh wrote:
> Can the body be empty? If not, I'd document this (e.g. using an assert()).
The body can't be empty because the matcher ensures that it must contain at least two statements:

  - A `return` statement returning a boolean literal `false` or `true`
  - An `if` statement with no `else` clause and a then clause that consists of a single `return` statement returning the opposite boolean literal `true` or `false`

http://reviews.llvm.org/D9810

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list