Fix aligning of comments.
Previously we started sequences to align for single line comments when
the previous line had a trailing comment, but the sequence was broken
for other reasons.
Now we re-format:
// a
// b
f(); // c
to:
// a
// b
f(); // c
llvm-svn: 182608
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 5346bdc..ce551e9 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -657,6 +657,26 @@
format("lineWith(); // comment\n"
"// at start\n"
"otherLine(); // comment"));
+ EXPECT_EQ("lineWith();\n"
+ "// at start\n"
+ "otherLine(); // comment",
+ format("lineWith();\n"
+ " // at start\n"
+ "otherLine(); // comment"));
+ EXPECT_EQ("// first\n"
+ "// at start\n"
+ "otherLine(); // comment",
+ format("// first\n"
+ " // at start\n"
+ "otherLine(); // comment"));
+ EXPECT_EQ("f();\n"
+ "// first\n"
+ "// at start\n"
+ "otherLine(); // comment",
+ format("f();\n"
+ "// first\n"
+ " // at start\n"
+ "otherLine(); // comment"));
}
TEST_F(FormatTest, CanFormatCommentsLocally) {