Debian Codegraph @

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-do-while.rst

raw
1 .. title:: clang-tidy - cppcoreguidelines-avoid-do-while
2
3 cppcoreguidelines-avoid-do-while
4 ================================
5
6 Warns when using ``do-while`` loops. They are less readable than plain ``while``
7 loops, since the termination condition is at the end and the condition is not
8 checked prior to the first iteration. This can lead to subtle bugs.
9
10 This check implements `ES.75
11 <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-do>`_
12 from the C++ Core Guidelines.
13
14 Examples:
15
16 .. code-block:: c++
17
18 int x;
19 do {
20 std::cin >> x;
21 // ...
22 } while (x < 0);
23
24 Options
25 -------
26
27 .. option:: IgnoreMacros
28
29 Ignore the check when analyzing macros. This is useful for safely defining function-like macros:
30
31 .. code-block:: c++
32
33 #define FOO_BAR(x) \
34 do { \
35 foo(x); \
36 bar(x); \
37 } while(0)
38
39 Defaults to `false`.