summaryrefslogtreecommitdiffstats
path: root/include/llvm/Support/IRReader.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Support/IRReader.h')
-rw-r--r--include/llvm/Support/IRReader.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/include/llvm/Support/IRReader.h b/include/llvm/Support/IRReader.h
index a44da52..292c001 100644
--- a/include/llvm/Support/IRReader.h
+++ b/include/llvm/Support/IRReader.h
@@ -19,10 +19,12 @@
#ifndef LLVM_SUPPORT_IRREADER_H
#define LLVM_SUPPORT_IRREADER_H
+#include "llvm/ADT/OwningPtr.h"
#include "llvm/Assembly/Parser.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/system_error.h"
namespace llvm {
@@ -56,15 +58,14 @@ namespace llvm {
inline Module *getLazyIRFileModule(const std::string &Filename,
SMDiagnostic &Err,
LLVMContext &Context) {
- std::string ErrMsg;
- MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg);
- if (F == 0) {
- Err = SMDiagnostic(Filename,
- "Could not open input file: " + ErrMsg);
+ OwningPtr<MemoryBuffer> File;
+ if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), File)) {
+ Err = SMDiagnostic(Filename,
+ "Could not open input file: " + ec.message());
return 0;
}
- return getLazyIRModule(F, Err, Context);
+ return getLazyIRModule(File.take(), Err, Context);
}
/// If the given MemoryBuffer holds a bitcode image, return a Module
@@ -94,15 +95,14 @@ namespace llvm {
inline Module *ParseIRFile(const std::string &Filename,
SMDiagnostic &Err,
LLVMContext &Context) {
- std::string ErrMsg;
- MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg);
- if (F == 0) {
- Err = SMDiagnostic(Filename,
- "Could not open input file: " + ErrMsg);
+ OwningPtr<MemoryBuffer> File;
+ if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), File)) {
+ Err = SMDiagnostic(Filename,
+ "Could not open input file: " + ec.message());
return 0;
}
- return ParseIR(F, Err, Context);
+ return ParseIR(File.take(), Err, Context);
}
}
OpenPOWER on IntegriCloud