diff options
| author | Ben Hamilton <benhamilton@google.com> | 2018-02-02 20:15:14 +0000 |
|---|---|---|
| committer | Ben Hamilton <benhamilton@google.com> | 2018-02-02 20:15:14 +0000 |
| commit | 4dc658ca520bb46a92f6b5c8636ce5dc5b5b27fc (patch) | |
| tree | 699398880a07a45871e1ae994d2774adb2acee79 /clang/unittests/Format | |
| parent | e7e147f52cb3deb6235ff62bcc46d76ead3f0ddb (diff) | |
| download | bcm5719-llvm-4dc658ca520bb46a92f6b5c8636ce5dc5b5b27fc.tar.gz bcm5719-llvm-4dc658ca520bb46a92f6b5c8636ce5dc5b5b27fc.zip | |
[clang-format] New format param ObjCBinPackProtocolList
Summary:
This is an alternative approach to D42014 after some
investigation by stephanemoore@ and myself.
Previously, the format parameter `BinPackParameters` controlled both
C function parameter list bin-packing and Objective-C protocol conformance
list bin-packing.
We found in the Google style, some teams were changing
`BinPackParameters` from its default (`true`) to `false` so they could
lay out Objective-C protocol conformance list items one-per-line
instead of bin-packing them into as few lines as possible.
To allow teams to use one-per-line Objective-C protocol lists without
changing bin-packing for other areas like C function parameter lists,
this diff introduces a new LibFormat parameter
`ObjCBinPackProtocolList` to control the behavior just for ObjC
protocol conformance lists.
The new parameter is an enum which defaults to `Auto` to keep the
previous behavior (delegating to `BinPackParameters`).
Depends On D42649
Test Plan: New tests added. make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests
Reviewers: jolesiak, stephanemoore, djasper
Reviewed By: stephanemoore
Subscribers: Wizard, hokein, cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D42650
llvm-svn: 324131
Diffstat (limited to 'clang/unittests/Format')
| -rw-r--r-- | clang/unittests/Format/FormatTestObjC.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/clang/unittests/Format/FormatTestObjC.cpp b/clang/unittests/Format/FormatTestObjC.cpp index 23e90663717..d9805859f66 100644 --- a/clang/unittests/Format/FormatTestObjC.cpp +++ b/clang/unittests/Format/FormatTestObjC.cpp @@ -281,8 +281,7 @@ TEST_F(FormatTestObjC, FormatObjCInterface) { " ccccccccccccc, ccccccccccccc,\n" " ccccccccccccc, ccccccccccccc> {\n" "}"); - - Style.BinPackParameters = false; + Style.ObjCBinPackProtocolList = FormatStyle::BPS_Never; verifyFormat("@interface ddddddddddddd () <\n" " ddddddddddddd,\n" " ddddddddddddd,\n" @@ -290,6 +289,20 @@ TEST_F(FormatTestObjC, FormatObjCInterface) { " ddddddddddddd> {\n" "}"); + Style.BinPackParameters = false; + Style.ObjCBinPackProtocolList = FormatStyle::BPS_Auto; + verifyFormat("@interface eeeeeeeeeeeee () <\n" + " eeeeeeeeeeeee,\n" + " eeeeeeeeeeeee,\n" + " eeeeeeeeeeeee,\n" + " eeeeeeeeeeeee> {\n" + "}"); + Style.ObjCBinPackProtocolList = FormatStyle::BPS_Always; + verifyFormat("@interface fffffffffffff () <\n" + " fffffffffffff, fffffffffffff,\n" + " fffffffffffff, fffffffffffff> {\n" + "}"); + Style = getGoogleStyle(FormatStyle::LK_ObjC); verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n" " @public\n" |

