[all-commits] [llvm/llvm-project] 70c986: [clang-format] Add option for not breaking line be...

MyDeveloperDay via All-commits all-commits at lists.llvm.org
Sat Feb 1 09:39:47 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 70c98671fa7b395a52829b91782393f4c2613562
      https://github.com/llvm/llvm-project/commit/70c98671fa7b395a52829b91782393f4c2613562
  Author: mydeveloperday <mydeveloperday at gmail.com>
  Date:   2020-02-01 (Sat, 01 Feb 2020)

  Changed paths:
    M clang/docs/ClangFormatStyleOptions.rst
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Format/Format.h
    M clang/lib/Format/ContinuationIndenter.cpp
    M clang/lib/Format/Format.cpp
    M clang/unittests/Format/FormatTestObjC.cpp

  Log Message:
  -----------
  [clang-format] Add option for not breaking line before ObjC params

Summary:
>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.

Reviewed By: MyDeveloperDay

Patch By: ghvg1313

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D70926




More information about the All-commits mailing list