diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 01317dbef3d..8672ece9b79 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -241,6 +241,9 @@ BreakableBlockComment::BreakableBlockComment(const FormatStyle &Style, Lines[i] = Lines[i].substr(Offset); LeadingWhitespace[i] += Offset; } + // Exclude empty lines from the calculation of the left-most column. + if (Lines[i].empty()) + continue; IndentAtLineBreak = std::min<int>(IndentAtLineBreak, StartOfLineColumn[i]); } DEBUG({ diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index b2e53a53348..07c57853860 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3641,6 +3641,17 @@ TEST_F(FormatTest, BlockComments) { "/* */someCall(parameter);", getLLVMStyleWithColumns(15))); EXPECT_EQ("/*\n**\n*/", format("/*\n**\n*/")); + // FIXME: Consider whether empty lines can dictated the left-most column. + EXPECT_EQ("/*\n" + "*\n" + " * aaaaaa\n" + " * aaaaaa\n" + "*/", + format("/*\n" + "*\n" + " * aaaaaa aaaaaa\n" + "*/", + getLLVMStyleWithColumns(10))); FormatStyle NoBinPacking = getLLVMStyle(); NoBinPacking.BinPackParameters = false; |