1.. title:: clang-tidy - cppcoreguidelines-avoid-do-while 2 3cppcoreguidelines-avoid-do-while 4================================ 5 6Warns when using ``do-while`` loops. They are less readable than plain ``while`` 7loops, since the termination condition is at the end and the condition is not 8checked prior to the first iteration. This can lead to subtle bugs. 9 10This check implements `ES.75 11<https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-do>`_ 12from the C++ Core Guidelines. 13 14Examples: 15 16.. code-block:: c++ 17 18 int x; 19 do { 20 std::cin >> x; 21 // ... 22 } while (x < 0); 23 24Options 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`. 40