[cfe-commits] [PATCH][PR11329][v3] Generalize -Wempty-body: warn when statement body is a empty
Dmitri Gribenko
gribozavr at gmail.com
Wed Jan 4 17:10:27 PST 2012
Hello,
Attached is a patch that implements enhancement proposed in PR11329.
Thanks to the reviewers' comments, I've implemented the following
heuristic. For and while with null statement as a body should be
followed by a CompoundStmt in order to emit a warning. This turned
out to be sufficient to silence all warnings in llvm and clang
codebase. Fixes to the testsuite are also reduced.
I've measured clang self-build time with and without the patch, time
difference is on order of measurement error.
Commit message:
Generalize -Wempty-body to warn about empty body in for, range-based
for, while and switch statements.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generalize-warn-empty-body-v3.patch
Type: text/x-diff
Size: 16372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120105/9dc981fa/attachment.patch>
More information about the cfe-commits
mailing list