r176260 - Dont break between (( in __attribute__((.

Daniel Jasper djasper at google.com
Thu Feb 28 06:44:26 PST 2013


Author: djasper
Date: Thu Feb 28 08:44:25 2013
New Revision: 176260

URL: http://llvm.org/viewvc/llvm-project?rev=176260&view=rev
Log:
Dont break between (( in __attribute__((.

Before:
void aaaaaaaaaaaaaaaaaa() __attribute__(
    (aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
     aaaaaaaaaaaaaaaaaaaaaaaaa));

After:
void aaaaaaaaaaaaaaaaaa()
    __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
                   aaaaaaaaaaaaaaaaaaaaaaaaa));

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=176260&r1=176259&r2=176260&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Feb 28 08:44:25 2013
@@ -1092,6 +1092,9 @@ bool TokenAnnotator::canBreakBefore(cons
     return false;
   if (Left.is(tok::equal) && Line.Type == LT_VirtualFunctionDecl)
     return false;
+  if (Left.is(tok::l_paren) && Right.is(tok::l_paren) && Left.Parent &&
+      Left.Parent->is(tok::kw___attribute))
+    return false;
 
   if (Right.Type == TT_LineComment)
     // We rely on MustBreakBefore being set correctly here as we should not
@@ -1120,7 +1123,7 @@ bool TokenAnnotator::canBreakBefore(cons
          Right.is(tok::colon) || Left.is(tok::coloncolon) ||
          Left.is(tok::semi) || Left.is(tok::l_brace) ||
          (Left.is(tok::r_paren) && Left.Type != TT_CastRParen &&
-          Right.is(tok::identifier)) ||
+          (Right.is(tok::identifier) || Right.is(tok::kw___attribute))) ||
          (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
          (Left.is(tok::l_square) && !Right.is(tok::r_square));
 }

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=176260&r1=176259&r2=176260&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Feb 28 08:44:25 2013
@@ -1334,6 +1334,10 @@ TEST_F(FormatTest, DoesNotBreakTrailingA
                "    GUARDED_BY(aaaaaaaaaaaaa);");
   verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
                "    GUARDED_BY(aaaaaaaaaaaaa) {}");
+  verifyFormat(
+      "void aaaaaaaaaaaaaaaaaa()\n"
+      "    __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa,\n"
+      "                   aaaaaaaaaaaaaaaaaaaaaaaaa));");
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {





More information about the cfe-commits mailing list