diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 7 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 16 |
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 9d73bf6c01e..83a5e1313a6 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -679,8 +679,13 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, if (Current.isMemberAccess()) State.Stack.back().StartOfFunctionCall = Current.LastOperator ? 0 : State.Column; - if (Current.is(TT_SelectorName)) + if (Current.is(TT_SelectorName)) { State.Stack.back().ObjCSelectorNameFound = true; + if (Style.IndentWrappedFunctionNames) { + State.Stack.back().Indent = + State.FirstIndent + Style.ContinuationIndentWidth; + } + } if (Current.is(TT_CtorInitializerColon)) { // Indent 2 from the column, so: // SomeClass::SomeClass() diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 1846aa68490..a154af931d9 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -7105,6 +7105,22 @@ TEST_F(FormatTest, FormatObjCMethodDeclarations) { " y:(id<yyyyyyyyyyyyyyyyyyyy>)y\n" " NS_DESIGNATED_INITIALIZER;", getLLVMStyleWithColumns(60)); + + // Continuation indent width should win over aligning colons if the function + // name is long. + FormatStyle continuationStyle = getGoogleStyle(); + continuationStyle.ColumnLimit = 40; + continuationStyle.IndentWrappedFunctionNames = true; + verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n" + " dontAlignNamef:(NSRect)theRect {\n" + "}", + continuationStyle); + + // Make sure we don't break aligning for short parameter names. + verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n" + " aShortf:(NSRect)theRect {\n" + "}", + continuationStyle); } TEST_F(FormatTest, FormatObjCMethodExpr) { |

