diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 2595737e8b3b1..bc28bb567f693 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -820,6 +820,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 edb33f4af4def..e1abcac5604a4 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 b2d84f2ee3895..15c12c2b8b0da 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_Never); constexpr StringRef Code("[[nodiscard]] inline int f(int &i);\n" "[[foo([[]])]] [[nodiscard]]\n" @@ -26194,6 +26193,10 @@ TEST_F(FormatTest, BreakAfterAttributes) { " return 1;\n" "}"); + EXPECT_EQ(Style.BreakAfterAttributes, FormatStyle::ABS_Leave); + 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 +26209,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"