[PATCH] D133589: [clang-format] JSON formatting add new option for controlling newlines in json arrays

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 12 00:27:27 PDT 2022


owenpan accepted this revision.
owenpan added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:4403-4404
+    // Always break after a JSON array opener based on BreakArrays.
     if (Left.is(TT_ArrayInitializerLSquare) && Left.is(tok::l_square) &&
-        !Right.is(tok::r_square)) {
-      return true;
+            Right.isNot(tok::r_square) ||
+        Left.is(tok::comma)) {
----------------
The compiler will warn without the extra pair of parentheses?


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:4427
+    if (Left.is(tok::comma)) {
+      if (Right.is(tok::l_brace)) {
+        return true;
----------------
MyDeveloperDay wrote:
> curdeius wrote:
> > You can elide braces here.
> This was funny I had RemoveBracesLLVM on, but it didn't get rid of them automatically, I wonder if this was my fault or if we are missing a case for the RemoveBraces option, but thanks you be done now
@MyDeveloperDay I'm very curious about this. Can you open an issue if it can be reproduced?


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

https://reviews.llvm.org/D133589



More information about the cfe-commits mailing list