[cfe-commits] r81783 - /cfe/trunk/lib/Analysis/BugReporter.cpp
Ted Kremenek
kremenek at apple.com
Mon Sep 14 13:40:59 PDT 2009
Author: kremenek
Date: Mon Sep 14 15:40:59 2009
New Revision: 81783
URL: http://llvm.org/viewvc/llvm-project?rev=81783&view=rev
Log:
Implement FIXME: free up BugReportEquivClass objects when deleting BugTypes.
Modified:
cfe/trunk/lib/Analysis/BugReporter.cpp
Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=81783&r1=81782&r2=81783&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Mon Sep 14 15:40:59 2009
@@ -1196,7 +1196,16 @@
//===----------------------------------------------------------------------===//
// Methods for BugType and subclasses.
//===----------------------------------------------------------------------===//
-BugType::~BugType() {}
+BugType::~BugType() {
+ // Free up the equivalence class objects. Observe that we get a pointer to
+ // the object first before incrementing the iterator, as destroying the
+ // node before doing so means we will read from freed memory.
+ for (iterator I = begin(), E = end(); I !=E; ) {
+ BugReportEquivClass *EQ = &*I;
+ ++I;
+ delete EQ;
+ }
+}
void BugType::FlushReports(BugReporter &BR) {}
//===----------------------------------------------------------------------===//
@@ -1319,9 +1328,6 @@
}
// Delete the BugType object.
-
- // FIXME: this will *not* delete the BugReportEquivClasses, since FoldingSet
- // only deletes the buckets, not the nodes themselves.
delete BT;
}
More information about the cfe-commits
mailing list