mxbOctasic created this revision. mxbOctasic added a reviewer: djasper. mxbOctasic added subscribers: cameron314, cfe-commits. Herald added a subscriber: klimek.
This bug occurred when the end of the file was reached while parsing a block. The indentation of the last line was reset to the initial indentation of the block. http://reviews.llvm.org/D19065 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -7110,10 +7110,9 @@ } TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) { - // FIXME: This is not what we want... verifyFormat("{\n" - "// a" - "// b"); + " // a\n" + " // b"); } TEST_F(FormatTest, FormatStarDependingOnContext) { Index: lib/Format/UnwrappedLineParser.cpp =================================================================== --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -430,6 +430,9 @@ ++Line->Level; parseLevel(/*HasOpeningBrace=*/true); + if (eof()) + return; + if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd) : !FormatTok->is(tok::r_brace)) { Line->Level = InitialLevel;
Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -7110,10 +7110,9 @@ } TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) { - // FIXME: This is not what we want... verifyFormat("{\n" - "// a" - "// b"); + " // a\n" + " // b"); } TEST_F(FormatTest, FormatStarDependingOnContext) { Index: lib/Format/UnwrappedLineParser.cpp =================================================================== --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -430,6 +430,9 @@ ++Line->Level; parseLevel(/*HasOpeningBrace=*/true); + if (eof()) + return; + if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd) : !FormatTok->is(tok::r_brace)) { Line->Level = InitialLevel;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits