diff options
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy')
-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 |
2 files changed, 21 insertions, 0 deletions
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 |