summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-05-03 23:50:28 +0000
committerAnna Zaks <ganna@apple.com>2012-05-03 23:50:28 +0000
commit228f9c7b68fd2bf56b32623251b54f3d3c9ee3b7 (patch)
tree267b6117d5f94254b376ca1ac9cccb9cec4443ee /clang/lib/StaticAnalyzer/Checkers
parentb41171b70b214ee529b01c3f6166e0b82229dabf (diff)
downloadbcm5719-llvm-228f9c7b68fd2bf56b32623251b54f3d3c9ee3b7.tar.gz
bcm5719-llvm-228f9c7b68fd2bf56b32623251b54f3d3c9ee3b7.zip
[analyzer] Allow pointers escape through calls containing callback args.
(Since we don't have a generic pointer escape callback, modify ExprEngineCallAndReturn as well as the malloc checker.) llvm-svn: 156134
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 55c32ec1ebb..14151840334 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1285,6 +1285,11 @@ bool MallocChecker::doesNotFreeMemory(const CallOrObjCMessage *Call,
if (FName.startswith("NS") && (FName.find("Insert") != StringRef::npos))
return false;
+ // If the call has a callback as an argument, assume the memory
+ // can be freed.
+ if (Call->hasNonZeroCallbackArg())
+ return false;
+
// Otherwise, assume that the function does not free memory.
// Most system calls, do not free the memory.
return true;
@@ -1312,6 +1317,11 @@ bool MallocChecker::doesNotFreeMemory(const CallOrObjCMessage *Call,
return false;
}
+ // If the call has a callback as an argument, assume the memory
+ // can be freed.
+ if (Call->hasNonZeroCallbackArg())
+ return false;
+
// Otherwise, assume that the function does not free memory.
// Most system calls, do not free the memory.
return true;
OpenPOWER on IntegriCloud