[llvm-branch-commits] [cfe-branch] r71554 - in /cfe/branches/Apple/Dib: lib/Analysis/CFRefCount.cpp test/Analysis/retain-release.m

Mike Stump mrs at apple.com
Tue May 12 07:41:50 PDT 2009


Author: mrs
Date: Tue May 12 09:41:45 2009
New Revision: 71554

URL: http://llvm.org/viewvc/llvm-project?rev=71554&view=rev
Log:
Merge in 71538:

Fix <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects

This was accomplished by having	'isTypeRef' recursively walk the typedef stack.

Modified:
    cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp
    cfe/branches/Apple/Dib/test/Analysis/retain-release.m

Modified: cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp?rev=71554&r1=71553&r2=71554&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp Tue May 12 09:41:45 2009
@@ -225,9 +225,17 @@
 static bool isRefType(QualType RetTy, const char* prefix,
                       ASTContext* Ctx = 0, const char* name = 0) {
   
-  if (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
-    const char* TDName = TD->getDecl()->getIdentifier()->getName();
-    return hasPrefix(TDName, prefix) && hasSuffix(TDName, "Ref");
+  // Recursively walk the typedef stack, allowing typedefs of reference types.
+  while (1) {
+    if (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
+      const char* TDName = TD->getDecl()->getIdentifier()->getName();
+      if (hasPrefix(TDName, prefix) && hasSuffix(TDName, "Ref"))
+        return true;
+      
+      RetTy = TD->getDecl()->getUnderlyingType();
+      continue;
+    }
+    break;
   }
 
   if (!Ctx || !name)

Modified: cfe/branches/Apple/Dib/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/Analysis/retain-release.m?rev=71554&r1=71553&r2=71554&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/Analysis/retain-release.m (original)
+++ cfe/branches/Apple/Dib/test/Analysis/retain-release.m Tue May 12 09:41:45 2009
@@ -528,6 +528,27 @@
  [pool drain];
 }
 
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects
+//===----------------------------------------------------------------------===//
+
+typedef CFTypeRef OtherRef;
+
+ at interface RDar6877235 : NSObject {}
+- (CFTypeRef)_copyCFTypeRef;
+- (OtherRef)_copyOtherRef;
+ at end
+
+ at implementation RDar6877235
+- (CFTypeRef)_copyCFTypeRef {
+  return [[NSString alloc] init]; // no-warning
+}
+- (OtherRef)_copyOtherRef {
+  return [[NSString alloc] init]; // no-warning
+}
+ at end
+
 //===----------------------------------------------------------------------===//
 // Tests of ownership attributes.
 //===----------------------------------------------------------------------===//





More information about the llvm-branch-commits mailing list