diff options
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy/checks/misc-redundant-expression.rst')
-rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/misc-redundant-expression.rst | 20 |
1 files changed, 20 insertions, 0 deletions
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 |