[PATCH] D94500: Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

Tim Wojtulewicz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 27 15:36:03 PST 2021


timwoj added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2967
+  // needs to be indented.
+  bool ClosesBlock =
+      Line->MatchingOpeningBlockLineIndex != UnwrappedLine::kInvalidIndex &&
----------------
curdeius wrote:
> Please move below to the place of use. Also, just naming it `ClosesBlock` is a bit misleading as it is only for Whitesmiths style.
I agree with renaming it, but I'm not sure on moving it to where it's used. It relies on `Line->MatchingOpeningBlockLineIndex` which is reset shortly after this boolean value is calculated.


================
Comment at: clang/unittests/Format/FormatTest.cpp:13688
 
-  WhitesmithsBraceStyle.IndentCaseBlocks = true;
+  WhitesmithsBraceStyle.IndentCaseLabels = true;
   verifyFormat("void switchTest1(int a)\n"
----------------
curdeius wrote:
> Hmm, you don't test the same thing anymore...
This change was intentional. According to the clang-format documentation, `IndentCaseBlocks` effectively just changes the brace breaking for the block after a case label. Given that it always breaks for Whitesmiths, `IndentCaseBlocks` can be effectively ignored for that style. I changed it to test the `IndentCaseLabels` instead because that tests indentation for the whole block.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500



More information about the cfe-commits mailing list