https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/140361

Fix #139510

>From f7528c42b4c1cce3a04722d2eadca3b81305cc5e Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpi...@gmail.com>
Date: Fri, 16 May 2025 22:50:35 -0700
Subject: [PATCH] [clang-format] Fix the indent of StartOfName after
 AttributeMacro

Fix #139510
---
 clang/lib/Format/ContinuationIndenter.cpp | 2 ++
 clang/unittests/Format/FormatTest.cpp     | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 55e1d1ceb55b7..b31fb29e7c4a0 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1475,6 +1475,8 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
        (PreviousNonComment->ClosesTemplateDeclaration ||
         PreviousNonComment->ClosesRequiresClause ||
         (PreviousNonComment->is(TT_AttributeMacro) &&
+         !Current.endsSequence(TT_StartOfName, TT_AttributeMacro,
+                               TT_PointerOrReference) &&
          Current.isNot(tok::l_paren)) ||
         PreviousNonComment->isOneOf(
             TT_AttributeRParen, TT_AttributeSquare, 
TT_FunctionAnnotationRParen,
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 436beaf68bd2a..8fe57c80cbe25 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12714,6 +12714,13 @@ TEST_F(FormatTest, UnderstandsAttributes) {
   verifyGoogleFormat("SomeType* absl_nullable s{InitValue};");
   verifyGoogleFormat("SomeType* absl_nullability_unknown s(InitValue);");
   verifyGoogleFormat("SomeType* absl_nullability_unknown s{InitValue};");
+
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.AttributeMacros.push_back("my_fancy_attr");
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("void foo(const MyLongTypeNameeeeeeeeeeeee* my_fancy_attr\n"
+               "             testttttttttt);",
+               Style);
 }
 
 TEST_F(FormatTest, UnderstandsPointerQualifiersInCast) {

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to