Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1329,7 +1329,7 @@ // FIXME: Add a more explicit test. while (FormatTok->TokenText.size() > 1 && FormatTok->TokenText[0] == '\\' && FormatTok->TokenText[1] == '\n') { - // FIXME: ++FormatTok->NewlinesBefore is missing... + ++FormatTok->NewlinesBefore; WhitespaceLength += 2; Column = 0; FormatTok->TokenText = FormatTok->TokenText.substr(2); Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -746,7 +746,7 @@ "int a; // This is unrelated\n" "};")); - EXPECT_EQ("int i; // single line trailing comment", + EXPECT_EQ("int i;\n// single line trailing comment", format("int i;\\\n// single line trailing comment")); verifyGoogleFormat("int a; // Trailing comment."); @@ -931,7 +931,7 @@ TEST_F(FormatTest, UnderstandsBlockComments) { verifyFormat("f(/*noSpaceAfterParameterNamingComment=*/true);"); verifyFormat("void f() { g(/*aaa=*/x, /*bbb=*/!y); }"); - EXPECT_EQ("f(aaaaaaaaaaaaaaaaaaaaaaaaa, /* Trailing comment for aa... */\n" + EXPECT_EQ("f(aaaaaaaaaaaaaaaaaaaaaaaaa,\n /* Trailing comment for aa... */\n" " bbbbbbbbbbbbbbbbbbbbbbbbb);", format("f(aaaaaaaaaaaaaaaaaaaaaaaaa , \\\n" "/* Trailing comment for aa... */\n" @@ -1057,7 +1057,7 @@ "// h i j k", format("// a b c d e f g h i j k", getLLVMStyleWithColumns(10))); - EXPECT_EQ("// a b c d\n" + EXPECT_EQ("\n// a b c d\n" "// e f g\n" "// h i j k", format("\\\n// a b c d e f g h i j k", @@ -1246,7 +1246,7 @@ " */", format("/* a b c d e f g h i j k */", getLLVMStyleWithColumns(10))); - EXPECT_EQ("/* a b c d\n" + EXPECT_EQ("\n/* a b c d\n" " * e f g\n" " * h i j k\n" " */", @@ -2462,11 +2462,11 @@ EXPECT_EQ( "#define A \\\n int i; \\\n int j;", format("#define A \\\nint i;\\\n int j;", getLLVMStyleWithColumns(11))); - EXPECT_EQ("template f();", format("\\\ntemplate f();")); + EXPECT_EQ("\ntemplate f();", format("\\\ntemplate f();")); } TEST_F(FormatTest, NoEscapedNewlineHandlingInBlockComments) { - EXPECT_EQ("/* \\ \\ \\\n*/", format("\\\n/* \\ \\ \\\n*/")); + EXPECT_EQ("\n/* \\ \\ \\\n*/", format("\\\n/* \\ \\ \\\n*/")); } TEST_F(FormatTest, CalculateSpaceOnConsecutiveLinesInMacro) { @@ -6349,7 +6349,7 @@ EXPECT_EQ("\"some text \"\n" "\"other\";", format("\"some text other\";", getLLVMStyleWithColumns(12))); - EXPECT_EQ("\"some text \"\n" + EXPECT_EQ("\n\"some text \"\n" "\"other\";", format("\\\n\"some text other\";", getLLVMStyleWithColumns(12))); EXPECT_EQ(