From ac4d0181928e3e22fa3929ca1b24ae7f14fb7628 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Sat, 12 Oct 2013 13:32:56 +0000 Subject: [PATCH] clang-format: Fix assertion on unterminated #ifs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192535 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 2 +- unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 93840dcad8..e8503bb332 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 5fea8e781e..6e8179a306 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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) { -- 2.40.0