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

Kanglei Fang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 2 14:20:14 PST 2019


ghvg1313 created this revision.
ghvg1313 added a reviewer: klimek.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

>From `clang-format` version 3.7.0 and up, , there is no way to keep following format of ObjectiveC block:

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

Regardless of the change in `.clang-format` configuration file, all parameters will be lined up so that colons will be on the same column, like following:

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

Considering with ObjectiveC, the first code style is cleaner & more readable for some people, I've added a config option: `ObjCDontBreakBeforeNestedBlockParam` (boolean) so that if it is enable, the first code style will be favored.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70926

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70926.231780.patch
Type: text/x-patch
Size: 4874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191202/0bc08a8a/attachment.bin>


More information about the cfe-commits mailing list