[PATCH] D55964: [clang-format][TableGen] Don't add spaces around items in square braces.

Jordan Rupprecht via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 9 10:51:29 PST 2019


rupprecht updated this revision to Diff 180882.
rupprecht added a comment.

Move TableGen language check to where SpacesInContainerLiterals is checked


Repository:
  rC Clang

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

https://reviews.llvm.org/D55964

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestTableGen.cpp


Index: unittests/Format/FormatTestTableGen.cpp
===================================================================
--- unittests/Format/FormatTestTableGen.cpp
+++ unittests/Format/FormatTestTableGen.cpp
@@ -52,5 +52,9 @@
                "               \"very long help string\">;\n");
 }
 
+TEST_F(FormatTestTableGen, NoSpacesInSquareBracketLists) {
+  verifyFormat("def flag : Flag<[\"-\", \"--\"], \"foo\">;\n");
+}
+
 } // namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2486,12 +2486,13 @@
     return false;
   const auto SpaceRequiredForArrayInitializerLSquare =
       [](const FormatToken &LSquareTok, const FormatStyle &Style) {
-        return Style.SpacesInContainerLiterals ||
-               ((Style.Language == FormatStyle::LK_Proto ||
-                 Style.Language == FormatStyle::LK_TextProto) &&
-                !Style.Cpp11BracedListStyle &&
-                LSquareTok.endsSequence(tok::l_square, tok::colon,
-                                        TT_SelectorName));
+        return Style.Language != FormatStyle::LK_TableGen &&
+               (Style.SpacesInContainerLiterals ||
+                ((Style.Language == FormatStyle::LK_Proto ||
+                  Style.Language == FormatStyle::LK_TextProto) &&
+                 !Style.Cpp11BracedListStyle &&
+                 LSquareTok.endsSequence(tok::l_square, tok::colon,
+                                         TT_SelectorName)));
       };
   if (Left.is(tok::l_square))
     return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55964.180882.patch
Type: text/x-patch
Size: 1711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190109/206f5828/attachment.bin>


More information about the cfe-commits mailing list