r185985 - objc migrator: More refinment of property

Jordan Rose jordan_rose at apple.com
Tue Jul 9 17:32:03 PDT 2013


! That's very wrong. Most objects are not copyable, and not all objects that are copyable should actually be copied. You can't actually solve this problem without looking at the setter. If you wanted to go half-way, you could offer alternatives of (copy) vs. <implicitly strong> iff the object's class implements NSCopying.

Jordan


On Jul 9, 2013, at 17:20 , Fariborz Jahanian <fjahanian at apple.com> wrote:

> Author: fjahanian
> Date: Tue Jul  9 19:20:11 2013
> New Revision: 185985
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=185985&view=rev
> Log:
> objc migrator: More refinment of property
> attributes in migration. Specialli use of
> 'copy' attribute for retainable object types.
> 
> 
> Modified:
>    cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
>    cfe/trunk/test/ARCMT/objcmt-property.m.result
> 
> Modified: cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp?rev=185985&r1=185984&r2=185985&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp (original)
> +++ cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp Tue Jul  9 19:20:11 2013
> @@ -362,16 +362,16 @@ bool edit::rewriteToObjCProperty(const O
>   const ParmVarDecl *argDecl = *Setter->param_begin();
>   QualType ArgType = argDecl->getType();
>   Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime();
> -  if (propertyLifetime != Qualifiers::OCL_None) {
> -    PropertyString += "(";
> -    if (propertyLifetime == Qualifiers::OCL_Strong)
> -      PropertyString += "strong";
> -    else if (propertyLifetime == Qualifiers::OCL_Weak)
> -      PropertyString += "weak";
> -    else
> -      PropertyString += "unsafe_unretained";
> -    PropertyString += ")";
> +  
> +  if (ArgType->isObjCRetainableType() &&
> +      propertyLifetime == Qualifiers::OCL_Strong) {
> +    PropertyString += "(copy)";
>   }
> +  else if (propertyLifetime == Qualifiers::OCL_Weak)
> +    PropertyString += "(weak)";
> +  else
> +    PropertyString += "(unsafe_unretained)";
> +  
>   QualType PropQT = Getter->getResultType();
>   PropertyString += " ";
>   PropertyString += PropQT.getAsString(NS.getASTContext().getPrintingPolicy());
> 
> Modified: cfe/trunk/test/ARCMT/objcmt-property.m.result
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-property.m.result?rev=185985&r1=185984&r2=185985&view=diff
> ==============================================================================
> --- cfe/trunk/test/ARCMT/objcmt-property.m.result (original)
> +++ cfe/trunk/test/ARCMT/objcmt-property.m.result Tue Jul  9 19:20:11 2013
> @@ -12,7 +12,7 @@
> 
> @property(weak) NSString *__weak WeakProp;
> 
> - at property(strong) NSString * StrongProp;
> + at property(copy) NSString * StrongProp;
> 
> 
> - (NSString *) UnavailProp  __attribute__((unavailable));
> @@ -42,8 +42,8 @@
> 
> 
> 
> - at property(strong) NSArray * names2;
> - at property(strong) NSArray * names3;
> - at property(strong) NSArray *__strong names4;
> - at property(strong) NSArray * names1;
> + at property(copy) NSArray * names2;
> + at property(copy) NSArray * names3;
> + at property(copy) NSArray *__strong names4;
> + at property(copy) NSArray * names1;
> @end
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130709/a8a1a9ef/attachment.html>


More information about the cfe-commits mailing list