[PATCH] D27409: [analyzer] RetainCountChecker: Improve support for libdispatch APIs.

Devin Coughlin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 6 18:33:19 PST 2016


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





More information about the cfe-commits mailing list