[llvm-branch-commits] [clang] 031743c - [clang-format] PR48539 ReflowComments breaks Qt translation comments
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 23 06:49:34 PST 2020
Author: mydeveloperday
Date: 2020-12-23T14:45:14Z
New Revision: 031743cb5b3c6c2df85a67d8533ef72a95e76cdc
URL: https://github.com/llvm/llvm-project/commit/031743cb5b3c6c2df85a67d8533ef72a95e76cdc
DIFF: https://github.com/llvm/llvm-project/commit/031743cb5b3c6c2df85a67d8533ef72a95e76cdc.diff
LOG: [clang-format] PR48539 ReflowComments breaks Qt translation comments
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.
Reviewed By: curdeius, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D93490
Added:
Modified:
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestComments.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index ea5cc31af07a..6a240fdec8b9 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -41,8 +41,8 @@ static bool IsBlank(char C) {
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);
diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index 27dfe71367b3..457e7321ec75 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -702,6 +702,12 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
" // 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)));
}
TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {
More information about the llvm-branch-commits
mailing list