[PATCH] D53974: [clang-tidy] new check: bugprone-too-small-loop-variable
Tamás Zolnai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 5 12:25:41 PST 2018
ztamas added inline comments.
================
Comment at: clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp:142
+ if (LoopVar->getType() != LoopIncrement->getType())
+ return; // We matched the loop variable incorrectly
+
----------------
JonasToth wrote:
> Does this try to ensure a precondition? Then it should become an assertion instead.
> Please adjust the comment like above (punctuation, position)
It's not an assumed precondition. This `if` handles the case when LoopVarMatcher is not fitted with the actual loop variable. That's why the IncrementMatcher is there so we can check whether we found the loop variable.
See voidForLoopReverseCond() test case which hits this `if` branch.
I did not find a solution to handle this check inside the matcher.
================
Comment at: docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst:10
+
+ .. code-block:: c++
+
----------------
JonasToth wrote:
> the `.. code-block:: c++` is usually not indended, only the code itself.
Hmm, I copied this from somewhere. It might be a good idea to make this consistent across all the *.rst files. See bugprone-suspicious-semicolon.rst or bugprone-use-after-move.rst for example.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D53974
More information about the cfe-commits
mailing list