[PATCH] D154550: [clang-format] Allow empty loops on a single line.

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 4 15:10:20 PDT 2023


owenpan added a comment.

In D154550#4529346 <https://reviews.llvm.org/D154550#4529346>, @gedare wrote:

> 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.

LLVM doesn't merge short loops. Google uses `{}` instead of `;` whereas AFAIK K&R does the opposite. I don't know of any major style that requires breaking before the null statement and merging the empty block.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154550



More information about the cfe-commits mailing list