diff options
author | Daniel Jasper <djasper@google.com> | 2013-11-21 01:46:33 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-11-21 01:46:33 +0000 |
commit | a78d7d45022522f9bb04ee2ac801222f93a48e86 (patch) | |
tree | f6b2dfd2ee1647d731de8463e7c511f01cc3778d | |
parent | 29b8fc4da9abc1c599899c3cd90dfb88fcd71562 (diff) | |
download | bcm5719-llvm-a78d7d45022522f9bb04ee2ac801222f93a48e86.tar.gz bcm5719-llvm-a78d7d45022522f9bb04ee2ac801222f93a48e86.zip |
clang-format: Improve formatting of ObjC method expressions.
In particular, make breaking after a parameter's ":" more of a last
resort choice as it significantly affects the readability gained by
aligning the parameters.
Before (in Chromium style - which doesn't allow bin-packing):
{
popup_window_.reset([[RenderWidgetPopupWindow alloc]
initWithContentRect:
NSMakeRect(
origin_global.x, origin_global.y, pos.width(), pos.height())
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO]);
}
After:
{
popup_window_.reset([[RenderWidgetPopupWindow alloc]
initWithContentRect:NSMakeRect(origin_global.x,
origin_global.y,
pos.width(),
pos.height())
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO]);
}
llvm-svn: 195301
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index fe5ab5df03d..7bba0362c4a 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1181,7 +1181,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Right.Type == TT_ObjCSelectorName) return 0; if (Left.is(tok::colon) && Left.Type == TT_ObjCMethodExpr) - return 50; + return 500; if (Left.is(tok::l_paren) && InFunctionDecl) return 100; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 0d317e65b64..90c74a47327 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5520,6 +5520,17 @@ TEST_F(FormatTest, FormatObjCMethodExpr) { " der:NO]);\n" "}", getLLVMStyleWithColumns(70)); + verifyFormat("{\n" + " popup_window_.reset([[RenderWidgetPopupWindow alloc]\n" + " initWithContentRect:NSMakeRect(origin_global.x,\n" + " origin_global.y,\n" + " pos.width(),\n" + " pos.height())\n" + " styleMask:NSBorderlessWindowMask\n" + " backing:NSBackingStoreBuffered\n" + " defer:NO]);\n" + "}", + getChromiumStyle()); verifyFormat("[contentsContainer replaceSubview:[subviews objectAtIndex:0]\n" " with:contentsNativeView];"); |