<div dir="ltr">It should probably default to true in llvm too, given that that's what the official property documentation ( <a href="https://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html">https://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html</a> ) uses. (Not that there's much ObjC code in llvm.)</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 28, 2014 at 7:20 AM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: djasper<br>
Date: Tue Jan 28 09:20:33 2014<br>
New Revision: 200320<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=200320&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=200320&view=rev</a><br>
Log:<br>
clang-format: Add support for a space after @property<br>
<br>
Mozilla and WebKit seem to use a space after @property (verified by<br>
grepping their codebases) so we turn this on there as well.<br>
<br>
Change by Christian Legnitto. Thank you!<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Format/Format.h<br>
cfe/trunk/lib/Format/Format.cpp<br>
cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
cfe/trunk/unittests/Format/FormatTest.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Format/Format.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=200320&r1=200319&r2=200320&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=200320&r1=200319&r2=200320&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Format/Format.h (original)<br>
+++ cfe/trunk/include/clang/Format/Format.h Tue Jan 28 09:20:33 2014<br>
@@ -163,6 +163,10 @@ struct FormatStyle {<br>
/// line.<br>
bool AllowShortFunctionsOnASingleLine;<br>
<br>
+ /// \brief Add a space after \c @property in Objective-C, i.e. use<br>
+ /// <tt>@property (readonly)</tt> instead of <tt>@property(readonly)</tt>.<br>
+ bool ObjCSpaceAfterProperty;<br>
+<br>
/// \brief Add a space in front of an Objective-C protocol list, i.e. use<br>
/// <tt>Foo <Protocol></tt> instead of \c Foo<Protocol>.<br>
bool ObjCSpaceBeforeProtocolList;<br>
@@ -329,6 +333,7 @@ struct FormatStyle {<br>
IndentWidth == R.IndentWidth && Language == R.Language &&<br>
MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep &&<br>
NamespaceIndentation == R.NamespaceIndentation &&<br>
+ ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty &&<br>
ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&<br>
PenaltyBreakComment == R.PenaltyBreakComment &&<br>
PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&<br>
<br>
Modified: cfe/trunk/lib/Format/Format.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=200320&r1=200319&r2=200320&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=200320&r1=200319&r2=200320&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/Format.cpp (original)<br>
+++ cfe/trunk/lib/Format/Format.cpp Tue Jan 28 09:20:33 2014<br>
@@ -164,6 +164,7 @@ template <> struct MappingTraits<FormatS<br>
IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);<br>
IO.mapOptional("MaxEmptyLinesToKeep", Style.MaxEmptyLinesToKeep);<br>
IO.mapOptional("NamespaceIndentation", Style.NamespaceIndentation);<br>
+ IO.mapOptional("ObjCSpaceAfterProperty", Style.ObjCSpaceAfterProperty);<br>
IO.mapOptional("ObjCSpaceBeforeProtocolList",<br>
Style.ObjCSpaceBeforeProtocolList);<br>
IO.mapOptional("PenaltyBreakBeforeFirstCallParameter",<br>
@@ -267,6 +268,7 @@ FormatStyle getLLVMStyle() {<br>
LLVMStyle.TabWidth = 8;<br>
LLVMStyle.MaxEmptyLinesToKeep = 1;<br>
LLVMStyle.NamespaceIndentation = FormatStyle::NI_None;<br>
+ LLVMStyle.ObjCSpaceAfterProperty = false;<br>
LLVMStyle.ObjCSpaceBeforeProtocolList = true;<br>
LLVMStyle.PointerBindsToType = false;<br>
LLVMStyle.SpacesBeforeTrailingComments = 1;<br>
@@ -305,6 +307,7 @@ FormatStyle getGoogleStyle() {<br>
GoogleStyle.DerivePointerBinding = true;<br>
GoogleStyle.IndentCaseLabels = true;<br>
GoogleStyle.IndentFunctionDeclarationAfterType = true;<br>
+ GoogleStyle.ObjCSpaceAfterProperty = false;<br>
GoogleStyle.ObjCSpaceBeforeProtocolList = false;<br>
GoogleStyle.PointerBindsToType = true;<br>
GoogleStyle.SpacesBeforeTrailingComments = 2;<br>
@@ -349,6 +352,7 @@ FormatStyle getMozillaStyle() {<br>
MozillaStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;<br>
MozillaStyle.DerivePointerBinding = true;<br>
MozillaStyle.IndentCaseLabels = true;<br>
+ MozillaStyle.ObjCSpaceAfterProperty = true;<br>
MozillaStyle.ObjCSpaceBeforeProtocolList = false;<br>
MozillaStyle.PenaltyReturnTypeOnItsOwnLine = 200;<br>
MozillaStyle.PointerBindsToType = true;<br>
@@ -365,6 +369,7 @@ FormatStyle getWebKitStyle() {<br>
Style.ColumnLimit = 0;<br>
Style.IndentWidth = 4;<br>
Style.NamespaceIndentation = FormatStyle::NI_Inner;<br>
+ Style.ObjCSpaceAfterProperty = true;<br>
Style.PointerBindsToType = true;<br>
return Style;<br>
}<br>
<br>
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=200320&r1=200319&r2=200320&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=200320&r1=200319&r2=200320&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)<br>
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jan 28 09:20:33 2014<br>
@@ -1260,6 +1260,9 @@ bool TokenAnnotator::spaceRequiredBetwee<br>
(Left.TokenText == "returns" || Left.TokenText == "option"))<br>
return true;<br>
}<br>
+ if (Style.ObjCSpaceAfterProperty && Line.Type == LT_ObjCProperty &&<br>
+ Left.Tok.getObjCKeywordID() == tok::objc_property)<br>
+ return true;<br>
if (Right.is(tok::hashhash))<br>
return Left.is(tok::hash);<br>
if (Left.isOneOf(tok::hashhash, tok::hash))<br>
<br>
Modified: cfe/trunk/unittests/Format/FormatTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=200320&r1=200319&r2=200320&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=200320&r1=200319&r2=200320&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jan 28 09:20:33 2014<br>
@@ -5872,6 +5872,12 @@ TEST_F(FormatTest, ObjCSnippets) {<br>
verifyFormat("@property(assign, nonatomic) CGFloat hoverAlpha;");<br>
verifyFormat("@property(assign, getter=isEditable) BOOL editable;");<br>
verifyGoogleFormat("@property(assign, getter=isEditable) BOOL editable;");<br>
+ verifyFormat("@property (assign, getter=isEditable) BOOL editable;",<br>
+ getMozillaStyle());<br>
+ verifyFormat("@property BOOL editable;", getMozillaStyle());<br>
+ verifyFormat("@property (assign, getter=isEditable) BOOL editable;",<br>
+ getWebKitStyle());<br>
+ verifyFormat("@property BOOL editable;", getWebKitStyle());<br>
<br>
verifyFormat("@import foo.bar;\n"<br>
"@import baz;");<br>
@@ -7323,6 +7329,7 @@ TEST_F(FormatTest, ParsesConfiguration)<br>
CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);<br>
CHECK_PARSE_BOOL(DerivePointerBinding);<br>
CHECK_PARSE_BOOL(IndentCaseLabels);<br>
+ CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);<br>
CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);<br>
CHECK_PARSE_BOOL(PointerBindsToType);<br>
CHECK_PARSE_BOOL(Cpp11BracedListStyle);<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>