forked from OSchip/llvm-project
[analyzer] Malloc checker cleanup/refactor
No need for the auxiliary flag. No need to generate a leak node when there is no error. llvm-svn: 166977
This commit is contained in:
parent
be70d4d0b4
commit
58a2c4e453
|
@ -1061,14 +1061,11 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper,
|
|||
RegionStateTy RS = state->get<RegionState>();
|
||||
RegionStateTy::Factory &F = state->get_context<RegionState>();
|
||||
|
||||
bool generateReport = false;
|
||||
llvm::SmallVector<SymbolRef, 2> Errors;
|
||||
for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) {
|
||||
if (SymReaper.isDead(I->first)) {
|
||||
if (I->second.isAllocated()) {
|
||||
generateReport = true;
|
||||
if (I->second.isAllocated())
|
||||
Errors.push_back(I->first);
|
||||
}
|
||||
// Remove the dead symbol from the map.
|
||||
RS = F.remove(RS, I->first);
|
||||
|
||||
|
@ -1085,15 +1082,16 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper,
|
|||
}
|
||||
|
||||
// Generate leak node.
|
||||
ExplodedNode *N = C.getPredecessor();
|
||||
if (!Errors.empty()) {
|
||||
static SimpleProgramPointTag Tag("MallocChecker : DeadSymbolsLeak");
|
||||
ExplodedNode *N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
|
||||
|
||||
if (generateReport) {
|
||||
N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
|
||||
for (llvm::SmallVector<SymbolRef, 2>::iterator
|
||||
I = Errors.begin(), E = Errors.end(); I != E; ++I) {
|
||||
reportLeak(*I, N, C);
|
||||
}
|
||||
}
|
||||
|
||||
C.addTransition(state->set<RegionState>(RS), N);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue