https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/70360
>From 3866a77d62a34e612ff869cde7c743e31350eed2 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov <serebrennikov.vladis...@gmail.com> Date: Thu, 26 Oct 2023 20:41:25 +0300 Subject: [PATCH 1/2] [clang-format] Change LLVM style to BreakAfterAttributes == ABS_Leave --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Format/Format.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 7 +++---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 7238386231e1a28..6cd5e3e077e6f3c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -794,6 +794,7 @@ clang-format ------------ - Add ``AllowBreakBeforeNoexceptSpecifier`` option. - Add ``AllowShortCompoundRequirementOnASingleLine`` option. +- Change ``BreakAfterAttributes`` from ``Never`` to ``Leave`` in LLVM style libclang -------- diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index edb33f4af4defef..e1abcac5604a410 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1476,7 +1476,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { /*SplitEmptyFunction=*/true, /*SplitEmptyRecord=*/true, /*SplitEmptyNamespace=*/true}; - LLVMStyle.BreakAfterAttributes = FormatStyle::ABS_Never; + LLVMStyle.BreakAfterAttributes = FormatStyle::ABS_Leave; LLVMStyle.BreakAfterJavaFieldAnnotations = false; LLVMStyle.BreakArrays = true; LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index b2d84f2ee389551..5cec49a9173e824 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -26179,7 +26179,7 @@ TEST_F(FormatTest, RemoveSemicolon) { TEST_F(FormatTest, BreakAfterAttributes) { FormatStyle Style = getLLVMStyle(); - EXPECT_EQ(Style.BreakAfterAttributes, FormatStyle::ABS_Never); + EXPECT_EQ(Style.BreakAfterAttributes, FormatStyle::ABS_Leave); constexpr StringRef Code("[[nodiscard]] inline int f(int &i);\n" "[[foo([[]])]] [[nodiscard]]\n" @@ -26193,7 +26193,9 @@ TEST_F(FormatTest, BreakAfterAttributes) { " i = 0;\n" " return 1;\n" "}"); + verifyNoChange(Code, Style); + Style.BreakAfterAttributes = FormatStyle::ABS_Never; verifyFormat("[[nodiscard]] inline int f(int &i);\n" "[[foo([[]])]] [[nodiscard]] int g(int &i);\n" "[[nodiscard]] inline int f(int &i) {\n" @@ -26206,9 +26208,6 @@ TEST_F(FormatTest, BreakAfterAttributes) { "}", Code, Style); - Style.BreakAfterAttributes = FormatStyle::ABS_Leave; - verifyNoChange(Code, Style); - Style.BreakAfterAttributes = FormatStyle::ABS_Always; verifyFormat("[[nodiscard]]\n" "inline int f(int &i);\n" >From e1faae463bd6a20b487386c7ca15d631846b4ec4 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov <serebrennikov.vladis...@gmail.com> Date: Fri, 27 Oct 2023 14:44:56 +0300 Subject: [PATCH 2/2] Address Owen's feedback --- clang/docs/ReleaseNotes.rst | 2 +- clang/unittests/Format/FormatTest.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6cd5e3e077e6f3c..fb0492f661ed374 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -794,7 +794,7 @@ clang-format ------------ - Add ``AllowBreakBeforeNoexceptSpecifier`` option. - Add ``AllowShortCompoundRequirementOnASingleLine`` option. -- Change ``BreakAfterAttributes`` from ``Never`` to ``Leave`` in LLVM style +- Change ``BreakAfterAttributes`` from ``Never`` to ``Leave`` in LLVM style. libclang -------- diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 5cec49a9173e824..15c12c2b8b0da3f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -26179,7 +26179,6 @@ TEST_F(FormatTest, RemoveSemicolon) { TEST_F(FormatTest, BreakAfterAttributes) { FormatStyle Style = getLLVMStyle(); - EXPECT_EQ(Style.BreakAfterAttributes, FormatStyle::ABS_Leave); constexpr StringRef Code("[[nodiscard]] inline int f(int &i);\n" "[[foo([[]])]] [[nodiscard]]\n" @@ -26193,6 +26192,8 @@ TEST_F(FormatTest, BreakAfterAttributes) { " i = 0;\n" " return 1;\n" "}"); + + EXPECT_EQ(Style.BreakAfterAttributes, FormatStyle::ABS_Leave); verifyNoChange(Code, Style); Style.BreakAfterAttributes = FormatStyle::ABS_Never; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits