[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 20 17:06:55 PST 2022


owenpan added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2449
     } else {
-      addUnwrappedLine();
-      ++Line->Level;
-      parseStructuralElement();
-      if (FormatTok->is(tok::eof))
-        addUnwrappedLine();
-      --Line->Level;
+      parseUnbracedBody(/*CheckEOF=*/true);
     }
----------------
curdeius wrote:
> Is it possible to get rid of the `CheckEOF` parameter and do `if (FormatTok->is(tok::eof)) addUnwrappedLine();` only here?
> (I'm unsure about the dependency between `Line` and `addUnwrappedLine`)
Unfortunately, no. Decrementing `Line->Level` before calling `addUnwrappedLine()` would fail `MacroDefinitionsWithIncompleteCode` in `FormatTest.cpp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120217



More information about the cfe-commits mailing list