Fix clang-format bug in unwrapped-line merging.
Before (in styles that allow it), clang-format would not merge an
if statement onto a single line, if only the second line was format
(e.g. in an editor integration):
if (a)
return; // clang-format invoked on this line.
With this patch, this gets properly merged to:
if (a) return; // ...
llvm-svn: 181770
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index b7f544e..19c5215 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -245,6 +245,8 @@
"}",
AllowsMergedIf);
+ EXPECT_EQ("if (a) return;", format("if(a)\nreturn;", 7, 1, AllowsMergedIf));
+
AllowsMergedIf.ColumnLimit = 14;
verifyFormat("if (a) return;", AllowsMergedIf);
verifyFormat("if (aaaaaaaaa)\n"
@@ -3810,7 +3812,7 @@
"a;\n"
"}\n"
"{\n"
- " b;\n"
+ " b; //\n"
"}\n"
"}",
format("{\n"
@@ -3818,15 +3820,15 @@
"a;\n"
"}\n"
"{\n"
- " b;\n"
+ " b; //\n"
"}\n"
"}",
22, 2, getLLVMStyle()));
EXPECT_EQ(" {\n"
- " a;\n"
+ " a; //\n"
" }",
format(" {\n"
- "a;\n"
+ "a; //\n"
" }",
4, 2, getLLVMStyle()));
EXPECT_EQ("void f() {}\n"