[PATCH] D75182: [clang-format] Handle commas in [] in C#

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 27 09:48:00 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG548e540d2ced: [clang-format] Handle commas in [] in C# (authored by Jonathan Coe <jbcoe at google.com>).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75182

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===================================================================
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -595,6 +595,10 @@
   verifyFormat(R"(bool[] xs = { true, true };)", Style);
   verifyFormat(R"(taskContext.Factory.Run(async () => doThing(args);)", Style);
   verifyFormat(R"(catch (TestException) when (innerFinallyExecuted))", Style);
+  verifyFormat(R"(private float[,] Values;)", Style);
+
+  Style.SpacesInSquareBrackets = true;
+  verifyFormat(R"(private float[, ] Values;)", Style);
 }
 
 } // namespace format
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2893,6 +2893,10 @@
     if (Left.is(TT_TemplateCloser) && Right.is(TT_StartOfName))
       return true;
 
+    // space after comma in '[,]'.
+    if (Left.is(tok::comma) && Right.is(tok::r_square))
+      return Style.SpacesInSquareBrackets;
+
     // space between keywords and paren e.g. "using ("
     if (Right.is(tok::l_paren))
       if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75182.246999.patch
Type: text/x-patch
Size: 1242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200227/bce2e501/attachment.bin>


More information about the cfe-commits mailing list