r197552 - clang-format: Fix ObjC method expr in binary expressions.
Daniel Jasper
djasper at google.com
Tue Dec 17 23:08:52 PST 2013
Author: djasper
Date: Wed Dec 18 01:08:51 2013
New Revision: 197552
URL: http://llvm.org/viewvc/llvm-project?rev=197552&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=197552&r1=197551&r2=197552&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Dec 18 01:08:51 2013
@@ -1144,7 +1144,7 @@ unsigned TokenAnnotator::splitPenalty(co
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)) {
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=197552&r1=197551&r2=197552&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Dec 18 01:08:51 2013
@@ -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) {
More information about the cfe-commits
mailing list