This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Don't break multi block parameters on ObjCBreakBeforeNestedBlockParam
ClosedPublic

Authored by ghvg1313 on Mar 30 2020, 12:41 AM.

Details

Summary

While the original diff makes a lot of sense, and multiple inline block parameter/trailing paramemter after inline block paramemter should be discouraged, the formatting result is different than what xcode does by default
For the exact same example provided in the original diff:

[object
  blockArgument:^{
    a = 42;
  }
     anotherArg:42];

The code is hard to read and not very visually pleasing

This diff uses ObjCBreakBeforeNestedBlockParam to shield from the formatting
When it's set to false, don't allign the inline block paramemters.

Diff Detail

Event Timeline

ghvg1313 created this revision.Mar 30 2020, 12:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2020, 12:41 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jolesiak accepted this revision.Mar 31 2020, 1:40 AM

Makes sense, thanks for patching this!

This revision is now accepted and ready to land.Mar 31 2020, 1:40 AM
ghvg1313 updated this revision to Diff 254014.Mar 31 2020, 3:04 PM
  • Fix documentation formatting
ghvg1313 updated this revision to Diff 254015.Mar 31 2020, 3:05 PM

reset diff's base

@jolesiak I don't yet have the commit access, do you mind help merging this diff? Thanks

Harbormaster completed remote builds in B51200: Diff 254015.
ghvg1313 edited reviewers, added: jinlin; removed: MyDeveloperDay.Apr 6 2020, 10:23 AM
This revision was automatically updated to reflect the committed changes.
MyDeveloperDay added a project: Restricted Project.

what is changing in clang/docs/ClangFormatStyleOptions.rst? if nothing then remove from the diff

what is changing in clang/docs/ClangFormatStyleOptions.rst? if nothing then remove from the diff

there's an indentation issue, this changes the example of the doc from:

- (void)_aMethod
     {
        [self.test1 t:self
                     w:self
            callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
                u = c;
             }]
}

to

- (void)_aMethod
{
   [self.test1 t:self
               w:self
        callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
            u = c;
        }]
}