[analyzer] Allow pointers to escape into NSPointerArray.
(Fixes radar://11691035 PR13140)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158703 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 1adcca0..2552254 100644
--- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1384,6 +1384,16 @@
return false;
}
+ // If the first selector starts with addPointer, insertPointer,
+ // or replacePointer, assume we are dealing with NSPointerArray or similar.
+ // This is similar to C++ containers (vector); we still might want to check
+ // that the pointers get freed, by following the container itself.
+ if (S.getNameForSlot(0).startswith("addPointer") ||
+ S.getNameForSlot(0).startswith("insertPointer") ||
+ S.getNameForSlot(0).startswith("replacePointer")) {
+ return false;
+ }
+
// If the call has a callback as an argument, assume the memory
// can be freed.
if (Call->hasNonZeroCallbackArg())