diff options
-rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 8672ece9b79..7d7fe3f032e 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -241,11 +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]); } + IndentAtLineBreak = std::max<unsigned>(IndentAtLineBreak, Decoration.size()); DEBUG({ for (size_t i = 0; i < Lines.size(); ++i) { llvm::dbgs() << i << " |" << Lines[i] << "| " << LeadingWhitespace[i] diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 07c57853860..bfe5459e37a 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3641,17 +3641,26 @@ 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" + "* aaaaaa\n" "*/", format("/*\n" "*\n" " * aaaaaa aaaaaa\n" "*/", getLLVMStyleWithColumns(10))); + EXPECT_EQ("/*\n" + "**\n" + "* aaaaaa\n" + "* aaaaaa\n" + "*/", + format("/*\n" + "**\n" + "* aaaaaa aaaaaa\n" + "*/", + getLLVMStyleWithColumns(10))); FormatStyle NoBinPacking = getLLVMStyle(); NoBinPacking.BinPackParameters = false; |