[PATCH] Add readability-simplify-boolean-expr check to clang-tidy

Richard legalize at xmission.com
Sat Feb 14 16:03:51 PST 2015


Hi alexfh,

This check looks for comparisons between boolean expressions and boolean constants and simplifies them to just use the appropriate boolean expression directly.

`if (b == true)` becomes `if (b)`
`if (b == false)` becomes `if (!b)`
`if (b && true)` becomes `if (b)`
`if (b && false)` becomes `if (false)`
`if (b || true)` becomes `if (true)`
`if (b || false)` becomes `if (b)`
`e ? true : false` becomes `e`
`e ? false : true` becomes `!e`
`if (true) t(); else f();` becomes `t();`
`if (false) t(); else f();` becomes `f();`

http://reviews.llvm.org/D7648

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SimplifyBooleanExpr.cpp
  clang-tidy/readability/SimplifyBooleanExpr.h
  test/clang-tidy/readability-simplify-bool-expr.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7648.19976.patch
Type: text/x-patch
Size: 28417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150215/13a48f9a/attachment.bin>


More information about the cfe-commits mailing list