[cfe-commits] r163362 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp test/Analysis/retain-release.m

Jordan Rose jordan_rose at apple.com
Thu Sep 6 16:53:09 PDT 2012


Comment? Someone not familiar with CFPlugInInstanceCreate will wonder why it doesn't at least return a CF object, even if it's not an owned object.

(For the list: it returns a COM interface pointer.)


On Sep 6, 2012, at 16:47 , Ted Kremenek <kremenek at apple.com> wrote:

> Author: kremenek
> Date: Thu Sep  6 18:47:02 2012
> New Revision: 163362
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=163362&view=rev
> Log:
> Teach RetainCountChecker that CFPlugInInstanceCreate  does not
> return a CF object at all.
> 
> Fixes <rdar://problem/9566345>
> 
> Modified:
>    cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
>    cfe/trunk/test/Analysis/retain-release.m
> 
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=163362&r1=163361&r2=163362&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Thu Sep  6 18:47:02 2012
> @@ -1074,6 +1074,8 @@
>       // 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" ||
> 
> Modified: cfe/trunk/test/Analysis/retain-release.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=163362&r1=163361&r2=163362&view=diff
> ==============================================================================
> --- cfe/trunk/test/Analysis/retain-release.m (original)
> +++ cfe/trunk/test/Analysis/retain-release.m Thu Sep  6 18:47:02 2012
> @@ -303,6 +303,10 @@
> // 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 @@
>   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
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list