Fix another clang-format crasher related to multi-line comments.

This fixes:
/*
*
* something long going over the column limit.
*/

llvm-svn: 182932
This commit is contained in:
Daniel Jasper 2013-05-30 15:20:29 +00:00
parent 29d9318c0c
commit 58dd2f0652
2 changed files with 14 additions and 0 deletions

View File

@ -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({

View File

@ -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;