LTO API: add lto_module_create_from_memory_with_path.

This function adds an extra path argument to lto_module_create_from_memory.
The path argument will be passed to makeBuffer to make sure the MemoryBuffer
has a name and the created module has a module identifier.

This is mainly for emitting warning messages from the linker. When we emit
warning message on a module, we can use the module identifier.

rdar://15985737

llvm-svn: 201114
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h
index fbad2b5..bff63ad 100644
--- a/llvm/include/llvm-c/lto.h
+++ b/llvm/include/llvm-c/lto.h
@@ -40,7 +40,7 @@
  * @{
  */
 
-#define LTO_API_VERSION 8
+#define LTO_API_VERSION 9
 
 /**
  * \since prior to LTO_API_VERSION=3
@@ -176,6 +176,16 @@
 lto_module_create_from_memory(const void* mem, size_t length);
 
 /**
+ * Loads an object file from memory with an extra path argument.
+ * Returns NULL on error (check lto_get_error_message() for details).
+ *
+ * \since prior to LTO_API_VERSION=9
+ */
+extern lto_module_t
+lto_module_create_from_memory_with_path(const void* mem, size_t length,
+                                        const char *path);
+
+/**
  * Loads an object file from disk. The seek point of fd is not preserved.
  * Returns NULL on error (check lto_get_error_message() for details).
  *
diff --git a/llvm/include/llvm/LTO/LTOModule.h b/llvm/include/llvm/LTO/LTOModule.h
index c70afa4..a70b71f 100644
--- a/llvm/include/llvm/LTO/LTOModule.h
+++ b/llvm/include/llvm/LTO/LTOModule.h
@@ -100,7 +100,8 @@
                                   std::string& errMsg);
   static LTOModule *makeLTOModule(const void *mem, size_t length,
                                   llvm::TargetOptions options,
-                                  std::string &errMsg);
+                                  std::string &errMsg,
+                                  llvm::StringRef path = "");
 
   /// getTargetTriple - Return the Module's target triple.
   const char *getTargetTriple() {
@@ -222,8 +223,9 @@
                                   llvm::TargetOptions options,
                                   std::string &errMsg);
 
-  /// makeBuffer - Create a MemoryBuffer from a memory range.
-  static llvm::MemoryBuffer *makeBuffer(const void *mem, size_t length);
+  /// Create a MemoryBuffer from a memory range with an optional name.
+  static llvm::MemoryBuffer *makeBuffer(const void *mem, size_t length,
+                                        llvm::StringRef name = "");
 };
 
 #endif // LTO_MODULE_H