diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-09 17:36:48 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-09 17:36:48 +0000 |
commit | 333fb04506233255f10d8095c9e2de5e5f0fdc6f (patch) | |
tree | 29b15348801de3482b07a438b1fb1f2ba094d3d2 /lib/Archive | |
parent | 908b6ddad6dac40c4c0453d690f0db9422b48b10 (diff) | |
download | external_llvm-333fb04506233255f10d8095c9e2de5e5f0fdc6f.zip external_llvm-333fb04506233255f10d8095c9e2de5e5f0fdc6f.tar.gz external_llvm-333fb04506233255f10d8095c9e2de5e5f0fdc6f.tar.bz2 |
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
Diffstat (limited to 'lib/Archive')
-rw-r--r-- | lib/Archive/Archive.cpp | 15 | ||||
-rw-r--r-- | lib/Archive/ArchiveWriter.cpp | 18 |
2 files changed, 25 insertions, 8 deletions
diff --git a/lib/Archive/Archive.cpp b/lib/Archive/Archive.cpp index e2e5593..3ce7fbd 100644 --- a/lib/Archive/Archive.cpp +++ b/lib/Archive/Archive.cpp @@ -17,6 +17,7 @@ #include "llvm/Module.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Process.h" +#include "llvm/Support/system_error.h" #include <memory> #include <cstring> using namespace llvm; @@ -147,9 +148,13 @@ Archive::Archive(const sys::Path& filename, LLVMContext& C) bool Archive::mapToMemory(std::string* ErrMsg) { - mapfile = MemoryBuffer::getFile(archPath.c_str(), ErrMsg); - if (mapfile == 0) + error_code ec; + mapfile = MemoryBuffer::getFile(archPath.c_str(), ec); + if (mapfile == 0) { + if (ErrMsg) + *ErrMsg = ec.message(); return true; + } base = mapfile->getBufferStart(); return false; } @@ -213,10 +218,12 @@ bool llvm::GetBitcodeSymbols(const sys::Path& fName, LLVMContext& Context, std::vector<std::string>& symbols, std::string* ErrMsg) { + error_code ec; std::auto_ptr<MemoryBuffer> Buffer( - MemoryBuffer::getFileOrSTDIN(fName.c_str())); + MemoryBuffer::getFileOrSTDIN(fName.c_str(), ec)); if (!Buffer.get()) { - if (ErrMsg) *ErrMsg = "Could not open file '" + fName.str() + "'"; + if (ErrMsg) *ErrMsg = "Could not open file '" + fName.str() + "'" + ": " + + ec.message(); return true; } diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp index de5887e..e9222c5 100644 --- a/lib/Archive/ArchiveWriter.cpp +++ b/lib/Archive/ArchiveWriter.cpp @@ -18,6 +18,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Process.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/system_error.h" #include <fstream> #include <ostream> #include <iomanip> @@ -212,9 +213,13 @@ Archive::writeMember( const char *data = (const char*)member.getData(); MemoryBuffer *mFile = 0; if (!data) { - mFile = MemoryBuffer::getFile(member.getPath().c_str(), ErrMsg); - if (mFile == 0) + error_code ec; + mFile = MemoryBuffer::getFile(member.getPath().c_str(), ec); + if (mFile == 0) { + if (ErrMsg) + *ErrMsg = ec.message(); return true; + } data = mFile->getBufferStart(); fSize = mFile->getBufferSize(); } @@ -406,8 +411,13 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress, // Map in the archive we just wrote. { - OwningPtr<MemoryBuffer> arch(MemoryBuffer::getFile(TmpArchive.c_str())); - if (arch == 0) return true; + error_code ec; + OwningPtr<MemoryBuffer> arch(MemoryBuffer::getFile(TmpArchive.c_str(), ec)); + if (arch == 0) { + if (ErrMsg) + *ErrMsg = ec.message(); + return true; + } const char* base = arch->getBufferStart(); // Open another temporary file in order to avoid invalidating the |