summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-control-flow.rst
blob: 64f561c6e536e2ab25c75a21d8d6600457d439d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
.. title:: clang-tidy - readability-redundant-control-flow

readability-redundant-control-flow
==================================

This check looks for procedures (functions returning no value) with ``return``
statements at the end of the function.  Such ``return`` statements are
redundant.

Loop statements (``for``, ``while``, ``do while``) are checked for redundant
``continue`` statements at the end of the loop body.

Examples:

The following function `f` contains a redundant `return` statement:

.. code:: c++

  extern void g();
  void f() {
    g();
    return;
  }

becomes

.. code:: c++

  extern void g();
  void f() {
    g();
  }

The following function `k` contains a redundant `continue` statement:

.. code:: c++

  void k() {
    for (int i = 0; i < 10; ++i) {
      continue;
    }
  }

becomes

.. code:: c++

  void k() {
    for (int i = 0; i < 10; ++i) {
    }
  }
OpenPOWER on IntegriCloud