diff options
Diffstat (limited to 'docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst')
-rw-r--r-- | docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst b/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst index 7688a3a5..702541d8 100644 --- a/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst +++ b/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst @@ -27,3 +27,20 @@ In a real use case size means a container's size which depends on the user input This algorithm works for small amount of objects, but will lead to freeze for a a larger user input. + +.. option:: MagnitudeBitsUpperLimit + + Upper limit for the magnitude bits of the loop variable. If it's set the check + filters out those catches in which the loop variable's type has more magnitude + bits as the specified upper limit. The default value is 16. + For example, if the user sets this option to 31 (bits), then a 32-bit ``unsigend int`` + is ignored by the check, however a 32-bit ``int`` is not (A 32-bit ``signed int`` + has 31 magnitude bits). + +.. code-block:: c++ + + int main() { + long size = 294967296l; + for (unsigned i = 0; i < size; ++i) {} // no warning with MagnitudeBitsUpperLimit = 31 on a system where unsigned is 32-bit + for (int i = 0; i < size; ++i) {} // warning with MagnitudeBitsUpperLimit = 31 on a system where int is 32-bit + } |