Author: zhongxingxu
Date: Sun Aug 15 03:19:57 2010
New Revision: 111097
URL: http://llvm.org/viewvc/llvm-project?rev=111097&view=rev
Log:
Implement MallocChecker::EvalDeadSymbols() with the new API. This time we
iterate over symbols being tracked, instead of symbols being dead.
Modified:
cfe/trunk/lib/Checker/MallocChecker.cpp
Modified: cfe/trunk/lib/Checker/MallocChecker.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/MallocChecker.cpp?rev=111097&r1=111096&r2=111097&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/MallocChecker.cpp (original)
+++ cfe/trunk/lib/Checker/MallocChecker.cpp Sun Aug 15 03:19:57 2010
@@ -562,22 +562,23 @@
}
void MallocChecker::EvalDeadSymbols(CheckerContext &C,SymbolReaper &SymReaper)
{
- for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
- E = SymReaper.dead_end(); I != E; ++I) {
- SymbolRef Sym = *I;
- const GRState *state = C.getState();
- const RefState *RS = state->get<RegionState>(Sym);
- if (!RS)
- return;
+ if (!SymReaper.hasDeadSymbols())
+ return;
- if (RS->isAllocated()) {
- if (ExplodedNode *N = C.GenerateSink()) {
- if (!BT_Leak)
- BT_Leak = new BuiltinBug("Memory leak",
+ const GRState *state = C.getState();
+ RegionStateTy RS = state->get<RegionState>();
+
+ for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) {
+ if (SymReaper.isDead(I->first)) {
+ if (I->second.isAllocated()) {
+ if (ExplodedNode *N = C.GenerateSink()) {
+ if (!BT_Leak)
+ BT_Leak = new BuiltinBug("Memory leak",
"Allocated memory never released. Potential memory
leak.");
- // FIXME: where it is allocated.
- BugReport *R = new BugReport(*BT_Leak, BT_Leak->getDescription(), N);
- C.EmitReport(R);
+ // FIXME: where it is allocated.
+ BugReport *R = new BugReport(*BT_Leak, BT_Leak->getDescription(), N);
+ C.EmitReport(R);
+ }
}
}
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits