r192535 - clang-format: Fix assertion on unterminated #ifs.
Daniel Jasper
djasper at google.com
Sat Oct 12 06:32:56 PDT 2013
Author: djasper
Date: Sat Oct 12 08:32:56 2013
New Revision: 192535
URL: http://llvm.org/viewvc/llvm-project?rev=192535&view=rev
Log:
clang-format: Fix assertion on unterminated #ifs.
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=192535&r1=192534&r2=192535&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Sat Oct 12 08:32:56 2013
@@ -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);
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=192535&r1=192534&r2=192535&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sat Oct 12 08:32:56 2013
@@ -2317,6 +2317,8 @@ TEST_F(FormatTest, LayoutStatementsAroun
" x();\n"
"}",
getLLVMStyleWithColumns(28));
+ verifyFormat("#if 1\n"
+ "int i;");
}
TEST_F(FormatTest, LayoutBlockInsideParens) {
More information about the cfe-commits
mailing list