Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with error_code &ec. And fix clients.
llvm-svn: 121379
diff --git a/llvm/lib/Linker/LinkItems.cpp b/llvm/lib/Linker/LinkItems.cpp
index cbbdd4b..7716b61 100644
--- a/llvm/lib/Linker/LinkItems.cpp
+++ b/llvm/lib/Linker/LinkItems.cpp
@@ -18,6 +18,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/system_error.h"
using namespace llvm;
// LinkItems - This function is the main entry point into linking. It takes a
@@ -160,7 +161,8 @@
// Check for a file of name "-", which means "read standard input"
if (File.str() == "-") {
std::auto_ptr<Module> M;
- if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN(&Error)) {
+ error_code ec;
+ if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN(ec)) {
if (!Buffer->getBufferSize()) {
delete Buffer;
Error = "standard input is empty";
@@ -172,7 +174,7 @@
return false;
}
}
- return error("Cannot link stdin: " + Error);
+ return error("Cannot link stdin: " + ec.message());
}
// Determine what variety of file it is.
diff --git a/llvm/lib/Linker/Linker.cpp b/llvm/lib/Linker/Linker.cpp
index 6e27fda..9606d06 100644
--- a/llvm/lib/Linker/Linker.cpp
+++ b/llvm/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);