]> granicus.if.org Git - clang/commitdiff
[analyzer] Malloc: Allow a pointer to escape through OSAtomicEnqueue.
authorAnna Zaks <ganna@apple.com>
Mon, 26 Mar 2012 18:18:39 +0000 (18:18 +0000)
committerAnna Zaks <ganna@apple.com>
Mon, 26 Mar 2012 18:18:39 +0000 (18:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153453 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/MallocChecker.cpp
test/Analysis/malloc.mm

index 5eca9178ad9143326c9710d114c47063660094e1..7b9adb7c157d5e6164552917537e34bf0197c773 100644 (file)
@@ -1257,7 +1257,8 @@ bool MallocChecker::doesNotFreeMemory(const CallOrObjCMessage *Call,
     // this would be to implement a pointer escapes callback.
     if (FName == "CVPixelBufferCreateWithBytes" ||
         FName == "CGBitmapContextCreateWithData" ||
-        FName == "CVPixelBufferCreateWithPlanarBytes") {
+        FName == "CVPixelBufferCreateWithPlanarBytes" ||
+        FName == "OSAtomicEnqueue") {
       return false;
     }
 
index 4cb2cfa328a9ca6e74763c6261bee08f1d4dbd87..fe14edeedd1ccd43ad5a45724a7fb03df073105e 100644 (file)
@@ -106,3 +106,14 @@ void testBlocks() {
   myBlock(3);
 }
 
+// Test that we handle pointer escaping through OSAtomicEnqueue.
+typedef volatile struct {
+ void *opaque1;
+ long opaque2;
+} OSQueueHead;
+void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset) __attribute__((weak_import));
+static inline void radar11111210(OSQueueHead *pool) {
+    void *newItem = malloc(4);
+    OSAtomicEnqueue(pool, newItem, 4);
+}
+