[PATCH] D70926: [clang-format] Add option for not breaking line before ObjC params

Kanglei Fang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 14:39:01 PST 2019


ghvg1313 marked 2 inline comments as done.
ghvg1313 added inline comments.


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:869
       State.Stack[i].BreakBeforeParameter = true;
 
   if (PreviousNonComment &&
----------------
ghvg1313 wrote:
> MyDeveloperDay wrote:
> > I'm a little confused by the code, this feels to me like its covering something more than a specific than just the ObjectiveC case, what is meant here by a nestedblockspecialcase? this feels like we are turning off BreakBeforeParameter by another method?
> > 
> > I get the code below, just wondering why this is also needed.
> I think you are right, bin packing is already avoided as the comment says so I don't have to do anything extra.
> 
> Was trying to handle linebreaking within block as well. Not needed indeed.
Notice I get this back again, it's actually to avoid parameter break in between blocks, so we don't get inconsistent parameter break between blocks, for example: 
```
- (void)_aMethod
{
    [self.test1 t:self
                    w:self
         callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
             u = c;
         } x:self callback2:^(typeof(self) self, NSNumber *u, NSNumber *v) {
             u = c;
         }]
}
```

Originally, the second block will trigger the parameter break in between itself and the previous block.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70926/new/

https://reviews.llvm.org/D70926





More information about the cfe-commits mailing list