summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-08-19 01:57:09 +0000
committerAnna Zaks <ganna@apple.com>2011-08-19 01:57:09 +0000
commitbe28d6c66d59f8ff66ad3aa378839831b81a93c5 (patch)
tree876a62d3f727a63937d4fc9ac8b3285ea72247c6 /clang/lib
parentda616d06e9a9fb235132915f427b45146cea456a (diff)
downloadbcm5719-llvm-be28d6c66d59f8ff66ad3aa378839831b81a93c5.tar.gz
bcm5719-llvm-be28d6c66d59f8ff66ad3aa378839831b81a93c5.zip
Fix a memory leak in the analyzer - BugReports didn't get freed. Plus, remove invalid assert from the destructor which wasn't called previously due to the leak.
llvm-svn: 138027
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 6624b93d2bf..6821806c846 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -1224,9 +1224,9 @@ void BugReport::addVisitor(BugReporterVisitor* visitor) {
BugReport::~BugReport() {
for (visitor_iterator I = visitor_begin(), E = visitor_end(); I != E; ++I) {
- // TODO: Remove the isOwned method; use reference counting to track visitors?.
- assert((*I)->isOwnedByReporterContext());
- delete *I;
+ if ((*I)->isOwnedByReporterContext()) {
+ delete *I;
+ }
}
}
@@ -1363,7 +1363,16 @@ ExplodedGraph &GRBugReporter::getGraph() { return Eng.getGraph(); }
ProgramStateManager&
GRBugReporter::getStateManager() { return Eng.getStateManager(); }
-BugReporter::~BugReporter() { FlushReports(); }
+BugReporter::~BugReporter() {
+ FlushReports();
+
+ // Free the bug reports we are tracking.
+ typedef std::vector<BugReportEquivClass *> ContTy;
+ for (ContTy::iterator I = EQClassesVector.begin(), E = EQClassesVector.end();
+ I != E; ++I) {
+ delete *I;
+ }
+}
void BugReporter::FlushReports() {
if (BugTypes.isEmpty())
@@ -1694,6 +1703,7 @@ void BugReporter::EmitReport(BugReport* R) {
if (!EQ) {
EQ = new BugReportEquivClass(R);
EQClasses.InsertNode(EQ, InsertPos);
+ EQClassesVector.push_back(EQ);
}
else
EQ->AddReport(R);
OpenPOWER on IntegriCloud