Debian Codegraph @

llvm-project/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 The check implements
11 `rule ES.75 of C++ Core Guidelines <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-do>`_.
12
13 Examples:
14
15 .. code-block:: c++
16
17 int x;
18 do {
19 std::cin >> x;
20 // ...
21 } while (x < 0);
22
23 Options
24 -------
25
26 .. option:: IgnoreMacros
27
28 Ignore the check when analyzing macros. This is useful for safely defining function-like macros:
29
30 .. code-block:: c++
31
32 #define FOO_BAR(x) \
33 do { \
34 foo(x); \
35 bar(x); \
36 } while(0)
37
38 Defaults to `false`.