r198920 - clang-format: Understand ObjC boxed expressions.
Daniel Jasper
djasper at google.com
Thu Jan 9 23:44:53 PST 2014
Author: djasper
Date: Fri Jan 10 01:44:53 2014
New Revision: 198920
URL: http://llvm.org/viewvc/llvm-project?rev=198920&view=rev
Log:
clang-format: Understand ObjC boxed expressions.
Before:
[dictionary setObject:@(1)forKey:@"number"];
After:
[dictionary setObject:@(1) forKey:@"number"];
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=198920&r1=198919&r2=198920&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jan 10 01:44:53 2014
@@ -717,6 +717,7 @@ private:
if (LeftOfParens && (LeftOfParens->Tok.getIdentifierInfo() == NULL ||
LeftOfParens->is(tok::kw_return)) &&
LeftOfParens->Type != TT_OverloadedOperator &&
+ LeftOfParens->isNot(tok::at) &&
LeftOfParens->Type != TT_TemplateCloser && Current.Next &&
Current.Next->is(tok::identifier))
IsCast = true;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=198920&r1=198919&r2=198920&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jan 10 01:44:53 2014
@@ -5879,6 +5879,8 @@ TEST_F(FormatTest, ObjCLiterals) {
verifyFormat("NSNumber *piOverTwo = @(M_PI / 2);");
verifyFormat("NSNumber *favoriteColor = @(Green);");
verifyFormat("NSString *path = @(getenv(\"PATH\"));");
+
+ verifyFormat("[dictionary setObject:@(1) forKey:@\"number\"];");
}
TEST_F(FormatTest, ObjCDictLiterals) {
More information about the cfe-commits
mailing list