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