r311641 - Revert "[clang-format] Break non-trailing block comments"

Krasimir Georgiev via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 01:55:07 PDT 2017


Author: krasimir
Date: Thu Aug 24 01:55:07 2017
New Revision: 311641

URL: http://llvm.org/viewvc/llvm-project?rev=311641&view=rev
Log:
Revert "[clang-format] Break non-trailing block comments"

This reverts commit r311457. It reveals some dormant bugs in comment
reflowing, like breaking a single line jsdoc type annotation before a
parameter into multiple lines.

Modified:
    cfe/trunk/lib/Format/ContinuationIndenter.cpp
    cfe/trunk/unittests/Format/FormatTestComments.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=311641&r1=311640&r2=311641&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Aug 24 01:55:07 2017
@@ -1282,7 +1282,7 @@ unsigned ContinuationIndenter::breakProt
       return 0;
     }
   } else if (Current.is(TT_BlockComment)) {
-    if (!Style.ReflowComments ||
+    if (!Current.isTrailingComment() || !Style.ReflowComments ||
         // If a comment token switches formatting, like
         // /* clang-format on */, we don't want to break it further,
         // but we may still want to adjust its indentation.

Modified: cfe/trunk/unittests/Format/FormatTestComments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestComments.cpp?rev=311641&r1=311640&r2=311641&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestComments.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestComments.cpp Thu Aug 24 01:55:07 2017
@@ -2787,22 +2787,6 @@ TEST_F(FormatTestComments, AlignsBlockCo
                    "* long */",
                    getLLVMStyleWithColumns(20)));
 }
-
-TEST_F(FormatTestComments, NonTrailingBlockComments) {
-  verifyFormat("const /** comment comment */ A = B;",
-               getLLVMStyleWithColumns(40));
-
-  verifyFormat("const /** comment comment comment */ A =\n"
-               "    B;",
-               getLLVMStyleWithColumns(40));
-
-  EXPECT_EQ("const /** comment comment comment\n"
-            "         comment */\n"
-            "    A = B;",
-            format("const /** comment comment comment comment */\n"
-                   "    A = B;",
-                   getLLVMStyleWithColumns(40)));
-}
 } // end namespace
 } // end namespace format
 } // end namespace clang




More information about the cfe-commits mailing list