https://github.com/XDeme updated https://github.com/llvm/llvm-project/pull/76336
>From 24aa5e41505eebb64288e7369a3b4f35ee0214fc Mon Sep 17 00:00:00 2001 From: XDeme <fernando.tagawa.gamail....@gmail.com> Date: Sun, 24 Dec 2023 11:27:31 -0300 Subject: [PATCH 1/2] [clang-format] Fix bad indentation with attribute and templated type --- clang/lib/Format/ContinuationIndenter.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 8489a30dd34ab3..102504182c4505 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -398,7 +398,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { } if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) || (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) && - Style.isCpp() && + State.Line->First->isNot(TT_AttributeSquare) && Style.isCpp() && // FIXME: This is a temporary workaround for the case where clang-format // sets BreakBeforeParameter to avoid bin packing and this creates a // completely unnecessary line break after a template type that isn't diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 762fc8254bdfc9..d5265aa230c7d2 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -26492,6 +26492,10 @@ TEST_F(FormatTest, BreakAfterAttributes) { verifyFormat("[[nodiscard]]\n" "Foo& operator-(Foo&);", Style); + + verifyFormat("[[maybe_unused]]\n" + "foo<int> f;", + Style); } TEST_F(FormatTest, InsertNewlineAtEOF) { >From d049c7f8169d1766363638b50365d8562bc6df7d Mon Sep 17 00:00:00 2001 From: XDeme <fernando.tagawa.gamail....@gmail.com> Date: Fri, 29 Dec 2023 11:48:47 -0300 Subject: [PATCH 2/2] Addresses comments --- clang/unittests/Format/FormatTest.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d5265aa230c7d2..881993ede17c3d 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -26295,6 +26295,8 @@ TEST_F(FormatTest, BreakAfterAttributes) { constexpr StringRef Code("[[maybe_unused]] const int i;\n" "[[foo([[]])]] [[maybe_unused]]\n" "int j;\n" + "[[maybe_unused]]\n" + "foo<int> k;\n" "[[nodiscard]] inline int f(int &i);\n" "[[foo([[]])]] [[nodiscard]]\n" "int g(int &i);\n" @@ -26315,6 +26317,7 @@ TEST_F(FormatTest, BreakAfterAttributes) { Style.BreakAfterAttributes = FormatStyle::ABS_Never; verifyFormat("[[maybe_unused]] const int i;\n" "[[foo([[]])]] [[maybe_unused]] int j;\n" + "[[maybe_unused]] foo<int> k;\n" "[[nodiscard]] inline int f(int &i);\n" "[[foo([[]])]] [[nodiscard]] int g(int &i);\n" "[[nodiscard]] inline int f(int &i) {\n" @@ -26332,6 +26335,8 @@ TEST_F(FormatTest, BreakAfterAttributes) { "const int i;\n" "[[foo([[]])]] [[maybe_unused]]\n" "int j;\n" + "[[maybe_unused]]\n" + "foo<int> k;\n" "[[nodiscard]]\n" "inline int f(int &i);\n" "[[foo([[]])]] [[nodiscard]]\n" @@ -26492,10 +26497,6 @@ TEST_F(FormatTest, BreakAfterAttributes) { verifyFormat("[[nodiscard]]\n" "Foo& operator-(Foo&);", Style); - - verifyFormat("[[maybe_unused]]\n" - "foo<int> f;", - Style); } TEST_F(FormatTest, InsertNewlineAtEOF) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits