Skip to content

Commit d8d5628

Browse files
committed
Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"
Summary: This reverts commit db9e5e9a616d7fdd4d1ba4c3b2cd89d8a0238533 (rC333171). Mentioned change introduced unintended formatting of ObjC code due to split priorities inherited from C/C++, e.g.: ``` fooooooo = [ [obj fooo] aaa:42 aaa:42]; ``` instead of ``` fooooooo = [[obj fooo] aaa:42 aaa:42]; ``` when formatted with ColumnLimit = 30. Reviewers: krasimir Reviewed By: krasimir Subscribers: benhamilton, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D47527 llvm-svn: 333539
1 parent 28f048a commit d8d5628

File tree

2 files changed

+0
-58
lines changed

2 files changed

+0
-58
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,29 +1387,6 @@ void ContinuationIndenter::moveStatePastScopeCloser(LineState &State) {
13871387
(Current.is(tok::greater) && Current.is(TT_DictLiteral))))
13881388
State.Stack.pop_back();
13891389

1390-
// Reevaluate whether ObjC message arguments fit into one line.
1391-
// If a receiver spans multiple lines, e.g.:
1392-
// [[object block:^{
1393-
// return 42;
1394-
// }] a:42 b:42];
1395-
// BreakBeforeParameter is calculated based on an incorrect assumption
1396-
// (it is checked whether the whole expression fits into one line without
1397-
// considering a line break inside a message receiver).
1398-
// We check whether arguements fit after receiver scope closer (into the same
1399-
// line).
1400-
if (Current.MatchingParen && Current.MatchingParen->Previous) {
1401-
const FormatToken &CurrentScopeOpener = *Current.MatchingParen->Previous;
1402-
if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
1403-
CurrentScopeOpener.MatchingParen) {
1404-
int NecessarySpaceInLine =
1405-
getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
1406-
CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
1407-
if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
1408-
Style.ColumnLimit)
1409-
State.Stack.back().BreakBeforeParameter = false;
1410-
}
1411-
}
1412-
14131390
if (Current.is(tok::r_square)) {
14141391
// If this ends the array subscript expr, reset the corresponding value.
14151392
const FormatToken *NextNonComment = Current.getNextNonComment();

clang/unittests/Format/FormatTestObjC.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -796,41 +796,6 @@ TEST_F(FormatTestObjC, FormatObjCMethodExpr) {
796796
verifyFormat("[((Foo *)foo) bar];");
797797
verifyFormat("[((Foo *)foo) bar:1 blech:2];");
798798

799-
// Message receiver taking multiple lines.
800-
Style.ColumnLimit = 20;
801-
// Non-corner case.
802-
verifyFormat("[[object block:^{\n"
803-
" return 42;\n"
804-
"}] a:42 b:42];");
805-
// Arguments just fit into one line.
806-
verifyFormat("[[object block:^{\n"
807-
" return 42;\n"
808-
"}] aaaaaaa:42 b:42];");
809-
// Arguments just over a column limit.
810-
verifyFormat("[[object block:^{\n"
811-
" return 42;\n"
812-
"}] aaaaaaa:42\n"
813-
" bb:42];");
814-
// Arguments just fit into one line.
815-
Style.ColumnLimit = 23;
816-
verifyFormat("[[obj a:42\n"
817-
" b:42\n"
818-
" c:42\n"
819-
" d:42] e:42 f:42];");
820-
821-
// Arguments do not fit into one line with a receiver.
822-
Style.ColumnLimit = 20;
823-
verifyFormat("[[obj a:42] a:42\n"
824-
" b:42];");
825-
verifyFormat("[[obj a:42] a:42\n"
826-
" b:42\n"
827-
" c:42];");
828-
verifyFormat("[[obj aaaaaa:42\n"
829-
" b:42]\n"
830-
" cc:42\n"
831-
" d:42];");
832-
833-
834799
Style.ColumnLimit = 70;
835800
verifyFormat(
836801
"void f() {\n"

0 commit comments

Comments
 (0)