[clang-format/ObjC] Prohibit breaking after a bracket opening ObjC method expression
authorJacek Olesiak <jolesiak@google.com>
Mon, 9 Jul 2018 06:04:58 +0000 (06:04 +0000)
committerJacek Olesiak <jolesiak@google.com>
Mon, 9 Jul 2018 06:04:58 +0000 (06:04 +0000)
Summary:
Don't break after a "[" opening an ObjC method expression.
Tests are added in D48719 where formatting is improved (to avoid adding and changing tests immediately).

Reviewers: benhamilton, klimek

Reviewed By: benhamilton

Subscribers: acoomans, cfe-commits

Differential Revision: https://reviews.llvm.org/D48718

llvm-svn: 336519

clang/lib/Format/ContinuationIndenter.cpp

index bb8efd6..0862a4e 100644 (file)
@@ -321,6 +321,9 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
       State.Stack.back().NoLineBreakInOperand)
     return false;
 
+  if (Previous.is(tok::l_square) && Previous.is(TT_ObjCMethodExpr))
+    return false;
+
   return !State.Stack.back().NoLineBreak;
 }