diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-16 03:29:14 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-16 03:29:14 +0000 |
commit | 3ff9563c3e391954b2e224afcf8b2b0fcc3888aa (patch) | |
tree | cccde9111a73ba5895f6cefbfb280290fa6c469d /lib/Linker | |
parent | b29b20e7deb7297f6a10b2d6922feeca8c6df055 (diff) | |
download | external_llvm-3ff9563c3e391954b2e224afcf8b2b0fcc3888aa.zip external_llvm-3ff9563c3e391954b2e224afcf8b2b0fcc3888aa.tar.gz external_llvm-3ff9563c3e391954b2e224afcf8b2b0fcc3888aa.tar.bz2 |
MemoryBuffer now return an error_code and returns a OwningPtr<MemoryBuffer> via an out parm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/LinkItems.cpp | 7 | ||||
-rw-r--r-- | lib/Linker/Linker.cpp | 10 |
2 files changed, 7 insertions, 10 deletions
diff --git a/lib/Linker/LinkItems.cpp b/lib/Linker/LinkItems.cpp index 7716b61..52a0d17 100644 --- a/lib/Linker/LinkItems.cpp +++ b/lib/Linker/LinkItems.cpp @@ -161,14 +161,13 @@ bool Linker::LinkInFile(const sys::Path &File, bool &is_native) { // Check for a file of name "-", which means "read standard input" if (File.str() == "-") { std::auto_ptr<Module> M; + OwningPtr<MemoryBuffer> Buffer; error_code ec; - if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN(ec)) { + if (!(ec = MemoryBuffer::getSTDIN(Buffer))) { if (!Buffer->getBufferSize()) { - delete Buffer; Error = "standard input is empty"; } else { - M.reset(ParseBitcodeFile(Buffer, Context, &Error)); - delete Buffer; + M.reset(ParseBitcodeFile(Buffer.get(), Context, &Error)); if (M.get()) if (!LinkInModule(M.get(), &Error)) return false; diff --git a/lib/Linker/Linker.cpp b/lib/Linker/Linker.cpp index 9606d06..fba91da 100644 --- a/lib/Linker/Linker.cpp +++ b/lib/Linker/Linker.cpp @@ -99,14 +99,12 @@ Linker::LoadObject(const sys::Path &FN) { std::string ParseErrorMessage; Module *Result = 0; - error_code ec; - std::auto_ptr<MemoryBuffer> Buffer( - MemoryBuffer::getFileOrSTDIN(FN.c_str(), ec)); - if (Buffer.get()) - Result = ParseBitcodeFile(Buffer.get(), Context, &ParseErrorMessage); - else + OwningPtr<MemoryBuffer> Buffer; + if (error_code ec = MemoryBuffer::getFileOrSTDIN(FN.c_str(), Buffer)) ParseErrorMessage = "Error reading file '" + FN.str() + "'" + ": " + ec.message(); + else + Result = ParseBitcodeFile(Buffer.get(), Context, &ParseErrorMessage); if (Result) return std::auto_ptr<Module>(Result); |