diff options
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 742b9a8d1cc..4e9fd405df3 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index daebc4ddab1..8e55ddb5d0f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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) { |