r178834 - [analyzer] Check allocation family more precise.
Anton Yartsev
anton.yartsev at gmail.com
Thu Apr 4 19:25:02 PDT 2013
Author: ayartsev
Date: Thu Apr 4 21:25:02 2013
New Revision: 178834
URL: http://llvm.org/viewvc/llvm-project?rev=178834&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=178834&r1=178833&r2=178834&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Thu Apr 4 21:25:02 2013
@@ -1535,6 +1535,9 @@ void MallocChecker::reportLeak(SymbolRef
!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
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);
More information about the cfe-commits
mailing list