From 7e70829632f82de15db187845666aaca6e04b792 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 25 Jun 2002 16:13:24 +0000 Subject: MEGAPATCH checkin. For details, See: docs/2002-06-25-MegaPatchInfo.txt git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2779 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Module.cpp | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'lib/VMCore/Module.cpp') diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 0d25691cba..b8cffdb56f 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -11,14 +11,29 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "Support/STLExtras.h" -#include "ValueHolderImpl.h" +#include "SymbolTableListTraitsImpl.h" +#include #include -// Instantiate Templates - This ugliness is the price we have to pay -// for having a DefHolderImpl.h file seperate from DefHolder.h! :( -// -template class ValueHolder; -template class ValueHolder; +Function *ilist_traits::createNode() { + return new Function(FunctionType::get(Type::VoidTy,std::vector(), + false), false); +} +GlobalVariable *ilist_traits::createNode() { + return new GlobalVariable(Type::IntTy, false, false); +} + +iplist &ilist_traits::getList(Module *M) { + return M->getFunctionList(); +} +iplist &ilist_traits::getList(Module *M) { + return M->getGlobalList(); +} + +// Explicit instantiations of SymbolTableListTraits since some of the methods +// are not in the public header file... +template SymbolTableListTraits; +template SymbolTableListTraits; // Define the GlobalValueRefMap as a struct that wraps a map so that we don't // have Module.h depend on @@ -27,16 +42,20 @@ struct GlobalValueRefMap : public std::map{ }; -Module::Module() : GlobalList(this, this), FunctionList(this, this) { +Module::Module() { + FunctionList.setItemParent(this); + FunctionList.setParent(this); + GlobalList.setItemParent(this); + GlobalList.setParent(this); GVRefMap = 0; SymTab = 0; } Module::~Module() { dropAllReferences(); - GlobalList.delete_all(); + GlobalList.clear(); GlobalList.setParent(0); - FunctionList.delete_all(); + FunctionList.clear(); FunctionList.setParent(0); delete SymTab; } @@ -136,11 +155,11 @@ std::string Module::getTypeName(const Type *Ty) { // delete. // void Module::dropAllReferences() { - for_each(FunctionList.begin(), FunctionList.end(), - std::mem_fun(&Function::dropAllReferences)); + for(Module::iterator I = begin(), E = end(); I != E; ++I) + I->dropAllReferences(); - for_each(GlobalList.begin(), GlobalList.end(), - std::mem_fun(&GlobalVariable::dropAllReferences)); + for(Module::giterator I = gbegin(), E = gend(); I != E; ++I) + I->dropAllReferences(); // If there are any GlobalVariable references still out there, nuke them now. // Since all references are hereby dropped, nothing could possibly reference -- cgit v1.2.3