]> granicus.if.org Git - clang/commitdiff
Teach RetainCountChecker that CFPlugInInstanceCreate does not
authorTed Kremenek <kremenek@apple.com>
Thu, 6 Sep 2012 23:47:02 +0000 (23:47 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 6 Sep 2012 23:47:02 +0000 (23:47 +0000)
return a CF object at all.

Fixes <rdar://problem/9566345>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163362 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
test/Analysis/retain-release.m

index e95ba52f6970b4adef5cf02da60b6852754dd4dd..5d10575d83dd69886b36725984407893bd434909 100644 (file)
@@ -1074,6 +1074,8 @@ RetainSummaryManager::getFunctionSummary(const FunctionDecl *FD) {
       // The headers on OS X 10.8 use cf_consumed/ns_returns_retained,
       // but we can fully model NSMakeCollectable ourselves.
       AllowAnnotations = false;
+    } else if (FName == "CFPlugInInstanceCreate") {
+      S = getPersistentSummary(RetEffect::MakeNoRet());
     } else if (FName == "IOBSDNameMatching" ||
                FName == "IOServiceMatching" ||
                FName == "IOServiceNameMatching" ||
index 9d2aa756b2823a7703314368fc94b9f4fee1b5ba..3a9649c741210f642308159e15f0f2d43eed1b27 100644 (file)
@@ -303,6 +303,10 @@ extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
 // This is how NSMakeCollectable is declared in the OS X 10.8 headers.
 id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained));
 
+typedef const struct __CFUUID * CFUUIDRef;
+
+extern
+void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
 
 //===----------------------------------------------------------------------===//
 // Test cases.
@@ -1907,3 +1911,11 @@ void test_custom_cf() {
   MyCFType x = CreateMyCFType(); // expected-warning {{leak of an object stored into 'x'}}
 }
 
+//===----------------------------------------------------------------------===//
+// Test calling CFPlugInInstanceCreate, which appears in CF but doesn't
+// return a CF object.
+//===----------------------------------------------------------------------===//
+
+void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) {
+  CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning
+}