]> granicus.if.org Git - clang/commitdiff
clang-format: Fix excessive formatting caused by r195954.
authorDaniel Jasper <djasper@google.com>
Mon, 2 Dec 2013 09:19:27 +0000 (09:19 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 2 Dec 2013 09:19:27 +0000 (09:19 +0000)
Due to a bug in the patch, clang-format would more or less simply format
all multi-line comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196080 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 7f91239477868cb33a3f8ca5174ba30b879a19f9..28ef19e192f9cec7ef4c366569aac3f22de45f2a 100644 (file)
@@ -1457,6 +1457,7 @@ private:
     bool IsContinuedComment = Line->First->is(tok::comment) &&
                               Line->First->Next == NULL &&
                               Line->First->NewlinesBefore < 2 && PreviousLine &&
+                              PreviousLine->Affected &&
                               PreviousLine->Last->is(tok::comment);
 
     if (SomeTokenAffected || SomeFirstChildAffected || LineMoved ||
index 9fac17bc9e53fb3d02d4bef5260435815e58e91c..17972c62f8ab54bce2535ba7db86d6256435fbc2 100644 (file)
@@ -859,6 +859,13 @@ TEST_F(FormatTest, CanFormatCommentsLocally) {
                    "\n"
                    "  // This is unrelated",
                    0, 0, getLLVMStyle()));
+  EXPECT_EQ("int a;\n"
+            "// This is\n"
+            "// not formatted.   ",
+            format("int a;\n"
+                   "// This is\n"
+                   "// not formatted.   ",
+                   0, 0, getLLVMStyle()));
 }
 
 TEST_F(FormatTest, RemovesTrailingWhitespaceOfComments) {