r236597 - clang-format: Properly indent method calls without inputs.

Daniel Jasper djasper at google.com
Wed May 6 05:48:06 PDT 2015


Author: djasper
Date: Wed May  6 07:48:06 2015
New Revision: 236597

URL: http://llvm.org/viewvc/llvm-project?rev=236597&view=rev
Log:
clang-format: Properly indent method calls without inputs.

Before:
  [aaaaaaaaaaa
          aaaaaaa];

After:
  [aaaaaaaaaaa
      aaaaaaa];

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=236597&r1=236596&r2=236597&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed May  6 07:48:06 2015
@@ -584,10 +584,12 @@ unsigned ContinuationIndenter::getNewLin
       return State.Stack.back().StartOfArraySubscripts;
     return ContinuationIndent;
   }
+  if (NextNonComment->is(TT_StartOfName) && NextNonComment->Next &&
+      NextNonComment->Next->is(TT_ObjCMethodExpr))
+    return State.Stack.back().Indent;
   if (NextNonComment->isOneOf(TT_StartOfName, TT_PointerOrReference) ||
-      Previous.isOneOf(tok::coloncolon, tok::equal)) {
+      Previous.isOneOf(tok::coloncolon, tok::equal))
     return ContinuationIndent;
-  }
   if (PreviousNonComment && PreviousNonComment->is(tok::colon) &&
       PreviousNonComment->isOneOf(TT_ObjCMethodExpr, TT_DictLiteral))
     return ContinuationIndent;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=236597&r1=236596&r2=236597&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May  6 07:48:06 2015
@@ -7144,6 +7144,8 @@ TEST_F(FormatTest, FormatObjCMethodExpr)
                "             fraction:1.0\n"
                "       respectFlipped:NO\n"
                "                hints:nil];");
+  verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+               "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];");
 
   verifyFormat(
       "scoped_nsobject<NSTextField> message(\n"





More information about the cfe-commits mailing list