]> granicus.if.org Git - clang/commit
[clang-format] Fix ObjC message arguments formatting.
authorJacek Olesiak <jolesiak@google.com>
Wed, 7 Feb 2018 10:35:08 +0000 (10:35 +0000)
committerJacek Olesiak <jolesiak@google.com>
Wed, 7 Feb 2018 10:35:08 +0000 (10:35 +0000)
commit848874aed95a913fb45f363120500cebfe54e2ef
treec97ef60971929941a8d33be3e33e19b7e5694a93
parentf022963d5452a9dbc775f1a07d842577481e0c60
[clang-format] Fix ObjC message arguments formatting.

Summary:
Fixes formatting of ObjC message arguments when inline block is a first
argument.

Having inline block as a first argument when method has multiple parameters is
discouraged by Apple:
"It’s best practice to use only one block argument to a method. If the
method also needs other non-block arguments, the block should come last"
(https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW7),
it should be correctly formatted nevertheless.

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

Fixed (colon alignment):
```
[object
  blockArgument:^{
    a = 42;
  }
     anotherArg:42];
```

Test Plan: make -j12 FormatTests && tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, benhamilton

Reviewed By: krasimir, benhamilton

Subscribers: benhamilton, klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324469 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/ContinuationIndenter.cpp
lib/Format/FormatToken.h
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestObjC.cpp