From bcfe0a32234b16a2d3f0559f71eff6475e79fabe Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 6 May 2015 12:48:06 +0000 Subject: [PATCH] clang-format: Properly indent method calls without inputs. Before: [aaaaaaaaaaa aaaaaaa]; After: [aaaaaaaaaaa aaaaaaa]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236597 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 6 ++++-- unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 44b86a76ef..83f719bd1c 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -584,10 +584,12 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) { 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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index ea15312eb5..c0441495b8 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -7144,6 +7144,8 @@ TEST_F(FormatTest, FormatObjCMethodExpr) { " fraction:1.0\n" " respectFlipped:NO\n" " hints:nil];"); + verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];"); verifyFormat( "scoped_nsobject message(\n" -- 2.40.0