clang-format: Fix assertion on unterminated #ifs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192535 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 93840dc..e8503bb 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -225,7 +225,7 @@
Callback.finishRun();
Lines.clear();
while (!PPLevelBranchIndex.empty() &&
- PPLevelBranchIndex.back() + 1 == PPLevelBranchCount.back()) {
+ PPLevelBranchIndex.back() + 1 >= PPLevelBranchCount.back()) {
PPLevelBranchIndex.resize(PPLevelBranchIndex.size() - 1);
PPLevelBranchCount.resize(PPLevelBranchCount.size() - 1);
}
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 5fea8e7..6e8179a 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2317,6 +2317,8 @@
" x();\n"
"}",
getLLVMStyleWithColumns(28));
+ verifyFormat("#if 1\n"
+ "int i;");
}
TEST_F(FormatTest, LayoutBlockInsideParens) {