Don't leak all of the Loop objects created...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2196 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index cd7768f..ef47936 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -22,13 +22,21 @@
   return find(Blocks.begin(), Blocks.end(), BB) != Blocks.end();
 }
 
+void cfg::LoopInfo::releaseMemory() {
+  for (std::vector<Loop*>::iterator I = TopLevelLoops.begin(),
+         E = TopLevelLoops.end(); I != E; ++I)
+    delete *I;   // Delete all of the loops...
+
+  BBMap.clear();                             // Reset internal state of analysis
+  TopLevelLoops.clear();
+}
+
 
 //===----------------------------------------------------------------------===//
 // cfg::LoopInfo implementation
 //
 bool cfg::LoopInfo::runOnMethod(Function *F) {
-  BBMap.clear();                             // Reset internal state of analysis
-  TopLevelLoops.clear();
+  releaseMemory();
   Calculate(getAnalysis<DominatorSet>());    // Update
   return false;
 }