Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with error_code &ec. And fix clients.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121379 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Linker/Linker.cpp b/lib/Linker/Linker.cpp
index 6e27fda..9606d06 100644
--- a/lib/Linker/Linker.cpp
+++ b/lib/Linker/Linker.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Config/config.h"
+#include "llvm/Support/system_error.h"
 using namespace llvm;
 
 Linker::Linker(StringRef progname, StringRef modname,
@@ -98,11 +99,14 @@
   std::string ParseErrorMessage;
   Module *Result = 0;
 
-  std::auto_ptr<MemoryBuffer> Buffer(MemoryBuffer::getFileOrSTDIN(FN.c_str()));
+  error_code ec;
+  std::auto_ptr<MemoryBuffer> Buffer(
+    MemoryBuffer::getFileOrSTDIN(FN.c_str(), ec));
   if (Buffer.get())
     Result = ParseBitcodeFile(Buffer.get(), Context, &ParseErrorMessage);
   else
-    ParseErrorMessage = "Error reading file '" + FN.str() + "'";
+    ParseErrorMessage = "Error reading file '" + FN.str() + "'" + ": "
+                      + ec.message();
 
   if (Result)
     return std::auto_ptr<Module>(Result);