From 90ab9bfa111fcf567a089ec35f232708466df647 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Fri, 30 Mar 2012 05:48:16 +0000 Subject: [analyzer]Malloc,RetainRelease: Allow pointer to escape via NSMapInsert. Fixes a false positive (radar://11152419). The current solution of adding the info into 3 places is quite ugly. Pending a generic pointer escapes callback. llvm-svn: 153731 --- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp') diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 7b9adb7c157..7456af23441 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1262,6 +1262,11 @@ bool MallocChecker::doesNotFreeMemory(const CallOrObjCMessage *Call, return false; } + // Whitelist NSXXInsertXX, for example NSMapInsertIfAbsent, since they can + // be deallocated by NSMapRemove. + if (FName.startswith("NS") && (FName.find("Insert") != StringRef::npos)) + return false; + // Otherwise, assume that the function does not free memory. // Most system calls, do not free the memory. return true; -- cgit v1.2.3