]> granicus.if.org Git - clang/commitdiff
Teach RetainCountChecker that it doesn't quite understand pthread_setspecific and...
authorTed Kremenek <kremenek@apple.com>
Thu, 26 Apr 2012 04:32:23 +0000 (04:32 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 26 Apr 2012 04:32:23 +0000 (04:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155613 91177308-0d34-0410-b5e6-96231b3b80d8

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

index b569e412c41f48463eddcff3803c57bbdb8b74f8..f7012799b8d6c345c281286322d98eeef922d6b2 100644 (file)
@@ -929,9 +929,9 @@ const RetainSummary * RetainSummaryManager::getSummary(const FunctionDecl *FD) {
     //  filters.
     assert(ScratchArgs.isEmpty());
 
-    if (FName == "pthread_create") {
-      // Part of: <rdar://problem/7299394>.  This will be addressed
-      // better with IPA.
+    if (FName == "pthread_create" || FName == "pthread_setspecific") {
+      // Part of: <rdar://problem/7299394> and <rdar://problem/11282706>.
+      // This will be addressed better with IPA.
       S = getPersistentStopSummary();
     } else if (FName == "NSMakeCollectable") {
       // Handle: id NSMakeCollectable(CFTypeRef)
index 06c510e5dd3ef97709b01c3f816defff001fa8a8..3aa2656c62f44e69a8b08d6efa641bd2f2b678e2 100644 (file)
@@ -1055,10 +1055,14 @@ typedef struct _opaque_pthread_t *__darwin_pthread_t;
 typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t;
 typedef __darwin_pthread_t pthread_t;
 typedef __darwin_pthread_attr_t pthread_attr_t;
+typedef unsigned long __darwin_pthread_key_t;
+typedef __darwin_pthread_key_t pthread_key_t;
 
 int pthread_create(pthread_t *, const pthread_attr_t *,
                    void *(*)(void *), void *);
 
+int pthread_setspecific(pthread_key_t key, const void *value);
+
 void *rdar_7299394_start_routine(void *p) {
   [((id) p) release];
   return 0;
@@ -1071,6 +1075,16 @@ void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) {
   NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
 }
 
+//===----------------------------------------------------------------------===//
+// <rdar://problem/11282706> false positive with not understanding thread
+// local storage
+//===----------------------------------------------------------------------===//
+
+void rdar11282706(pthread_key_t key) {
+  NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
+  pthread_setspecific(key, (void*) number);
+}
+
 //===----------------------------------------------------------------------===//
 // <rdar://problem/7283567> False leak associated with call to 
 //                          CVPixelBufferCreateWithBytes ()