r184804 - Formatter/ObjC: Correctly format casts in objc message send expressions.
Nico Weber
nicolasweber at gmx.de
Mon Jun 24 17:55:58 PDT 2013
Author: nico
Date: Mon Jun 24 19:55:57 2013
New Revision: 184804
URL: http://llvm.org/viewvc/llvm-project?rev=184804&view=rev
Log:
Formatter/ObjC: Correctly format casts in objc message send expressions.
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=184804&r1=184803&r2=184804&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jun 24 19:55:57 2013
@@ -637,9 +637,8 @@ private:
// there is also an identifier before the ().
if (LeftOfParens && (LeftOfParens->Tok.getIdentifierInfo() == NULL ||
LeftOfParens->is(tok::kw_return)) &&
- LeftOfParens->Type != TT_TemplateCloser &&
- LeftOfParens->Type != TT_ObjCMethodExpr && Current.Next &&
- (Current.Next->is(tok::identifier)))
+ LeftOfParens->Type != TT_TemplateCloser && Current.Next &&
+ Current.Next->is(tok::identifier))
IsCast = true;
if (IsCast && !ParensAreEmpty)
Current.Type = TT_CastRParen;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=184804&r1=184803&r2=184804&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jun 24 19:55:57 2013
@@ -4309,6 +4309,10 @@ TEST_F(FormatTest, FormatObjCMethodExpr)
verifyFormat("throw [self errorFor:a];");
verifyFormat("@throw [self errorFor:a];");
+ verifyFormat("[(id)foo bar:(id)baz quux:(id)snorf];");
+ verifyFormat("[(id)foo bar:(id) ? baz : quux];");
+ verifyFormat("4 > 4 ? (id)a : (id)baz;");
+
// This tests that the formatter doesn't break after "backing" but before ":",
// which would be at 80 columns.
verifyFormat(
More information about the cfe-commits
mailing list