From: Krasimir Georgiev Date: Thu, 24 Aug 2017 08:55:07 +0000 (+0000) Subject: Revert "[clang-format] Break non-trailing block comments" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=deada28d598565069625d73a44417d71f1adb45e;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311641 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 206be294c9..d8ae82c184 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -1282,7 +1282,7 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, 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. diff --git a/unittests/Format/FormatTestComments.cpp b/unittests/Format/FormatTestComments.cpp index 79dc003ae8..600132ec4b 100644 --- a/unittests/Format/FormatTestComments.cpp +++ b/unittests/Format/FormatTestComments.cpp @@ -2787,22 +2787,6 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) { "* 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