summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs/clang-tidy
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2016-02-12 15:09:05 +0000
committerAaron Ballman <aaron@aaronballman.com>2016-02-12 15:09:05 +0000
commitf034a8c7d7719d9be6c775bb74afc97a88238ba4 (patch)
treed408ca68558947eb48894f0033a9d2725085cd84 /clang-tools-extra/docs/clang-tidy
parent8e57697cfd75ec590307267128456a30707156af (diff)
downloadbcm5719-llvm-f034a8c7d7719d9be6c775bb74afc97a88238ba4.tar.gz
bcm5719-llvm-f034a8c7d7719d9be6c775bb74afc97a88238ba4.zip
Reapply r260096.
Expand the simplify boolean expression check to handle implicit conversion of integral types to bool and improve the handling of implicit conversion of member pointers to bool. Implicit conversion of member pointers are replaced with explicit comparisons to nullptr. Implicit conversions of integral types are replaced with explicit comparisons to 0. Patch by Richard Thomson. llvm-svn: 260681
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy')
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst11
1 files changed, 7 insertions, 4 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst b/clang-tools-extra/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
index 4c3a1c8f8ce..c3c111961fb 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst
@@ -35,11 +35,14 @@ The resulting expression ``e`` is modified as follows:
2. Negated applications of ``!`` are eliminated.
3. Negated applications of comparison operators are changed to use the
opposite condition.
- 4. Implicit conversions of pointer to ``bool`` are replaced with explicit
- comparisons to ``nullptr``.
+ 4. Implicit conversions of pointers, including pointers to members, to
+ ``bool`` are replaced with explicit comparisons to ``nullptr`` in C++11
+ or ``NULL`` in C++98/03.
5. Implicit casts to ``bool`` are replaced with explicit casts to ``bool``.
6. Object expressions with ``explicit operator bool`` conversion operators
are replaced with explicit casts to ``bool``.
+ 7. Implicit conversions of integral types to ``bool`` are replaced with
+ explicit comparisons to ``0``.
Examples:
1. The ternary assignment ``bool b = (i < 0) ? true : false;`` has redundant
@@ -60,11 +63,11 @@ Examples:
The ternary assignment ``bool b = (i & 1) ? true : false;`` has an
implicit conversion of ``i & 1`` to ``bool`` and becomes
- ``bool b = static_cast<bool>(i & 1);``.
+ ``bool b = (i & 1) != 0;``.
5. The conditional return ``if (i & 1) return true; else return false;`` has
an implicit conversion of an integer quantity ``i & 1`` to ``bool`` and
- becomes ``return static_cast<bool>(i & 1);``
+ becomes ``return (i & 1) != 0;``
6. Given ``struct X { explicit operator bool(); };``, and an instance ``x`` of
``struct X``, the conditional return ``if (x) return true; return false;``
OpenPOWER on IntegriCloud