[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
Fri Jan 29 20:59:02 PST 2016


LegalizeAdulthood marked 2 inline comments as done.

================
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:
> Perhaps a different idea regarding parens isn't to add/remove parens in various checks for readability, but instead have two readability checks that do different things (both disabled by default?): (1) remove spurious parens where the presence of the parens has no effect on the order of evaluation of the subexpressions, and (2) add parens where there is an operator precedence difference between the operators of two subexpressions. Both of these checks are at odds with one another (which is why I don't think it makes sense to enable them by default), but both certainly seem like they would be useful.
> 
> Thoughts on the general idea (not trying to sign either of us up for work to implement it)?
I'm of two minds on this, I'm not really coming down hard on either side.  It feels like there should be a readability check for removing parenthesis to consolidate the heuristics all in one place and that check can in turn be configured by parameters.


http://reviews.llvm.org/D16308





More information about the cfe-commits mailing list