r182940 - More fixes for clang-format's multiline comment breaking.

Daniel Jasper djasper at google.com
Thu May 30 10:27:48 PDT 2013


Author: djasper
Date: Thu May 30 12:27:48 2013
New Revision: 182940

URL: http://llvm.org/viewvc/llvm-project?rev=182940&view=rev
Log:
More fixes for clang-format's multiline comment breaking.

Modified:
    cfe/trunk/lib/Format/BreakableToken.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=182940&r1=182939&r2=182940&view=diff
==============================================================================
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Thu May 30 12:27:48 2013
@@ -241,11 +241,9 @@ BreakableBlockComment::BreakableBlockCom
       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<int>(IndentAtLineBreak, StartOfLineColumn[i]);
   }
+  IndentAtLineBreak = std::max<unsigned>(IndentAtLineBreak, Decoration.size());
   DEBUG({
     for (size_t i = 0; i < Lines.size(); ++i) {
       llvm::dbgs() << i << " |" << Lines[i] << "| " << LeadingWhitespace[i]

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182940&r1=182939&r2=182940&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu May 30 12:27:48 2013
@@ -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;





More information about the cfe-commits mailing list