summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-01-10 21:30:42 +0000
committerNico Weber <nicolasweber@gmx.de>2013-01-10 21:30:42 +0000
commita2a8495e19cee3d8d09f1836274ddd48945d82d2 (patch)
tree1bcfa1bbcb7c0cb0a6d4b8fbd77661e27505a173 /clang/lib
parent045a73e62d9da3314c8f2f7a13f52d703fcd0635 (diff)
downloadbcm5719-llvm-a2a8495e19cee3d8d09f1836274ddd48945d82d2.tar.gz
bcm5719-llvm-a2a8495e19cee3d8d09f1836274ddd48945d82d2.zip
Formatter: No spaces around '=' in @property lines.
Before: @property(assign, getter = isEditable) BOOL editable; Now: @property(assign, getter=isEditable) BOOL editable; It'd be nice if some Apple person could let me know if spaces are preferred around '=' in @synthesize lines (see FIXME in the test). llvm-svn: 172110
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/Format.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d721536c76b..f84d3c5bc7a 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -39,6 +39,7 @@ enum TokenType {
TT_ObjCBlockLParen,
TT_ObjCDecl,
TT_ObjCMethodSpecifier,
+ TT_ObjCProperty,
TT_OverloadedOperator,
TT_PointerOrReference,
TT_PureVirtualSpecifier,
@@ -55,7 +56,8 @@ enum LineType {
LT_PreprocessorDirective,
LT_VirtualFunctionDecl,
LT_ObjCDecl, // An @interface, @implementation, or @protocol line.
- LT_ObjCMethodDecl
+ LT_ObjCMethodDecl,
+ LT_ObjCProperty // An @property line.
};
class AnnotatedToken {
@@ -841,6 +843,8 @@ public:
CurrentLineType = LT_ObjCMethodDecl;
else if (RootToken.Type == TT_ObjCDecl)
CurrentLineType = LT_ObjCDecl;
+ else if (RootToken.Type == TT_ObjCProperty)
+ CurrentLineType = LT_ObjCProperty;
if (!RootToken.Children.empty())
calculateExtraInformation(RootToken.Children[0]);
@@ -891,6 +895,10 @@ private:
case tok::objc_implementation:
case tok::objc_protocol:
Current.Type = TT_ObjCDecl;
+ break;
+ case tok::objc_property:
+ Current.Type = TT_ObjCProperty;
+ break;
default:
break;
}
@@ -1044,6 +1052,9 @@ private:
// Don't space between ':' and '('
return false;
}
+ if (CurrentLineType == LT_ObjCProperty &&
+ (Tok.is(tok::equal) || Tok.Parent->is(tok::equal)))
+ return false;
if (Tok.Type == TT_CtorInitializerColon || Tok.Type == TT_ObjCBlockLParen)
return true;
OpenPOWER on IntegriCloud