dcoughlin added a comment.

The analyzer currently doesn't do any checking for dispatch retain/release APIs 
in C. It similarly doesn't do any checking in Objective-C when 
OS_OBJECT_USE_OBJC is 0 (and thus the dispatch types are defined to their 
C-struct versions). This happens when the user explicitly sets 
-DOS_OBJECT_USE_OBJC=0 (to safely share dispatch between ARC and non-ARC 
projects) and also under certain combinations of deployment targets and 
architectures where the runtime support for the feature is not present (for 
example, earlier than iOS 6.0).

My feeling is that for this patch it is fine to continue the policy of not 
diagnosing dispatch leaks/overreleases when OS_OBJECT_USE_OBJC is 0. Adding 
this support to the retain count checker is a larger project and in my opinion 
it should be done separately. To that end, I would recommend removing the 
summary creation for dispatch_retain/dispatch_release().

That said, people do use these APIs in C (and with -DOS_OBJECT_USE_OBJC=0 in 
ObjC), so it would be great test to make sure that this patch don't introduce 
any new false positives in these situations. I think it important to suck in 
enough of the header typedefs used when -DOS_OBJECT_USE_OBJC=0 to write these 
tests to make sure we don't regress when using the C-based APIs.



================
Comment at: test/Analysis/dispatch-data-leak.m:4
+// RUN: %clang_cc1 -w -triple x86_64-apple-macosx10.12.0 -fblocks 
-DDISPATCH_MACROS -analyze -analyzer-output=text 
-analyzer-checker=core,osx.cocoa,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -triple x86_64-apple-macosx10.12.0 -fblocks 
-DDISPATCH_MARCOS -fobjc-arc -analyze -analyzer-output=text 
-analyzer-checker=core,osx.cocoa,unix.Malloc -verify %s
+
----------------
Looks like there is a typo here ('MARCOS' vs. 'MACROS')?


https://reviews.llvm.org/D27409



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to