[PATCH] D93490: [clang-format] PR48539 ReflowComments breaks Qt translation comments
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 17 13:20:21 PST 2020
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, curdeius, JakeMerdichAMD, JVApen.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.
https://bugs.llvm.org/show_bug.cgi?id=48539
Add support for Qt Translator Comments to reflow
When reflown and a part of the comments are added on a new line, it should repeat these extra characters as part of the comment token.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93490
Files:
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestComments.cpp
Index: clang/unittests/Format/FormatTestComments.cpp
===================================================================
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -702,6 +702,22 @@
" // long 1 2 3 4 5 6\n"
"}",
getLLVMStyleWithColumns(20)));
+
+ EXPECT_EQ("//: A comment that\n"
+ "//: doesn't fit on\n"
+ "//: one line",
+ format("//: A comment that doesn't fit on one line",
+ getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("//= A comment that\n"
+ "//= doesn't fit on\n"
+ "//= one line",
+ format("//= A comment that doesn't fit on one line",
+ getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("//~ A comment that\n"
+ "//~ doesn't fit on\n"
+ "//~ one line",
+ format("//~ A comment that doesn't fit on one line",
+ getLLVMStyleWithColumns(20)));
}
TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {
Index: clang/lib/Format/BreakableToken.cpp
===================================================================
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -41,8 +41,8 @@
static StringRef getLineCommentIndentPrefix(StringRef Comment,
const FormatStyle &Style) {
- static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///", "//",
- "//!"};
+ static const char *const KnownCStylePrefixes[] = {
+ "///<", "//!<", "///", "//", "//!", "//:", "//=", "//~"};
static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
"####"};
ArrayRef<const char *> KnownPrefixes(KnownCStylePrefixes);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93490.312601.patch
Type: text/x-patch
Size: 1909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201217/54a2b878/attachment.bin>
More information about the cfe-commits
mailing list