summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorMarianne Mailhot-Sarrasin <marianne.mailhot.sarrasin@gmail.com>2016-04-14 14:56:49 +0000
committerMarianne Mailhot-Sarrasin <marianne.mailhot.sarrasin@gmail.com>2016-04-14 14:56:49 +0000
commit03137c65382ef647511771e2401f276f491779c3 (patch)
treeaf8b38a6548c074af9b8579662aff08d96efee5d /clang
parent51fe279fbbae990318bcedd6d0990dbc2ae00583 (diff)
downloadbcm5719-llvm-03137c65382ef647511771e2401f276f491779c3.tar.gz
bcm5719-llvm-03137c65382ef647511771e2401f276f491779c3.zip
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
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp5
2 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 76e87768bc6..6cd74f91a8a 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -430,6 +430,9 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
++Line->Level;
parseLevel(/*HasOpeningBrace=*/true);
+ if (eof())
+ return;
+
if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
: !FormatTok->is(tok::r_brace)) {
Line->Level = InitialLevel;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 50a83f66ad2..1b0e5865b77 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7110,10 +7110,9 @@ TEST_F(FormatTest, BlockCommentsAtEndOfLine) {
}
TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) {
- // FIXME: This is not what we want...
verifyFormat("{\n"
- "// a"
- "// b");
+ " // a\n"
+ " // b");
}
TEST_F(FormatTest, FormatStarDependingOnContext) {
OpenPOWER on IntegriCloud