diff options
| -rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 11ab58c18cd..125283a0c6d 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -917,7 +917,7 @@ private: Token.reset(new BreakableStringLiteral(Current, StartColumn, Line.InPPDirective, Encoding)); - } else if (Current.Type == TT_BlockComment) { + } else if (Current.Type == TT_BlockComment && Current.isTrailingComment()) { Token.reset(new BreakableBlockComment( Style, Current, StartColumn, OriginalStartColumn, !Current.Previous, Line.InPPDirective, Encoding)); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 433d0ec1d71..3b8f91130ff 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -866,6 +866,13 @@ TEST_F(FormatTest, CorrectlyHandlesLengthOfBlockComments) { getLLVMStyleWithColumns(40))); } +TEST_F(FormatTest, DontBreakNonTrailingBlockComments) { + EXPECT_EQ("void\n" + "ffffffffff(int aaaaa /* test */);", + format("void ffffffffff(int aaaaa /* test */);", + getLLVMStyleWithColumns(35))); +} + TEST_F(FormatTest, SplitsLongCxxComments) { EXPECT_EQ("// A comment that\n" "// doesn't fit on\n" |

