jbcoe created this revision.
jbcoe added a reviewer: krasimir.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
krasimir accepted this revision.
This revision is now accepted and ready to land.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76621
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
@@ -640,9 +640,12 @@
verifyFormat(R"(private float[,] Values;)", Style);
verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
+ verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
+
Style.SpacesInSquareBrackets = true;
verifyFormat(R"(private float[ , ] Values;)", Style);
verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
+ verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
}
TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3015,6 +3015,10 @@
if (Right.is(TT_CSharpNullConditionalLSquare))
return false;
+ // No space between consecutive commas '[,,]'.
+ if (Left.is(tok::comma) && Right.is(tok::comma))
+ return false;
+
// Possible space inside `?[ 0 ]`.
if (Left.is(TT_CSharpNullConditionalLSquare))
return Style.SpacesInSquareBrackets;
Index: clang/unittests/Format/FormatTestCSharp.cpp
===================================================================
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -640,9 +640,12 @@
verifyFormat(R"(private float[,] Values;)", Style);
verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
+ verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
+
Style.SpacesInSquareBrackets = true;
verifyFormat(R"(private float[ , ] Values;)", Style);
verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
+ verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
}
TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3015,6 +3015,10 @@
if (Right.is(TT_CSharpNullConditionalLSquare))
return false;
+ // No space between consecutive commas '[,,]'.
+ if (Left.is(tok::comma) && Right.is(tok::comma))
+ return false;
+
// Possible space inside `?[ 0 ]`.
if (Left.is(TT_CSharpNullConditionalLSquare))
return Style.SpacesInSquareBrackets;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits