diff options
author | Jacek Olesiak <jolesiak@google.com> | 2018-07-09 06:54:52 +0000 |
---|---|---|
committer | Jacek Olesiak <jolesiak@google.com> | 2018-07-09 06:54:52 +0000 |
commit | 6b475b730b1c0414cc573c89db986705828cc0a8 (patch) | |
tree | a0d5b7c70f912eecdcb5a35a20561e95e2583562 /clang/unittests | |
parent | e7c4b5901e614444c9f0e9531ad00a4526d85c8a (diff) | |
download | bcm5719-llvm-6b475b730b1c0414cc573c89db986705828cc0a8.tar.gz bcm5719-llvm-6b475b730b1c0414cc573c89db986705828cc0a8.zip |
[clang-format/ObjC] Improve split priorities for ObjC methods
Reduce penalty for aligning ObjC method arguments using the colon alignment as
this is the canonical way.
Trying to fit a whole expression into one line should not force other line
breaks (e.g. when ObjC method expression is a part of other expression).
llvm-svn: 336520
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Format/FormatTestObjC.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/clang/unittests/Format/FormatTestObjC.cpp b/clang/unittests/Format/FormatTestObjC.cpp index 9d086551b25..58e75363a55 100644 --- a/clang/unittests/Format/FormatTestObjC.cpp +++ b/clang/unittests/Format/FormatTestObjC.cpp @@ -678,6 +678,18 @@ TEST_F(FormatTestObjC, FormatObjCMethodExpr) { verifyFormat("[(id)foo bar:(id) ? baz : quux];"); verifyFormat("4 > 4 ? (id)a : (id)baz;"); + unsigned PreviousColumnLimit = Style.ColumnLimit; + Style.ColumnLimit = 50; + // Instead of: + // bool a = + // ([object a:42] == 0 || [object a:42 + // b:42] == 0); + verifyFormat("bool a = ([object a:42] == 0 ||\n" + " [object a:42 b:42] == 0);"); + Style.ColumnLimit = PreviousColumnLimit; + verifyFormat("bool a = ([aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaa ||\n" + " [aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaaaaa);"); + // This tests that the formatter doesn't break after "backing" but before ":", // which would be at 80 columns. verifyFormat( @@ -754,11 +766,10 @@ TEST_F(FormatTestObjC, FormatObjCMethodExpr) { "[self aaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];"); + verifyFormat("[self // break\n" " a:a\n" " aaa:aaa];"); - verifyFormat("bool a = ([aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaa ||\n" - " [aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaaaaa);"); // Formats pair-parameters. verifyFormat("[I drawRectOn:surface ofSize:aa:bbb atOrigin:cc:dd];"); @@ -803,6 +814,12 @@ TEST_F(FormatTestObjC, FormatObjCMethodExpr) { verifyFormat("[((Foo *)foo) bar];"); verifyFormat("[((Foo *)foo) bar:1 blech:2];"); + Style.ColumnLimit = 20; + verifyFormat("aaaaa = [a aa:aa\n" + " aa:aa];"); + verifyFormat("aaaaaa = [aa aa:aa\n" + " aa:aa];"); + Style.ColumnLimit = 70; verifyFormat( "void f() {\n" |