llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: owenca (owenca) <details> <summary>Changes</summary> Fixes #<!-- -->199775 --- Full diff: https://github.com/llvm/llvm-project/pull/200721.diff 2 Files Affected: - (modified) clang/lib/Format/TokenAnnotator.cpp (+2) - (modified) clang/unittests/Format/FormatTest.cpp (+17-6) ``````````diff diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 43e4f6796b6dd..cc49be513fa0c 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -6498,6 +6498,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, !(Right.Next && Right.Next->isOneOf(TT_FunctionDeclarationName, tok::kw_const))); } + if (Left.is(tok::hashhash) || Right.is(tok::hashhash)) + return false; if (Right.isOneOf(TT_StartOfName, TT_FunctionDeclarationName, TT_ClassHeadName, TT_QtProperty, tok::kw_operator)) { return true; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 83e2c5b38ceaf..5fd9a7a13f0bb 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5967,22 +5967,33 @@ TEST_F(FormatTest, HashInMacroDefinition) { verifyFormat("#define A(c) uR#c"); verifyFormat("#define A(c) UR#c"); verifyFormat("#define A(c) u8R#c"); - verifyFormat("#define A \\\n b #c;", getLLVMStyleWithColumns(11)); + + auto Style = getLLVMStyleWithColumns(11); + verifyFormat("#define A \\\n b #c;", Style); verifyFormat("#define A \\\n" " { \\\n" " f(#c); \\\n" " }", - getLLVMStyleWithColumns(11)); + Style); + Style.ColumnLimit = 22; verifyFormat("#define A(X) \\\n" " void function##X()", - getLLVMStyleWithColumns(22)); - + Style); verifyFormat("#define A(a, b, c) \\\n" " void a##b##c()", - getLLVMStyleWithColumns(22)); + Style); + verifyFormat("#define A void # ## #", Style); - verifyFormat("#define A void # ## #", getLLVMStyleWithColumns(22)); + Style.ColumnLimit = 60; + Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign; + verifyFormat( + "#define MACRO(Name) \\\n" + " struct LongPrefix##Name##LongSuffix< \\\n" + " VeryLongTemplateArgument> {};", + "#define MACRO(Name) \\\n" + " struct LongPrefix##Name##LongSuffix<VeryLongTemplateArgument> {};", + Style); verifyFormat("{\n" " {\n" `````````` </details> https://github.com/llvm/llvm-project/pull/200721 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
