Author: Fernando Tagawa Date: 2024-02-06T21:23:12-03:00 New Revision: 1b03cbc93989c84ad0b78c27d4427a7eaa5842f1
URL: https://github.com/llvm/llvm-project/commit/1b03cbc93989c84ad0b78c27d4427a7eaa5842f1 DIFF: https://github.com/llvm/llvm-project/commit/1b03cbc93989c84ad0b78c27d4427a7eaa5842f1.diff LOG: [clang-format] Handle doxygen commands starting with \ (#80381) Fixes llvm/llvm-project#63241 Doxygen commands can start with `@` or `\`. 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 473908e8fee3b3..75304908dc6506 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 c249f4d9333fd0..d705cf34d8af02 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 '\'. + verifyFormat("// long long long\n" + "// long\n" + "// \\param arg", + "// 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