[cfe-commits] [PATCH][PR11329][v6] Generalize -Wempty-body: warn when statement body is empty

Dmitri Gribenko gribozavr at gmail.com
Sun Jan 15 06:00:50 PST 2012

On Wed, Jan 11, 2012 at 1:53 AM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
> On Jan 10, 2012, at 3:33 PM, Argyrios Kyrtzidis wrote:
>> How about at least setting a flag to indicate if an empty while/for was encountered, and if not, skip the traversing of statements altogether ?

I think that we would need a stack of flags, or am I misunderstanding
you?  For example:

void foo() {
__for(...); // flag set
__if(...) {
____while(...); // the same flag set
__} // ActOnCompoundStatement checks the flag, checks statements,
emits the warning about `while', clears flag
} // ActOnCompoundStatement finds that flag is cleared => `for' warning is lost

>> And before setting the flag, check if the warning is disabled at that source location, which means no check is necessary at all.

This makes sense to me, but I couldn't find how to check (from Sema)
if warning is enabled.  Could you give me a pointer?

Here's an improved version of the patch with helper methods moved to


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generalize-warn-empty-body-v6.patch
Type: text/x-diff
Size: 20537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120115/b1fba7ec/attachment.patch>

More information about the cfe-commits mailing list