From f8c17b79ab55d633567a151da5eb596b6001fa30 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Thu, 9 Feb 2012 06:48:19 +0000 Subject: [PATCH] [analyzer] MallocChecker: address a diagnostic "fixme". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150158 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 4a15afd986..7edc50d42f 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -651,12 +651,13 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, RegionStateTy::Factory &F = state->get_context(); bool generateReport = false; - + llvm::SmallVector Errors; for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) { if (SymReaper.isDead(I->first)) { - if (I->second.isAllocated()) + if (I->second.isAllocated()) { generateReport = true; - + Errors.push_back(I->first); + } // Remove the dead symbol from the map. RS = F.remove(RS, I->first); @@ -665,17 +666,16 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, ExplodedNode *N = C.addTransition(state->set(RS)); - // FIXME: This does not handle when we have multiple leaks at a single - // place. - // TODO: We don't have symbol info in the diagnostics here! if (N && generateReport) { if (!BT_Leak) BT_Leak.reset(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); - //Report->addVisitor(new MallocBugVisitor(Sym)); - C.EmitReport(R); + "Allocated memory never released. Potential memory leak.")); + for (llvm::SmallVector::iterator + I = Errors.begin(), E = Errors.end(); I != E; ++I) { + BugReport *R = new BugReport(*BT_Leak, BT_Leak->getDescription(), N); + R->addVisitor(new MallocBugVisitor(*I)); + C.EmitReport(R); + } } } -- 2.50.1