* Rename MethodPass class to FunctionPass
[oota-llvm.git] / include / llvm / Analysis / LoopInfo.h
index 13535bc788539b1514a58f5968ce4cc2b71ca31f..6c9468c7d3a053fbe553b9863a0d4dd45e60fe8f 100644 (file)
@@ -46,10 +46,14 @@ public:
 private:
   friend class LoopInfo;
   inline Loop(const BasicBlock *BB) { Blocks.push_back(BB); LoopDepth = 0; }
+  ~Loop() {
+    for (unsigned i = 0, e = SubLoops.size(); i != e; ++i)
+      delete SubLoops[i];
+  }
   
   void setLoopDepth(unsigned Level) {
     LoopDepth = Level;
-    for (unsigned i = 0; i < SubLoops.size(); ++i)
+    for (unsigned i = 0, e = SubLoops.size(); i != e; ++i)
       SubLoops[i]->setLoopDepth(Level+1);
   }
 };
@@ -58,9 +62,9 @@ private:
 
 //===----------------------------------------------------------------------===//
 // LoopInfo - This class builds and contains all of the top level loop
-// structures in the specified method.
+// structures in the specified function.
 //
-class LoopInfo : public MethodPass {
+class LoopInfo : public FunctionPass {
   // BBMap - Mapping of basic blocks to the inner most loop they occur in
   std::map<const BasicBlock *, Loop*> BBMap;
   std::vector<Loop*> TopLevelLoops;
@@ -69,6 +73,7 @@ public:
 
   // LoopInfo ctor - Calculate the natural loop information for a CFG
   LoopInfo(AnalysisID id) { assert(id == ID); }
+  ~LoopInfo() { releaseMemory(); }
 
   const std::vector<Loop*> &getTopLevelLoops() const { return TopLevelLoops; }
 
@@ -100,14 +105,15 @@ public:
   bool isLoopExit(const BasicBlock *BB) const;
 #endif
 
-  // runOnMethod - Pass framework implementation
-  virtual bool runOnMethod(Function *F);
+  // runOnFunction - Pass framework implementation
+  virtual bool runOnFunction(Function *F);
+
+  virtual void releaseMemory();
 
-  // getAnalysisUsageInfo - Provide loop info, require dominator set
+  // getAnalysisUsage - Provide loop info, require dominator set
   //
-  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
-                                    Pass::AnalysisSet &Destroyed,
-                                    Pass::AnalysisSet &Provided);
+  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
+
 private:
   void Calculate(const DominatorSet &DS);
   Loop *ConsiderForLoop(const BasicBlock *BB, const DominatorSet &DS);