| 1 |
.. title:: clang-tidy - misc-redundant-expression |
| 2 |
|
| 3 |
misc-redundant-expression |
| 4 |
========================= |
| 5 |
|
| 6 |
Detect redundant expressions which are typically errors due to copy-paste. |
| 7 |
|
| 8 |
Depending on the operator expressions may be |
| 9 |
|
| 10 |
- redundant, |
| 11 |
|
| 12 |
- always ``true``, |
| 13 |
|
| 14 |
- always ``false``, |
| 15 |
|
| 16 |
- always a constant (zero or one). |
| 17 |
|
| 18 |
Examples: |
| 19 |
|
| 20 |
.. code-block:: c++ |
| 21 |
|
| 22 |
((x+1) | (x+1)) // (x+1) is redundant |
| 23 |
(p->x == p->x) // always true |
| 24 |
(p->x < p->x) // always false |
| 25 |
(speed - speed + 1 == 12) // speed - speed is always zero |