[PATCH] D67888: [clang-format] NFC clang-format the clang-format unit tests
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 22 05:12:01 PDT 2019
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: klimek, owenpan, timwoj.
MyDeveloperDay added a project: clang-tools-extra.
Herald added a project: clang.
It is annoying that the clang-format tests aren't themselves clang-formatted, if you use a format on save option in VS or vim this file gets massively changed then you have to `git difftool` all the other changes back out, which is risky.
I know people don't like mass clang-format changes but sometimes it becomes unmanageable to not. There are no other changes here other than just the reformat.
clang-format tests all pass.
[==========] 691 tests from 21 test cases ran. (55990 ms total)
[ PASSED ] 691 tests.
Repository:
rC Clang
https://reviews.llvm.org/D67888
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
@@ -165,6 +165,21 @@
"public string Host {\n set;\n get;\n}");
}
+TEST_F(FormatTestCSharp, CSharpUsing) {
+ FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+ Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
+ verifyFormat("public void foo() {\n"
+ " using (StreamWriter sw = new StreamWriter (filenameA)) {}\n"
+ "}",
+ Style);
+
+ Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
+ verifyFormat("public void foo() {\n"
+ " using(StreamWriter sw = new StreamWriter(filenameB)) {}\n"
+ "}",
+ Style);
+}
+
TEST_F(FormatTestCSharp, CSharpRegions) {
verifyFormat("#region aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaa long region");
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2611,6 +2611,10 @@
return Style.Language == FormatStyle::LK_JavaScript ||
!Left.TokenText.endswith("=*/");
if (Right.is(tok::l_paren)) {
+ // using (FileStream fs...
+ if (Style.isCSharp() && Left.is(tok::kw_using) &&
+ Style.SpaceBeforeParens != FormatStyle::SBPO_Never)
+ return true;
if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
(Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67888.221213.patch
Type: text/x-patch
Size: 1693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190922/dc6fcac8/attachment.bin>
More information about the cfe-commits
mailing list