summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-10-25 15:01:34 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-10-25 15:01:34 +0000
commit6e1c511aba87ab5f9962ae9328014897459f777a (patch)
tree4dbed7a0b1d0582c6b88672622eed35f8914ce3f
parentc7ef7c2de7f809f6407471048dd0302ebbc824ac (diff)
downloadllvm-6e1c511aba87ab5f9962ae9328014897459f777a.tar.gz
llvm-6e1c511aba87ab5f9962ae9328014897459f777a.tar.bz2
llvm-6e1c511aba87ab5f9962ae9328014897459f777a.tar.xz
Call destroy from ~BasicCallGraph.
This fix a memory leak found by valgrind. Calling it from the base class destructor would not destroy the BasicCallGraph bits. FIXME: BasicCallGraph is the only thing that inherits from CallGraph. Can we merge the two? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193412 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/CallGraph.h2
-rw-r--r--lib/Analysis/IPA/CallGraph.cpp4
2 files changed, 5 insertions, 1 deletions
diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h
index 591484dd27..926da76b5f 100644
--- a/include/llvm/Analysis/CallGraph.h
+++ b/include/llvm/Analysis/CallGraph.h
@@ -152,7 +152,7 @@ protected:
CallGraph() {}
public:
- virtual ~CallGraph() { destroy(); }
+ virtual ~CallGraph() { }
/// initialize - Call this method before calling other methods,
/// re/initializes the state of the CallGraph.
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp
index 7620fd9842..6c18d0d1a6 100644
--- a/lib/Analysis/IPA/CallGraph.cpp
+++ b/lib/Analysis/IPA/CallGraph.cpp
@@ -46,12 +46,16 @@ public:
ExternalCallingNode(0), CallsExternalNode(0) {
initializeBasicCallGraphPass(*PassRegistry::getPassRegistry());
}
+ ~BasicCallGraph() {
+ destroy();
+ }
// runOnModule - Compute the call graph for the specified module.
virtual bool runOnModule(Module &M) {
CallGraph::initialize(M);
ExternalCallingNode = getOrInsertFunction(0);
+ assert(!CallsExternalNode);
CallsExternalNode = new CallGraphNode(0);
Root = 0;