From 918c4ecb0c1c85adad760fb9d7faae088171d324 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 9 Apr 2002 05:43:19 +0000 Subject: 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 --- include/llvm/Analysis/LoopInfo.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include/llvm/Analysis') diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 13535bc7..5b6000d 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -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); } }; @@ -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 &getTopLevelLoops() const { return TopLevelLoops; } @@ -103,6 +108,8 @@ public: // runOnMethod - Pass framework implementation virtual bool runOnMethod(Function *F); + virtual void releaseMemory(); + // getAnalysisUsageInfo - Provide loop info, require dominator set // virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, -- cgit v1.1