! 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 <[email protected]> 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;
> 
> -@property(strong) NSString * StrongProp;
> +@property(copy) NSString * StrongProp;
> 
> 
> - (NSString *) UnavailProp  __attribute__((unavailable));
> @@ -42,8 +42,8 @@
> 
> 
> 
> -@property(strong) NSArray * names2;
> -@property(strong) NSArray * names3;
> -@property(strong) NSArray *__strong names4;
> -@property(strong) NSArray * names1;
> +@property(copy) NSArray * names2;
> +@property(copy) NSArray * names3;
> +@property(copy) NSArray *__strong names4;
> +@property(copy) NSArray * names1;
> @end
> 
> 
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to