[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 13:26:40 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
ztamas wrote:
> 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.
voidForLoopReverseCond()  was renamed to voidForLoopCondImplicitCast() in the mean time.

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list