[cfe-commits] [Patch] Add a warning for for loops with conditions that do not change
Richard Trieu
rtrieu at google.com
Mon Feb 6 13:55:34 PST 2012
The motivation of this path is to catch code like this:
for (int i = 0; i < 10; ++i)
for (int j = 0; j < 10; ++i)
{ }
The second for loop increments i instead of j causing an infinite loop.
The warning also checks the body of the for loop so it will trigger on:
for (int i; i <10; ) { }
But not trigger on:
for (int i; i< 10; ) { ++i; }
I'm still fine-tuning the trigger conditions, but would like some feedback
on this patch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120206/5c0b07c5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop-analysis.patch
Type: text/x-patch
Size: 7129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120206/5c0b07c5/attachment.bin>
More information about the cfe-commits
mailing list