xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-control-flow.rst (revision 6e566bc5523f743bc34a7e26f050f1f2b4d699a8)
1.. title:: clang-tidy - readability-redundant-control-flow
2
3readability-redundant-control-flow
4==================================
5
6This check looks for procedures (functions returning no value) with ``return``
7statements at the end of the function. Such ``return`` statements are redundant.
8
9Loop statements (``for``, ``while``, ``do while``) are checked for redundant
10``continue`` statements at the end of the loop body.
11
12Examples:
13
14The 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
24becomes
25
26.. code-block:: c++
27
28  extern void g();
29  void f() {
30    g();
31  }
32
33The 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
43becomes
44
45.. code-block:: c++
46
47  void k() {
48    for (int i = 0; i < 10; ++i) {
49    }
50  }
51