gedare planned changes to this revision.
gedare added a comment.

In D154550#4526386 <https://reviews.llvm.org/D154550#4526386>, @owenpan wrote:

> Like `while (a);`, `while (a) {}` is also an empty loop, so `NonEmpty` is 
> misleading if it excludes the former but not the latter. IMO we should just 
> fix the bug without extending the option because any loop with a 
> single-statement body is a short loop.

Agreed, except that many style guides (notably, K&R, LLVM, and Google) treat 
these two cases differently. The loop with only a semi-colon is a special case, 
and is what I'm looking to support. K&R defines the semi-colon terminated 
for/while loop as a body composed of a //null statement//. I believe that `{ }` 
is instead an empty body, as it does not parse as a statement, despite 
generating identical code. Maybe`NonNullStatement` is precise and better than 
`NonEmpty`?  I will prepare that change, and fix the spacing before the `;`.

Whether someone thinks collapsing bracketed bodies that are short should be 
supported is a separate problem, and even if so, it would require a similar 
style option change as I suggest to allow for backward compatibility. I'm not 
personally interested in that case, as the code base I work with uses the 
isolated semicolon.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154550/new/

https://reviews.llvm.org/D154550

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to