Skip to content

Commit 1b03cbc

Browse files
authored
[clang-format] Handle doxygen commands starting with \ (#80381)
Fixes #63241 Doxygen commands can start with `@` or `\`.
1 parent 2f49058 commit 1b03cbc

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clang/lib/Format/BreakableToken.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,11 @@ const FormatToken &BreakableComment::tokenAt(unsigned LineIndex) const {
449449

450450
static bool mayReflowContent(StringRef Content) {
451451
Content = Content.trim(Blanks);
452-
// Lines starting with '@' commonly have special meaning.
452+
// Lines starting with '@' or '\' commonly have special meaning.
453453
// Lines starting with '-', '-#', '+' or '*' are bulleted/numbered lists.
454454
bool hasSpecialMeaningPrefix = false;
455455
for (StringRef Prefix :
456-
{"@", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* "}) {
456+
{"@", "\\", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* "}) {
457457
if (Content.starts_with(Prefix)) {
458458
hasSpecialMeaningPrefix = true;
459459
break;

clang/unittests/Format/FormatTestComments.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,14 @@ TEST_F(FormatTestComments, ReflowsComments) {
19091909
"// @param arg",
19101910
getLLVMStyleWithColumns(20)));
19111911

1912+
// Don't reflow lines starting with '\'.
1913+
verifyFormat("// long long long\n"
1914+
"// long\n"
1915+
"// \\param arg",
1916+
"// long long long long\n"
1917+
"// \\param arg",
1918+
getLLVMStyleWithColumns(20));
1919+
19121920
// Don't reflow lines starting with 'TODO'.
19131921
EXPECT_EQ("// long long long\n"
19141922
"// long\n"

0 commit comments

Comments
 (0)