[cfe-commits] r163738 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/arc-objc-lifetime.m

Fariborz Jahanian fjahanian at apple.com
Wed Sep 12 13:34:47 PDT 2012


Author: fjahanian
Date: Wed Sep 12 15:34:47 2012
New Revision: 163738

URL: http://llvm.org/viewvc/llvm-project?rev=163738&view=rev
Log:
objective-C arc: don't issue no explicit ownership warning when
__autoreleasing is explicitely added to param type.
// rdar://12280826

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/arc-objc-lifetime.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=163738&r1=163737&r2=163738&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Sep 12 15:34:47 2012
@@ -282,11 +282,10 @@
     AddFactoryMethodToGlobalPool(MDecl, true);
 }
 
-/// StrongPointerToObjCPointer - returns true when pointer to ObjC pointer
-/// is __strong, or when it is any other type. It returns false when
-/// pointer to ObjC pointer is not __strong.
+/// HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer
+/// has explicit ownership attribute; false otherwise.
 static bool
-StrongPointerToObjCPointer(Sema &S, ParmVarDecl *Param) {
+HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param) {
   QualType T = Param->getType();
   if (!T->isObjCIndirectLifetimeType())
     return true;
@@ -296,8 +295,11 @@
         ? T->getAs<PointerType>()->getPointeeType() 
         : T->getAs<ReferenceType>()->getPointeeType();
   if (T->isObjCLifetimeType()) {
-    Qualifiers::ObjCLifetime lifetime = T.getObjCLifetime();
-    return lifetime == Qualifiers::OCL_Strong;
+    // when lifetime is Qualifiers::OCL_None it means that it has
+    // no implicit ownership qualifier (which means it is explicit).
+    Qualifiers::ObjCLifetime lifetime = 
+      T.getLocalQualifiers().getObjCLifetime();
+    return lifetime == Qualifiers::OCL_None;
   }
   return true;
 }
@@ -335,7 +337,7 @@
           Param->setInvalidDecl();
     if (!Param->isInvalidDecl() &&
         getLangOpts().ObjCAutoRefCount &&
-        !StrongPointerToObjCPointer(*this, Param))
+        !HasExplicitOwnershipAttr(*this, Param))
       Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
             Param->getType();
     

Modified: cfe/trunk/test/SemaObjC/arc-objc-lifetime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-objc-lifetime.m?rev=163738&r1=163737&r2=163738&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-objc-lifetime.m (original)
+++ cfe/trunk/test/SemaObjC/arc-objc-lifetime.m Wed Sep 12 15:34:47 2012
@@ -56,3 +56,14 @@
 - (void) N : (__strong NSObject***) arg0 : (__strong NSObject<P>***)arg : (float**) arg1 : (double) arg2 {} 
 - (void) BLOCK : (T*) arg0 : (T)arg  : (__strong T*) arg1 {} // expected-warning {{method parameter of type '__autoreleasing T *' (aka 'void (^__autoreleasing *)()') with no explicit ownership}}
 @end
+
+// rdar://12280826
+ at class NSMutableDictionary, NSError;
+ at interface Radar12280826
+- (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError**)error;
+ at end
+
+ at implementation Radar12280826
+- (void)createInferiorTransportAndSetEnvironment:(NSMutableDictionary*)environment error:(__autoreleasing NSError**)error {}
+ at end
+





More information about the cfe-commits mailing list