diff options
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy')
-rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst | 11 |
1 files changed, 4 insertions, 7 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 c3c111961fb..4c3a1c8f8ce 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,14 +35,11 @@ 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 pointers, including pointers to members, to - ``bool`` are replaced with explicit comparisons to ``nullptr`` in C++11 - or ``NULL`` in C++98/03. + 4. Implicit conversions of pointer to ``bool`` are replaced with explicit + comparisons to ``nullptr``. 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 @@ -63,11 +60,11 @@ Examples: The ternary assignment ``bool b = (i & 1) ? true : false;`` has an implicit conversion of ``i & 1`` to ``bool`` and becomes - ``bool b = (i & 1) != 0;``. + ``bool b = static_cast<bool>(i & 1);``. 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 (i & 1) != 0;`` + becomes ``return static_cast<bool>(i & 1);`` 6. Given ``struct X { explicit operator bool(); };``, and an instance ``x`` of ``struct X``, the conditional return ``if (x) return true; return false;`` |