clang-format: Fix ObjC method expr in binary expressions.

Before:
  bool a = ([aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaa || [aaaaaaaa aaaaa] ==
                                                         aaaaaaaaaaaaaaaaaaaa);

After:
  bool a = ([aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaa ||
            [aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaaaaa);

This fixes llvm.org/PR18271.

llvm-svn: 197552
This commit is contained in:
Daniel Jasper 2013-12-18 07:08:51 +00:00
parent 53eaea0104
commit 3460b2546c
2 changed files with 3 additions and 1 deletions

View File

@ -1144,7 +1144,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return 0;
if (Left.is(tok::comma))
return 1;
if (Right.is(tok::l_square))
if (Right.is(tok::l_square) && Right.Type != TT_ObjCMethodExpr)
return 250;
if (Right.Type == TT_StartOfName || Right.is(tok::kw_operator)) {

View File

@ -5707,6 +5707,8 @@ TEST_F(FormatTest, FormatObjCMethodExpr) {
verifyFormat("[self // break\n"
" a:a\n"
" aaa:aaa];");
verifyFormat("bool a = ([aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaa ||\n"
" [aaaaaaaa aaaaa] == aaaaaaaaaaaaaaaaaaaa);");
}
TEST_F(FormatTest, ObjCAt) {