diff options
author | Ben Hamilton <benhamilton@google.com> | 2018-04-12 15:11:55 +0000 |
---|---|---|
committer | Ben Hamilton <benhamilton@google.com> | 2018-04-12 15:11:55 +0000 |
commit | 01cbd5aa686b7b50cf5b099c8a37b6ac2cfd05df (patch) | |
tree | 6745e90cebebe99ce5a55ddc574afe629f111f6a /clang/unittests/Format/FormatTestObjC.cpp | |
parent | b1a7919e4cd0175ec08a3efb3c183913e21628ba (diff) | |
download | bcm5719-llvm-01cbd5aa686b7b50cf5b099c8a37b6ac2cfd05df.tar.gz bcm5719-llvm-01cbd5aa686b7b50cf5b099c8a37b6ac2cfd05df.zip |
[clang-format] Do not break after ObjC category open paren
Summary:
Previously, `clang-format` would break Objective-C
category extensions after the opening parenthesis to avoid
breaking the protocol list:
```
% echo "@interface ccccccccccccc (ccccccccccc) <ccccccccccccc> { }" | \
clang-format -assume-filename=foo.h -style="{BasedOnStyle: llvm, \
ColumnLimit: 40}"
@interface ccccccccccccc (
ccccccccccc) <ccccccccccccc> {
}
```
This looks fairly odd, as we could have kept the category extension
on the previous line.
Category extensions are a single item, so they are generally very
short compared to protocol lists. We should prefer breaking after the
opening `<` of the protocol list over breaking after the opening `(`
of the category extension.
With this diff, we now avoid breaking after the category extension's
open paren, which causes us to break after the protocol list's
open angle bracket:
```
% echo "@interface ccccccccccccc (ccccccccccc) <ccccccccccccc> { }" | \
./bin/clang-format -assume-filename=foo.h -style="{BasedOnStyle: llvm, \
ColumnLimit: 40}"
@interface ccccccccccccc (ccccccccccc) <
ccccccccccccc> {
}
```
Test Plan: New test added. Confirmed test failed before diff and
passed after diff by running:
% make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests
Reviewers: djasper, jolesiak
Reviewed By: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D45526
llvm-svn: 329919
Diffstat (limited to 'clang/unittests/Format/FormatTestObjC.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestObjC.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestObjC.cpp b/clang/unittests/Format/FormatTestObjC.cpp index 9c8f252143f..b878d7886e1 100644 --- a/clang/unittests/Format/FormatTestObjC.cpp +++ b/clang/unittests/Format/FormatTestObjC.cpp @@ -334,6 +334,9 @@ TEST_F(FormatTestObjC, FormatObjCInterface) { " ccccccccccccc, ccccccccccccc,\n" " ccccccccccccc, ccccccccccccc> {\n" "}"); + verifyFormat("@interface ccccccccccccc (ccccccccccc) <\n" + " ccccccccccccc> {\n" + "}"); Style.ObjCBinPackProtocolList = FormatStyle::BPS_Never; verifyFormat("@interface ddddddddddddd () <\n" " ddddddddddddd,\n" |