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

Gedare Bloom via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 5 13:12:47 PDT 2023


gedare added a comment.

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

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

Got it. I can prepare a change to merge null as a short loop. I will get back to this in a couple weeks.


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