]> granicus.if.org Git - clang/commitdiff
Remove incorrect assert.
authorManuel Klimek <klimek@google.com>
Tue, 22 Oct 2013 08:27:19 +0000 (08:27 +0000)
committerManuel Klimek <klimek@google.com>
Tue, 22 Oct 2013 08:27:19 +0000 (08:27 +0000)
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
unittests/Format/FormatTest.cpp

index 949f5a308b2c593a3da997a3f22d3b9afcdf81b9..e0b090f6abc99ae3a04f2c7a6fda6e9b9fec8022 100644 (file)
@@ -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;
     }
   }
index a7de81b26782cd2ee278420846462966057eb056..20132f9cccc45d8c1263bd7530e4a0de33fb7b51 100644 (file)
@@ -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) {