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

Dmitri Gribenko gribozavr at gmail.com
Tue Jan 10 12:41:19 PST 2012

On Tue, Jan 10, 2012 at 8:57 PM, Anna Zaks <ganna at apple.com> wrote:
> Here is one way to implement it (suggestion by Argyrios). You can store a
> member variable inside Sema to flag if potential warning is diagnosed. When
> processing the next statement in ActOnExprStmt, you can check the identation
> and make the final decision.

I think it would actually complicate the code because someone should
be clearing that flag (and when? -- mutable state is not good...).
And we will need to add checks not only to ActOnExprStmt, but also to
ActOnCompoundStmt (to warn on for();{}).  This would spread the logic
for a single warning over many functions, is it really worth doing?

Moving cheaper checks first: done:
Factoring out a function: done.


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

More information about the cfe-commits mailing list