[cfe-commits] r138062 - in /cfe/trunk: lib/Sema/SemaObjCProperty.cpp test/CodeGenObjC/arc.m test/SemaObjC/arc.m

Fariborz Jahanian fjahanian at apple.com
Fri Aug 19 12:28:44 PDT 2011


Author: fjahanian
Date: Fri Aug 19 14:28:44 2011
New Revision: 138062

URL: http://llvm.org/viewvc/llvm-project?rev=138062&view=rev
Log:
objc-arc: @property definitions should default to (strong) when not
specified. // rdar://9971982

Modified:
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp
    cfe/trunk/test/CodeGenObjC/arc.m
    cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=138062&r1=138061&r2=138062&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Fri Aug 19 14:28:44 2011
@@ -605,7 +605,8 @@
           !PropertyIvarType.getObjCLifetime()) {
 
         if (!property->hasWrittenStorageAttribute() &&
-            property->getType()->isObjCRetainableType()) {
+            property->getType()->isObjCRetainableType() &&
+            !(kind & ObjCPropertyDecl::OBJC_PR_strong) ) {
           Diag(PropertyLoc,
                diag::err_arc_objc_property_default_assign_on_object);
           Diag(property->getLocation(), diag::note_property_declare);
@@ -1707,13 +1708,19 @@
                       ObjCDeclSpec::DQ_PR_weak)) &&
       !(Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
       PropertyTy->isObjCObjectPointerType()) {
-    // Skip this warning in gc-only mode.
-    if (getLangOptions().getGCMode() != LangOptions::GCOnly)
-      Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
-
-    // If non-gc code warn that this is likely inappropriate.
-    if (getLangOptions().getGCMode() == LangOptions::NonGC)
-      Diag(Loc, diag::warn_objc_property_default_assign_on_object);
+      if (getLangOptions().ObjCAutoRefCount)
+        // With arc,  @property definitions should default to (strong) when 
+        // not specified
+        PropertyDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_strong);
+      else {
+          // Skip this warning in gc-only mode.
+          if (getLangOptions().getGCMode() != LangOptions::GCOnly)
+            Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
+
+          // If non-gc code warn that this is likely inappropriate.
+          if (getLangOptions().getGCMode() == LangOptions::NonGC)
+            Diag(Loc, diag::warn_objc_property_default_assign_on_object);
+      }
 
     // FIXME: Implement warning dependent on NSCopying being
     // implemented. See also:

Modified: cfe/trunk/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc.m?rev=138062&r1=138061&r2=138062&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc.m Fri Aug 19 14:28:44 2011
@@ -1839,3 +1839,19 @@
 
   // CHECK:      ret void
 }
+
+// rdar://9971982
+ at class NSString;
+
+ at interface Person  {
+  NSString *name;
+}
+ at property NSString *address;
+ at end
+
+ at implementation Person
+ at synthesize address;
+ at end
+// CHECK: call i8* @objc_getProperty
+// CHECK: call void @objc_setProperty 
+

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=138062&r1=138061&r2=138062&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Fri Aug 19 14:28:44 2011
@@ -491,9 +491,7 @@
   __weak id _myProp1;
   id myProp2;
 }
- at property id x; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \
-                // expected-warning {{default property attribute 'assign' not appropriate for non-gc object}} \
-                // expected-note {{declared here}}
+ at property id x;
 @property (readonly) id ro; // expected-note {{declared here}}
 @property (readonly) id custom_ro;
 @property int y;
@@ -504,7 +502,7 @@
 @end
 
 @implementation Test27
- at synthesize x; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}}
+ at synthesize x;
 @synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}}
 @synthesize y;
 





More information about the cfe-commits mailing list