[PATCH] D126157: [clang-format][NFC] Insert/remove braces in clang/lib/Format/
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 23 14:37:13 PDT 2022
curdeius added inline comments.
================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2769
- if (Style.isCSharp()) {
do {
----------------
owenpan wrote:
> From https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements, it's unclear whether the braces should be removed when a block has a do-while loop as its single statement. Should I put the braces back and add handling of do-while for `RemoveBracesLLVM`?
It's indeed not clear, I remember having paused over this code for a moment.
I believe that the best course of action is to grep for both cases in the codebase and see what's more frequent (and whether there's some sort of consensus).
================
Comment at: clang/lib/Format/WhitespaceManager.cpp:231-239
+ if (Change.Tok->is(TT_LineComment) || !Change.IsInsideToken) {
LastBlockComment = &Change;
- else {
- if ((Change.StartOfBlockComment = LastBlockComment))
+ } else {
+ if ((Change.StartOfBlockComment = LastBlockComment)) {
Change.IndentationOffset =
Change.StartOfTokenColumn -
Change.StartOfBlockComment->StartOfTokenColumn;
----------------
owenpan wrote:
> It would be nice to remove the braces of the `else` here. See https://github.com/llvm/llvm-project/issues/55663.
+1. Would you fix it manually here then and fix it later?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126157/new/
https://reviews.llvm.org/D126157
More information about the cfe-commits
mailing list