diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 5317c05f3a46..def0d73e7753 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -158,8 +158,7 @@ getCommentSplit(StringRef Text, unsigned ContentStartColumn, return BreakableToken::Split(StringRef::npos, 0); StringRef BeforeCut = Text.substr(0, SpaceOffset).rtrim(Blanks); StringRef AfterCut = Text.substr(SpaceOffset); - // Don't trim the leading blanks if it would create a */ after the break. - if (!DecorationEndsWithStar || AfterCut.size() <= 1 || AfterCut[1] != '/') + if (!DecorationEndsWithStar) AfterCut = AfterCut.ltrim(Blanks); return BreakableToken::Split(BeforeCut.size(), AfterCut.begin() - BeforeCut.end()); diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp index 5eefd767706a..a16fbffb7627 100644 --- a/clang/unittests/Format/FormatTestComments.cpp +++ b/clang/unittests/Format/FormatTestComments.cpp @@ -2486,7 +2486,7 @@ TEST_F(FormatTestComments, BlockComments) { EXPECT_EQ("/*\n" "**\n" "* aaaaaa\n" - "*aaaaaa\n" + "* aaaaaa\n" "*/", format("/*\n" "**\n"