Fix memory leak in the stackifier, due to the machinebasicblocks not holding
[oota-llvm.git] / lib / VMCore / ModuleProvider.cpp
1 //===-- ModuleProvider.cpp - Base implementation for module providers -----===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // Minimal implementation of the abstract interface for providing a module.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/ModuleProvider.h"
15 #include "llvm/Module.h"
16 using namespace llvm;
17
18 /// ctor - always have a valid Module
19 ///
20 ModuleProvider::ModuleProvider() : TheModule(0) { }
21
22 /// dtor - when we leave, we take our Module with us
23 ///
24 ModuleProvider::~ModuleProvider() {
25   delete TheModule;
26 }
27
28 /// materializeFunction - make sure the given function is fully read.
29 ///
30 Module* ModuleProvider::materializeModule() {
31   assert(TheModule && "Attempting to materialize an invalid module!");
32
33   for (Module::iterator i = TheModule->begin(), e = TheModule->end();
34        i != e; ++i)
35     materializeFunction(i);
36
37   return TheModule;
38 }