[PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

Richard via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 20 09:14:40 PST 2016


LegalizeAdulthood added inline comments.

================
Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:77
@@ -74,3 +76,3 @@
 ///      implicit conversion of `i & 1` to `bool` and becomes
-///      `bool b = static_cast<bool>(i & 1);`.
+///      `bool b = i & 1 != 0;`.
 ///
----------------
aaron.ballman wrote:
> LegalizeAdulthood wrote:
> > aaron.ballman wrote:
> > > To me, this does not improve readability -- I now have to think much harder about operator precedence. Including parens would help significantly, IMO, so that it becomes `(i & 1) != 0`.
> > To clarify: You'd like to see parens around the expression when it is a binary operator, correct?
> > 
> > When it is a variable, there's no need to add parentheses.
> Correct; if it's just a DeclRefExpr or unary operator then parens aren't useful; but if it's a binary operator, I think parens may help clarify.
Ironically, in another review we were talking about eliminating redundant parentheses globally and these parentheses added for binary operators would be considered redundant and removed.


http://reviews.llvm.org/D16308





More information about the cfe-commits mailing list