Author: Owen Pan
Date: 2025-04-22T23:49:26-07:00
New Revision: da8f2d52423bb82b5d4e75cff3018704effe044f

URL: 
https://github.com/llvm/llvm-project/commit/da8f2d52423bb82b5d4e75cff3018704effe044f
DIFF: 
https://github.com/llvm/llvm-project/commit/da8f2d52423bb82b5d4e75cff3018704effe044f.diff

LOG: Revert "[clang-format] Allow breaking before kw___attribute (#128623)"

This reverts commit 8fc8a84e23471fe56214e68706addc712b5a2949, which caused a
regression.

Fixes #136675.

Added: 
    

Modified: 
    clang/lib/Format/TokenAnnotator.cpp
    clang/unittests/Format/FormatTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 6d861d19117e2..3e17c688dbcce 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -6242,8 +6242,6 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
                     TT_ClassHeadName, tok::kw_operator)) {
     return true;
   }
-  if (Right.isAttribute())
-    return true;
   if (Left.is(TT_PointerOrReference))
     return false;
   if (Right.isTrailingComment()) {
@@ -6388,6 +6386,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
                           tok::less, tok::coloncolon);
   }
 
+  if (Right.isAttribute())
+    return true;
+
   if (Right.is(tok::l_square) && Right.is(TT_AttributeSquare))
     return Left.isNot(TT_AttributeSquare);
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index f1b3b7dd8c0c3..8543c1b565d6d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12645,9 +12645,6 @@ TEST_F(FormatTest, UnderstandsAttributes) {
   verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((unused))\n"
                "aaaaaaaaaaaaaaaaaaaaaaa(int i);");
   verifyFormat("__attribute__((nodebug)) ::qualified_type f();");
-  verifyFormat(
-      "RenderWidgetHostViewCocoa *\n"
-      "    __attribute__((objc_precise_lifetime)) keepSelfAlive = self;");
   FormatStyle AfterType = getLLVMStyle();
   AfterType.BreakAfterReturnType = FormatStyle::RTBS_All;
   verifyFormat("__attribute__((nodebug)) void\n"


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

Reply via email to