Add removeModuleProvider()


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43002 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index 7100a5f..2a2fb7c 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -97,7 +97,11 @@
   void addModuleProvider(ModuleProvider *P) {
     Modules.push_back(P);
   }
-  
+
+  /// removeModuleProvider - Remove a ModuleProvider from the list of modules.
+  /// Release module from ModuleProvider.
+  Module* removeModuleProvider(ModuleProvider *P, std::string *ErrInfo = 0);
+
   /// FindFunctionNamed - Search all of the active modules to find the one that
   /// defines FnName.  This is very slow operation and shouldn't be used for
   /// general code.
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index 96604f1..512c452 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -51,6 +51,21 @@
     delete Modules[i];
 }
 
+/// removeModuleProvider - Remove a ModuleProvider from the list of modules.
+/// Release module from ModuleProvider.
+Module* ExecutionEngine::removeModuleProvider(ModuleProvider *P, 
+                                              std::string *ErrInfo) {
+  for(SmallVector<ModuleProvider *, 1>::iterator I = Modules.begin(), 
+        E = Modules.end(); I != E; ++I) {
+    ModuleProvider *MP = *I;
+    if (MP == P) {
+      Modules.erase(I);
+      return MP->releaseModule(ErrInfo);
+    }
+  }
+  return NULL;
+}
+
 /// FindFunctionNamed - Search all of the active modules to find the one that
 /// defines FnName.  This is very slow operation and shouldn't be used for
 /// general code.