]> granicus.if.org Git - clang/commitdiff
More fixes for clang-format's multiline comment breaking.
authorDaniel Jasper <djasper@google.com>
Thu, 30 May 2013 17:27:48 +0000 (17:27 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 30 May 2013 17:27:48 +0000 (17:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182940 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/BreakableToken.cpp
unittests/Format/FormatTest.cpp

index 8672ece9b798a3c27ede911185154f76bd800bb4..7d7fe3f032eebfb33fc7c89d5d2ba770c4b660ac 100644 (file)
@@ -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<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]
index 07c57853860f192195f90942d7e388bbe977bdde..bfe5459e37ab9a21c8d0477b9f2068e71b3e4bc3 100644 (file)
@@ -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;