This revision was automatically updated to reflect the committed changes. Closed by commit rL286973: [clang-format] Fixed line merging of more than two lines (authored by cameron314).
Changed prior to commit: https://reviews.llvm.org/D19063?vs=53572&id=77996#toc Repository: rL LLVM https://reviews.llvm.org/D19063 Files: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp cfe/trunk/unittests/Format/FormatTest.cpp Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp =================================================================== --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp @@ -151,7 +151,7 @@ MergedLines = 0; if (!DryRun) for (unsigned i = 0; i < MergedLines; ++i) - join(*Next[i], *Next[i + 1]); + join(*Next[0], *Next[i + 1]); Next = Next + MergedLines + 1; return Current; } Index: cfe/trunk/unittests/Format/FormatTest.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -276,6 +276,30 @@ "int i;\n" "\n" "} // namespace")); + + FormatStyle Style = getLLVMStyle(); + Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; + Style.MaxEmptyLinesToKeep = 2; + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterClass = true; + Style.BraceWrapping.AfterFunction = true; + Style.KeepEmptyLinesAtTheStartOfBlocks = false; + + EXPECT_EQ("class Foo\n" + "{\n" + " Foo() {}\n" + "\n" + " void funk() {}\n" + "};", + format("class Foo\n" + "{\n" + " Foo()\n" + " {\n" + " }\n" + "\n" + " void funk() {}\n" + "};", + Style)); } TEST_F(FormatTest, RecognizesBinaryOperatorKeywords) {
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp =================================================================== --- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp +++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp @@ -151,7 +151,7 @@ MergedLines = 0; if (!DryRun) for (unsigned i = 0; i < MergedLines; ++i) - join(*Next[i], *Next[i + 1]); + join(*Next[0], *Next[i + 1]); Next = Next + MergedLines + 1; return Current; } Index: cfe/trunk/unittests/Format/FormatTest.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -276,6 +276,30 @@ "int i;\n" "\n" "} // namespace")); + + FormatStyle Style = getLLVMStyle(); + Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; + Style.MaxEmptyLinesToKeep = 2; + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterClass = true; + Style.BraceWrapping.AfterFunction = true; + Style.KeepEmptyLinesAtTheStartOfBlocks = false; + + EXPECT_EQ("class Foo\n" + "{\n" + " Foo() {}\n" + "\n" + " void funk() {}\n" + "};", + format("class Foo\n" + "{\n" + " Foo()\n" + " {\n" + " }\n" + "\n" + " void funk() {}\n" + "};", + Style)); } TEST_F(FormatTest, RecognizesBinaryOperatorKeywords) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits