forked from OSchip/llvm-project
clang-format: Fix bad wrapping of ObjC method exprs.
Before: [aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa: aaaaaaaa aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]; After: [aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa:aaaaaaaa aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]; Note that this might now violate the column limit and we probably need an alternative way of indenting these then. However, that is still strictly better than the messy formatting that clang-format did before. llvm-svn: 236598
This commit is contained in:
parent
eb53668c35
commit
2746a308c2
|
@ -166,6 +166,9 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
|
|||
((Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All) ||
|
||||
Style.BreakConstructorInitializersBeforeComma || Style.ColumnLimit != 0))
|
||||
return true;
|
||||
if (Current.is(TT_SelectorName) && State.Stack.back().ObjCSelectorNameFound &&
|
||||
State.Stack.back().BreakBeforeParameter)
|
||||
return true;
|
||||
|
||||
if (State.Column < getNewLineColumn(State))
|
||||
return false;
|
||||
|
@ -203,9 +206,6 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
|
|||
State.Stack.back().FirstLessLess == 0)
|
||||
return true;
|
||||
|
||||
if (Current.is(TT_SelectorName) && State.Stack.back().ObjCSelectorNameFound &&
|
||||
State.Stack.back().BreakBeforeParameter)
|
||||
return true;
|
||||
if (Current.NestingLevel == 0 && !Current.isTrailingComment()) {
|
||||
if (Previous.ClosesTemplateDeclaration)
|
||||
return true;
|
||||
|
|
|
@ -7162,6 +7162,13 @@ TEST_F(FormatTest, FormatObjCMethodExpr) {
|
|||
" aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |\n"
|
||||
" aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa];");
|
||||
|
||||
// FIXME: This violates the column limit.
|
||||
verifyFormat(
|
||||
"[aaaaaaaaaaaaaaaaaaaaaaaaa\n"
|
||||
" aaaaaaaaaaaaaaaaa:aaaaaaaa\n"
|
||||
" aaa:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];",
|
||||
getLLVMStyleWithColumns(60));
|
||||
|
||||
// Variadic parameters.
|
||||
verifyFormat(
|
||||
"NSArray *myStrings = [NSArray stringarray:@\"a\", @\"b\", nil];");
|
||||
|
|
Loading…
Reference in New Issue