<div class="gmail_quote">On Mon, Feb 6, 2012 at 2:02 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Mon, Feb 6, 2012 at 1:55 PM, Richard Trieu <<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>> wrote:<br>
> The motivation of this path is to catch code like this:<br>
><br>
> for (int i = 0; i < 10; ++i)<br>
>   for (int j = 0; j < 10; ++i)<br>
>     { }<br>
><br>
> The second for loop increments i instead of j causing an infinite loop.  The<br>
> warning also checks the body of the for loop so it will trigger on:<br>
><br>
> for (int i; i <10; ) { }<br>
><br>
> But not trigger on:<br>
><br>
> for (int i; i< 10; ) { ++i; }<br>
><br>
> I'm still fine-tuning the trigger conditions, but would like some feedback<br>
> on this patch.<br>
<br>
</div></div>Adding an additional recursive traversal of the body of every parsed<br>
for loop is very expensive.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Eli<br>
</font></span></blockquote></div><div><br></div>Is it that expensive?  I would think that once the AST was constructed, the visitor would be pretty fast, especially if no action is taken on most of the nodes.  I also made the warning default ignore and put in an early return to prevent the visitors from running in the default case.<div>
<br></div><div>Do you have any suggestions on removing the recursive traversal?</div>