A better attempt to add a missing include
[oota-llvm.git] / include / llvm / Transforms / IPO / FunctionImport.h
index 0315c72811c168d5f91e0a51e258154d6563ef27..d7707790a017909a66af1aaca496d6c7916556e9 100644 (file)
 #ifndef LLVM_FUNCTIONIMPORT_H
 #define LLVM_FUNCTIONIMPORT_H
 
-#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/ADT/StringMap.h"
+#include <functional>
 
 namespace llvm {
 class LLVMContext;
 class Module;
 class FunctionInfoIndex;
 
-/// Helper to load on demand a Module from file and cache it for subsequent
-/// queries. It can be used with the FunctionImporter.
-class ModuleLazyLoaderCache {
-  /// The context that will be used for importing.
-  LLVMContext &Context;
-
-  /// Cache of lazily loaded module for import.
-  StringMap<std::unique_ptr<Module>> ModuleMap;
-
-public:
-  /// Create the loader, Module will be initialized in \p Context.
-  ModuleLazyLoaderCache(LLVMContext &Context) : Context(Context) {}
-
-  /// Retrieve a Module from the cache or lazily load it on demand.
-  Module &operator()(StringRef FileName);
-};
-
 /// The function importer is automatically importing function from other modules
 /// based on the provided summary informations.
 class FunctionImporter {
@@ -42,19 +25,15 @@ class FunctionImporter {
   /// The summaries index used to trigger importing.
   const FunctionInfoIndex &Index;
 
-  /// Diagnostic will be sent to this handler.
-  DiagnosticHandlerFunction DiagnosticHandler;
-
-  /// Retrieve a Module from the cache or lazily load it on demand.
-  std::function<Module &(StringRef FileName)> getLazyModule;
+  /// Factory function to load a Module for a given identifier
+  std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader;
 
 public:
   /// Create a Function Importer.
-  FunctionImporter(const FunctionInfoIndex &Index,
-                   DiagnosticHandlerFunction DiagnosticHandler,
-                   std::function<Module &(StringRef FileName)> ModuleLoader)
-      : Index(Index), DiagnosticHandler(DiagnosticHandler),
-        getLazyModule(ModuleLoader) {}
+  FunctionImporter(
+      const FunctionInfoIndex &Index,
+      std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader)
+      : Index(Index), ModuleLoader(ModuleLoader) {}
 
   /// Import functions in Module \p M based on the summary informations.
   bool importFunctions(Module &M);