diff options
Diffstat (limited to 'clang-tools-extra/docs')
-rw-r--r-- | clang-tools-extra/docs/ReleaseNotes.rst | 5 | ||||
-rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/list.rst | 1 | ||||
-rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/misc-redundant-expression.rst | 20 |
3 files changed, 26 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 6c25069d0cc..b7273a3e05d 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -113,6 +113,11 @@ identified. The improvements since the 3.8 release include: Warns about suspicious operations involving pointers and integral types. +- New `misc-redundant-expression + <http://clang.llvm.org/extra/clang-tidy/checks/misc-redundant-expression.html>`_ check + + Warns about redundant and equivalent expressions. + - New `misc-sizeof-expression <http://clang.llvm.org/extra/clang-tidy/checks/misc-sizeof-expression.html>`_ check diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index db31a73fbba..113b341add2 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -67,6 +67,7 @@ Clang-Tidy Checks misc-noexcept-move-constructor misc-non-copyable-objects misc-pointer-and-integral-operation + misc-redundant-expression misc-sizeof-container misc-sizeof-expression misc-static-assert diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-redundant-expression.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-redundant-expression.rst new file mode 100644 index 00000000000..812031d91b2 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/misc-redundant-expression.rst @@ -0,0 +1,20 @@ +.. title:: clang-tidy - misc-redundant-expression + +misc-redundant-expression +========================= + +Detect redundant expressions which are typically errors due to copy-paste. + +Depending on the operator expressions may be + * redundant, + * always be `true`, + * always be `false`, + * always be a constant (zero or one) + +Example: +.. code:: c++ + + ((x+1) | (x+1)) // (x+1) is redundant + (p->x == p->x) // always true + (p->x < p->x) // always false + (speed - speed + 1 == 12) // speed - speed is always zero |