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

Alexander Kornienko alexfh at google.com
Mon May 18 06:16:44 PDT 2015


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

> In http://reviews.llvm.org/D9810#173989, @LegalizeAdulthood wrote:
>
> > Testing this on LLVM/clang indicates that it turns valid code into invalid code, so I will need to address this first.  The problem appears that isFollowedBy is reporting `true` when it should not.
>
>
> This appears to be a regression somewhere outside of my changes.


So does LLVM/Clang compile and pass all tests after applying all fixes from this check?


================
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 =
----------------
Why not make the default value "ignored" and remove the ternary below?

http://reviews.llvm.org/D9810

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






More information about the cfe-commits mailing list