Fix a bug in the line merging.

If the first line of a merge would exactly fit into the column limit,
an unsigned overflow made us not break.

llvm-svn: 172426
This commit is contained in:
Daniel Jasper 2013-01-14 16:02:06 +00:00
parent 2ab0d01a8e
commit 3e9218e50a
2 changed files with 4 additions and 0 deletions

View File

@ -1408,6 +1408,8 @@ private:
unsigned Length = 0;
if (!fitsIntoLimit(I->First, Limit, &Length))
return false;
if (Limit == Length)
return true; // Couldn't fit a space.
Limit -= Length + 1; // One space.
if (I + 1 == E)
return true;

View File

@ -138,6 +138,8 @@ TEST_F(FormatTest, FormatIfWithoutCompountStatement) {
" f();");
verifyFormat("if (a) return;", getLLVMStyleWithColumns(14));
verifyFormat("if (a)\n return;", getLLVMStyleWithColumns(13));
verifyFormat("if (aaaaaaaaa)\n"
" return;", getLLVMStyleWithColumns(14));
}
TEST_F(FormatTest, ParseIfElse) {