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. https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching <quote> Empty loop bodies should use either an empty pair of braces or continue with no braces, rather than a single semicolon. while (condition) {} // Good - `{}` indicates no logic. while (condition) { // Comments are okay, too } while (condition) continue; // Good - `continue` indicates no logic. while (condition); // Bad - looks like part of `do-while` loop. 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