Author: Jonathan Coe Date: 2020-04-28T17:31:40+01:00 New Revision: 7443f86eabbae0fdef90fe796c3956ed65238e99
URL: https://github.com/llvm/llvm-project/commit/7443f86eabbae0fdef90fe796c3956ed65238e99 DIFF: https://github.com/llvm/llvm-project/commit/7443f86eabbae0fdef90fe796c3956ed65238e99.diff LOG: [clang-format] insert space after C# keyword var in var (key, value) Reviewers: krasimir, MyDeveloperDay Reviewed By: MyDeveloperDay Subscribers: cfe-commits Tags: #clang-format, #clang Differential Revision: https://reviews.llvm.org/D79008 Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTestCSharp.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 3e441100a2f0..61386cef990a 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -3053,6 +3053,10 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, if (Left.is(TT_CSharpNullConditionalLSquare)) return Style.SpacesInSquareBrackets; + // space after var in `var (key, value)` + if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren)) + return true; + // 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)) diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp index 75112a786867..91962ef12631 100644 --- a/clang/unittests/Format/FormatTestCSharp.cpp +++ b/clang/unittests/Format/FormatTestCSharp.cpp @@ -698,6 +698,7 @@ TEST_F(FormatTestCSharp, CSharpSpaces) { verifyFormat(R"(Result this[Index x] => Foo(x);)", Style); verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style); + verifyFormat(R"(var (key, value))", Style); // Not seen as a C-style cast. verifyFormat(R"(// _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits