| 1 |
.. title:: clang-tidy - readability-redundant-control-flow |
| 2 |
|
| 3 |
readability-redundant-control-flow |
| 4 |
================================== |
| 5 |
|
| 6 |
This check looks for procedures (functions returning no value) with ``return`` |
| 7 |
statements at the end of the function. Such ``return`` statements are redundant. |
| 8 |
|
| 9 |
Loop statements (``for``, ``while``, ``do while``) are checked for redundant |
| 10 |
``continue`` statements at the end of the loop body. |
| 11 |
|
| 12 |
Examples: |
| 13 |
|
| 14 |
The following function `f` contains a redundant ``return`` statement: |
| 15 |
|
| 16 |
.. code-block:: c++ |
| 17 |
|
| 18 |
extern void g(); |
| 19 |
void f() { |
| 20 |
g(); |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
becomes |
| 25 |
|
| 26 |
.. code-block:: c++ |
| 27 |
|
| 28 |
extern void g(); |
| 29 |
void f() { |
| 30 |
g(); |
| 31 |
} |
| 32 |
|
| 33 |
The following function `k` contains a redundant ``continue`` statement: |
| 34 |
|
| 35 |
.. code-block:: c++ |
| 36 |
|
| 37 |
void k() { |
| 38 |
for (int i = 0; i < 10; ++i) { |
| 39 |
continue; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
becomes |
| 44 |
|
| 45 |
.. code-block:: c++ |
| 46 |
|
| 47 |
void k() { |
| 48 |
for (int i = 0; i < 10; ++i) { |
| 49 |
} |
| 50 |
} |