owenpan created this revision. owenpan added reviewers: klimek, sammccall, MyDeveloperDay, djasper, krasimir. owenpan added a project: clang. Herald added a subscriber: cfe-commits.
This patch fixes PR41213 <https://bugs.llvm.org/show_bug.cgi?id=41213>. Repository: rC Clang https://reviews.llvm.org/D61276 Files: clang/lib/Format/BreakableToken.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -11137,6 +11137,16 @@ FormatStyle Style = getLLVMStyle(); Style.ColumnLimit = 20; + // See PR41213 + EXPECT_EQ("/*\n" + " * 456789012345678\n" + " * /x\n" + " */", + format("/*\n" + " *\t456789012345678 /x\n" + " */", + Style)); + verifyFormat("int a; // the\n" " // comment", Style); EXPECT_EQ("int a; /* first line\n" Index: clang/lib/Format/BreakableToken.cpp =================================================================== --- clang/lib/Format/BreakableToken.cpp +++ clang/lib/Format/BreakableToken.cpp @@ -380,6 +380,8 @@ break; if (!Content[i].empty() && i + 1 != e && Decoration.startswith(Content[i])) continue; + if (Content[i].startswith("*\t")) + continue; while (!Content[i].startswith(Decoration)) Decoration = Decoration.substr(0, Decoration.size() - 1); }
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -11137,6 +11137,16 @@ FormatStyle Style = getLLVMStyle(); Style.ColumnLimit = 20; + // See PR41213 + EXPECT_EQ("/*\n" + " * 456789012345678\n" + " * /x\n" + " */", + format("/*\n" + " *\t456789012345678 /x\n" + " */", + Style)); + verifyFormat("int a; // the\n" " // comment", Style); EXPECT_EQ("int a; /* first line\n" Index: clang/lib/Format/BreakableToken.cpp =================================================================== --- clang/lib/Format/BreakableToken.cpp +++ clang/lib/Format/BreakableToken.cpp @@ -380,6 +380,8 @@ break; if (!Content[i].empty() && i + 1 != e && Decoration.startswith(Content[i])) continue; + if (Content[i].startswith("*\t")) + continue; while (!Content[i].startswith(Decoration)) Decoration = Decoration.substr(0, Decoration.size() - 1); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits