From 45206cac6339a675348a5675b5744148d3aba2f4 Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Tue, 22 Oct 2013 08:27:19 +0000 Subject: [PATCH] Remove incorrect assert. If we run into the second preprocessor branch chain, the first branch chain might have already set the maximum branch count on that level to something > 0. Fixes PR17645. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193153 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 1 - unittests/Format/FormatTest.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 949f5a308b..e0b090f6ab 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -485,7 +485,6 @@ void UnwrappedLineParser::parsePPEndIf() { assert(PPBranchLevel < (int)PPLevelBranchIndex.size()); if (PPBranchLevel >= 0 && !PPChainBranchIndex.empty()) { if (PPChainBranchIndex.top() + 1 > PPLevelBranchCount[PPBranchLevel]) { - assert(PPLevelBranchCount[PPBranchLevel] == 0); PPLevelBranchCount[PPBranchLevel] = PPChainBranchIndex.top() + 1; } } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index a7de81b267..20132f9ccc 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2327,6 +2327,12 @@ TEST_F(FormatTest, LayoutStatementsAroundPreprocessorDirectives) { getLLVMStyleWithColumns(28)); verifyFormat("#if 1\n" "int i;"); + verifyFormat( + "#if 1\n" + "#endif\n" + "#if 1\n" + "#else\n" + "#endif\n"); } TEST_F(FormatTest, FormatsJoinedLinesOnSubsequentRuns) { -- 2.40.0