Author: mamai Date: Thu Apr 14 09:56:49 2016 New Revision: 266321 URL: http://llvm.org/viewvc/llvm-project?rev=266321&view=rev Log: clang-format: Last line in incomplete block is indented incorrectly
Indentation of the last line was reset to the initial indentation of the block when reaching EOF. Patch by Maxime Beaulieu Differential Revision: http://reviews.llvm.org/D19065 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=266321&r1=266320&r2=266321&view=diff ============================================================================== --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Apr 14 09:56:49 2016 @@ -430,6 +430,9 @@ void UnwrappedLineParser::parseBlock(boo ++Line->Level; parseLevel(/*HasOpeningBrace=*/true); + if (eof()) + return; + if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd) : !FormatTok->is(tok::r_brace)) { Line->Level = InitialLevel; Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=266321&r1=266320&r2=266321&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Apr 14 09:56:49 2016 @@ -7110,10 +7110,9 @@ TEST_F(FormatTest, BlockCommentsAtEndOfL } TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) { - // FIXME: This is not what we want... verifyFormat("{\n" - "// a" - "// b"); + " // a\n" + " // b"); } TEST_F(FormatTest, FormatStarDependingOnContext) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits