forked from OSchip/llvm-project
[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
This commit is contained in:
parent
726c8c3bdd
commit
6e49925622
|
@ -1535,6 +1535,9 @@ void MallocChecker::reportLeak(SymbolRef Sym, ExplodedNode *N,
|
||||||
!Filter.CNewDeleteChecker)
|
!Filter.CNewDeleteChecker)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!isTrackedFamily(C, Sym))
|
||||||
|
return;
|
||||||
|
|
||||||
assert(N);
|
assert(N);
|
||||||
if (!BT_Leak) {
|
if (!BT_Leak) {
|
||||||
BT_Leak.reset(new BugType("Memory leak", "Memory Error"));
|
BT_Leak.reset(new BugType("Memory leak", "Memory Error"));
|
||||||
|
@ -1560,13 +1563,10 @@ void MallocChecker::reportLeak(SymbolRef Sym, ExplodedNode *N,
|
||||||
AllocationStmt = Exit->getCalleeContext()->getCallSite();
|
AllocationStmt = Exit->getCalleeContext()->getCallSite();
|
||||||
else if (Optional<StmtPoint> SP = P.getAs<StmtPoint>())
|
else if (Optional<StmtPoint> SP = P.getAs<StmtPoint>())
|
||||||
AllocationStmt = SP->getStmt();
|
AllocationStmt = SP->getStmt();
|
||||||
if (AllocationStmt) {
|
if (AllocationStmt)
|
||||||
LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocationStmt,
|
LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocationStmt,
|
||||||
C.getSourceManager(),
|
C.getSourceManager(),
|
||||||
AllocNode->getLocationContext());
|
AllocNode->getLocationContext());
|
||||||
if (!isTrackedFamily(C, AllocationStmt))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SmallString<200> buf;
|
SmallString<200> buf;
|
||||||
llvm::raw_svector_ostream os(buf);
|
llvm::raw_svector_ostream os(buf);
|
||||||
|
|
Loading…
Reference in New Issue