[PATCH] D126157: [clang-format][NFC] Insert/remove braces in clang/lib/Format/

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 23 14:17:31 PDT 2022


owenpan added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2769
 
-  if (Style.isCSharp()) {
     do {
----------------
>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`?


================
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;
----------------
It would be nice to remove the braces of the `else` here. See https://github.com/llvm/llvm-project/issues/55663.


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