summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
diff options
context:
space:
mode:
authorAnton Yartsev <anton.yartsev@gmail.com>2013-04-05 02:25:02 +0000
committerAnton Yartsev <anton.yartsev@gmail.com>2013-04-05 02:25:02 +0000
commit6e49925622a371c89f737441749e503972c7ae63 (patch)
tree1a4ca07d2881a2b89acf7774bd67f370372fdb17 /clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
parent726c8c3bdd0634cfeccd6fb0f9495d289c7cf137 (diff)
downloadbcm5719-llvm-6e49925622a371c89f737441749e503972c7ae63.tar.gz
bcm5719-llvm-6e49925622a371c89f737441749e503972c7ae63.zip
[analyzer] Check allocation family more precise.
The statement passed to isTrackedFamily() might be a user defined function calling malloc; in this case we got AF_NONE family for this function. Now the allocation family is derived from Sym, that holds a family of a real allocator. This commit is also a movement towards getting rid of tracking memory allocating by unknown means. llvm-svn: 178834
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 1e18792d890..4b0e7661d8d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1535,6 +1535,9 @@ void MallocChecker::reportLeak(SymbolRef Sym, ExplodedNode *N,
!Filter.CNewDeleteChecker)
return;
+ if (!isTrackedFamily(C, Sym))
+ return;
+
assert(N);
if (!BT_Leak) {
BT_Leak.reset(new BugType("Memory leak", "Memory Error"));
@@ -1560,13 +1563,10 @@ void MallocChecker::reportLeak(SymbolRef Sym, ExplodedNode *N,
AllocationStmt = Exit->getCalleeContext()->getCallSite();
else if (Optional<StmtPoint> SP = P.getAs<StmtPoint>())
AllocationStmt = SP->getStmt();
- if (AllocationStmt) {
+ if (AllocationStmt)
LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocationStmt,
C.getSourceManager(),
AllocNode->getLocationContext());
- if (!isTrackedFamily(C, AllocationStmt))
- return;
- }
SmallString<200> buf;
llvm::raw_svector_ostream os(buf);
OpenPOWER on IntegriCloud