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

Richard legalize at xmission.com
Sun May 24 13:40:58 PDT 2015


In http://reviews.llvm.org/D9810#174289, @LegalizeAdulthood wrote:

> In http://reviews.llvm.org/D9810#174276, @LegalizeAdulthood wrote:
>
> > It all compiles, but manual testing with clang-query shows the problem.  See https://llvm.org/bugs/show_bug.cgi?id=23552 for details.
>
>
> There's also the possibility that it's something I messed up in my tree.  I'd like to see if anyone else can reproduce the clang-query session in the attachment on that bug.


OK, ditched everything and rebuilt from master on llvm, clang and clang-tools-extra and got the same results.  clang-query v. 3.5 clearly dumps out two ifStmt nodes, while the trunk version only dumps out one.

Trunk also dumps out puke about not being able to find <stddef.h> for every single file I analyze.  clang-query v. 3.5 doesn't issue any such complaining.

make check-clang passes all tests.


================
Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:77
@@ -69,4 +76,3 @@
 
-internal::Matcher<Stmt> ReturnsBool(bool Value, StringRef Id = "") {
-  auto SimpleReturnsBool = returnStmt(
-      has(boolLiteral(equals(Value)).bind(Id.empty() ? "ignored" : Id)));
+internal::Matcher<Stmt> returnsBool(bool Value, StringRef Id = "") {
+  auto SimpleReturnsBool =
----------------
alexfh wrote:
> Why not make the default value "ignored" and remove the ternary below?
Fixed.

http://reviews.llvm.org/D9810

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






More information about the cfe-commits mailing list