This is an archive of the discontinued LLVM Phabricator instance.

Allow PenaltyBreakBeforeFirstCallParameter to not break Obj-C call before first parameter
Needs ReviewPublic

Authored by kmensah on Jul 17 2015, 9:14 AM.

Details

Reviewers
djasper
Summary

Patch to prefer not breaking before the first parameter on an Objective-c method call if possible.

Diff Detail

Repository
rL LLVM

Event Timeline

kmensah updated this revision to Diff 30006.Jul 17 2015, 9:14 AM
kmensah retitled this revision from to Allow PenaltyBreakBeforeFirstCallParameter to not break Obj-C call before first parameter.
kmensah updated this object.
kmensah set the repository for this revision to rL LLVM.
kmensah updated this revision to Diff 30007.Jul 17 2015, 9:14 AM
kmensah added a reviewer: djasper.
kmensah added a subscriber: cfe-commits.
djasper added inline comments.Jul 17 2015, 9:25 AM
lib/Format/TokenAnnotator.cpp
1751

I think this doesn't work yet, as the callee can also be the result of an expression, right?

so: [[self a] a:b c:d];

But I think you can just check whether Right.LongestObjCSelectorName is != 0. This value should only be set for the first selector.

kmensah updated this object.Jul 21 2015, 7:38 AM
kmensah updated this revision to Diff 30257.Jul 21 2015, 8:08 AM

Fixing per djasper's comments.

kmensah updated this revision to Diff 30276.Jul 21 2015, 12:08 PM
kmensah marked an inline comment as done.

Fixing obj-c method calls with no parameters and and adding unit test for when callee is an expression.

Ready for review again.

djasper added inline comments.Jul 21 2015, 4:06 PM
lib/Format/TokenAnnotator.cpp
1701–1706

I don't understand this change. Could you elaborate?

unittests/Format/FormatTest.cpp
7343–7344

No, this is exactly as many spaces as intended. It is 4 spaces from "function".

kmensah updated this revision to Diff 30405.Jul 22 2015, 2:55 PM

Fixing per comments from djasper

Responding to comments form djasper

lib/Format/TokenAnnotator.cpp
1701–1706

without this single Objective-C calls with no parameters ([self foo]) didn't have PenaltyBreakBeforeFirstCallParameter applied to stop a break before "foo". I wanted to return the max between the old default of 200 and PenaltyBreakBeforeFirstCallParameter but didn't want to have specify 200 multiple times.

unittests/Format/FormatTest.cpp
7343–7344

Removed that statement.