https://github.com/XDeme created https://github.com/llvm/llvm-project/pull/80381
Fixes llvm/llvm-project#63241 Doxygen commands can start with `@` or `\`. >From efd816282e5f5b71d6f88038a2121fa698becf7a Mon Sep 17 00:00:00 2001 From: XDeme <fernando.tagawa.gamail....@gmail.com> Date: Fri, 2 Feb 2024 00:27:57 -0300 Subject: [PATCH] [clang-format] Handle doxygen comments starting with \ --- clang/lib/Format/BreakableToken.cpp | 4 ++-- clang/unittests/Format/FormatTestComments.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 473908e8fee3b..75304908dc650 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -449,11 +449,11 @@ const FormatToken &BreakableComment::tokenAt(unsigned LineIndex) const { static bool mayReflowContent(StringRef Content) { Content = Content.trim(Blanks); - // Lines starting with '@' commonly have special meaning. + // Lines starting with '@' or '\' commonly have special meaning. // Lines starting with '-', '-#', '+' or '*' are bulleted/numbered lists. bool hasSpecialMeaningPrefix = false; for (StringRef Prefix : - {"@", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* "}) { + {"@", "\\", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* "}) { if (Content.starts_with(Prefix)) { hasSpecialMeaningPrefix = true; break; diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp index c249f4d9333fd..0327937e4496a 100644 --- a/clang/unittests/Format/FormatTestComments.cpp +++ b/clang/unittests/Format/FormatTestComments.cpp @@ -1909,6 +1909,14 @@ TEST_F(FormatTestComments, ReflowsComments) { "// @param arg", getLLVMStyleWithColumns(20))); + // Don't reflow lines starting with '\'. + EXPECT_EQ("// long long long\n" + "// long\n" + "// \\param arg", + format("// long long long long\n" + "// \\param arg", + getLLVMStyleWithColumns(20))); + // Don't reflow lines starting with 'TODO'. EXPECT_EQ("// long long long\n" "// long\n" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits