Skip to content

Commit 03137c6

Browse files
author
Marianne Mailhot-Sarrasin
committedApr 14, 2016
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 llvm-svn: 266321
1 parent 51fe279 commit 03137c6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

Diff for: ‎clang/lib/Format/UnwrappedLineParser.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
430430
++Line->Level;
431431
parseLevel(/*HasOpeningBrace=*/true);
432432

433+
if (eof())
434+
return;
435+
433436
if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
434437
: !FormatTok->is(tok::r_brace)) {
435438
Line->Level = InitialLevel;

Diff for: ‎clang/unittests/Format/FormatTest.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -7110,10 +7110,9 @@ TEST_F(FormatTest, BlockCommentsAtEndOfLine) {
71107110
}
71117111

71127112
TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) {
7113-
// FIXME: This is not what we want...
71147113
verifyFormat("{\n"
7115-
"// a"
7116-
"// b");
7114+
" // a\n"
7115+
" // b");
71177116
}
71187117

71197118
TEST_F(FormatTest, FormatStarDependingOnContext) {

0 commit comments

Comments
 (0)
Please sign in to comment.