From: Daniel Jasper Date: Thu, 30 May 2013 17:27:48 +0000 (+0000) Subject: More fixes for clang-format's multiline comment breaking. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb4b40b86e284151d6ca14181f949655a9ceccd8;p=clang More fixes for clang-format's multiline comment breaking. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182940 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp index 8672ece9b7..7d7fe3f032 100644 --- a/lib/Format/BreakableToken.cpp +++ b/lib/Format/BreakableToken.cpp @@ -241,11 +241,9 @@ BreakableBlockComment::BreakableBlockComment(const FormatStyle &Style, Lines[i] = Lines[i].substr(Offset); LeadingWhitespace[i] += Offset; } - // Exclude empty lines from the calculation of the left-most column. - if (Lines[i].empty()) - continue; IndentAtLineBreak = std::min(IndentAtLineBreak, StartOfLineColumn[i]); } + IndentAtLineBreak = std::max(IndentAtLineBreak, Decoration.size()); DEBUG({ for (size_t i = 0; i < Lines.size(); ++i) { llvm::dbgs() << i << " |" << Lines[i] << "| " << LeadingWhitespace[i] diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 07c5785386..bfe5459e37 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3641,17 +3641,26 @@ TEST_F(FormatTest, BlockComments) { "/* */someCall(parameter);", getLLVMStyleWithColumns(15))); EXPECT_EQ("/*\n**\n*/", format("/*\n**\n*/")); - // FIXME: Consider whether empty lines can dictated the left-most column. EXPECT_EQ("/*\n" "*\n" " * aaaaaa\n" - " * aaaaaa\n" + "* aaaaaa\n" "*/", format("/*\n" "*\n" " * aaaaaa aaaaaa\n" "*/", getLLVMStyleWithColumns(10))); + EXPECT_EQ("/*\n" + "**\n" + "* aaaaaa\n" + "* aaaaaa\n" + "*/", + format("/*\n" + "**\n" + "* aaaaaa aaaaaa\n" + "*/", + getLLVMStyleWithColumns(10))); FormatStyle NoBinPacking = getLLVMStyle(); NoBinPacking.BinPackParameters = false;