summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-05-13 10:23:03 +0000
committerDaniel Jasper <djasper@google.com>2015-05-13 10:23:03 +0000
commita7b142603da5ae63232b727bb20b997cadbaf4bb (patch)
tree20611f7465b68cb6dcf803987d68c494bc0095f0
parentd130fd17f15bbdeb57003db99abff59aa5795617 (diff)
downloadbcm5719-llvm-a7b142603da5ae63232b727bb20b997cadbaf4bb.tar.gz
bcm5719-llvm-a7b142603da5ae63232b727bb20b997cadbaf4bb.zip
clang-format: [ObjC] Further improve wrapping of methods calls without inputs.
Before: [aaaaaaaaaaaaaaaaaaaaaaa .aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa] aaaaaaaaaaaaaaaaaaaaaa]; After: [aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa] aaaaaaaaaaaaaaaaaaaaaa]; llvm-svn: 237244
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 777de9bf1e3..3e51417d2cd 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2111,7 +2111,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
return false;
if (Left.is(tok::colon) && (Left.isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)))
return true;
- if (Right.is(TT_SelectorName))
+ if (Right.is(TT_SelectorName) || (Right.is(tok::identifier) && Right.Next &&
+ Right.Next->is(TT_ObjCMethodExpr)))
return true;
if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty)
return true;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index fbe651ef12a..105d1a11253 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7299,6 +7299,8 @@ TEST_F(FormatTest, FormatObjCMethodExpr) {
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];");
verifyFormat("[aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];");
+ verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa]\n"
+ " aaaaaaaaaaaaaaaaaaaaaa];");
verifyFormat(
"scoped_nsobject<NSTextField> message(\n"
OpenPOWER on IntegriCloud