forked from OSchip/llvm-project
Formatter/ObjC: Correctly format casts in objc message send expressions.
llvm-svn: 184804
This commit is contained in:
parent
503b726b43
commit
ec9e41076b
|
@ -637,9 +637,8 @@ private:
|
||||||
// there is also an identifier before the ().
|
// there is also an identifier before the ().
|
||||||
if (LeftOfParens && (LeftOfParens->Tok.getIdentifierInfo() == NULL ||
|
if (LeftOfParens && (LeftOfParens->Tok.getIdentifierInfo() == NULL ||
|
||||||
LeftOfParens->is(tok::kw_return)) &&
|
LeftOfParens->is(tok::kw_return)) &&
|
||||||
LeftOfParens->Type != TT_TemplateCloser &&
|
LeftOfParens->Type != TT_TemplateCloser && Current.Next &&
|
||||||
LeftOfParens->Type != TT_ObjCMethodExpr && Current.Next &&
|
Current.Next->is(tok::identifier))
|
||||||
(Current.Next->is(tok::identifier)))
|
|
||||||
IsCast = true;
|
IsCast = true;
|
||||||
if (IsCast && !ParensAreEmpty)
|
if (IsCast && !ParensAreEmpty)
|
||||||
Current.Type = TT_CastRParen;
|
Current.Type = TT_CastRParen;
|
||||||
|
|
|
@ -4309,6 +4309,10 @@ TEST_F(FormatTest, FormatObjCMethodExpr) {
|
||||||
verifyFormat("throw [self errorFor:a];");
|
verifyFormat("throw [self errorFor:a];");
|
||||||
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 ":",
|
// This tests that the formatter doesn't break after "backing" but before ":",
|
||||||
// which would be at 80 columns.
|
// which would be at 80 columns.
|
||||||
verifyFormat(
|
verifyFormat(
|
||||||
|
|
Loading…
Reference in New Issue