summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-12 13:32:56 +0000
committerDaniel Jasper <djasper@google.com>2013-10-12 13:32:56 +0000
commit53bd167c60dca5d0e59c0069d2644aecc2151985 (patch)
tree801fd995836b414676e044c6eb0f0795d4e40f99 /clang
parent7f5823844ae92f64f31db8af2ef3173ecf1349f0 (diff)
downloadbcm5719-llvm-53bd167c60dca5d0e59c0069d2644aecc2151985.tar.gz
bcm5719-llvm-53bd167c60dca5d0e59c0069d2644aecc2151985.zip
clang-format: Fix assertion on unterminated #ifs.
llvm-svn: 192535
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp2
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 93840dcad8f..e8503bb3322 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -225,7 +225,7 @@ bool UnwrappedLineParser::parse() {
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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 5fea8e781eb..6e8179a3068 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2317,6 +2317,8 @@ TEST_F(FormatTest, LayoutStatementsAroundPreprocessorDirectives) {
" x();\n"
"}",
getLLVMStyleWithColumns(28));
+ verifyFormat("#if 1\n"
+ "int i;");
}
TEST_F(FormatTest, LayoutBlockInsideParens) {
OpenPOWER on IntegriCloud