aboutsummaryrefslogtreecommitdiff
path: root/lib/AsmParser/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AsmParser/Parser.cpp')
-rw-r--r--lib/AsmParser/Parser.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp
index a613a8346a..59fb471f2b 100644
--- a/lib/AsmParser/Parser.cpp
+++ b/lib/AsmParser/Parser.cpp
@@ -42,15 +42,14 @@ Module *llvm::ParseAssembly(MemoryBuffer *F,
Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
LLVMContext &Context) {
- error_code ec;
- MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), ec);
- if (F == 0) {
+ 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 ParseAssembly(F, 0, Err, Context);
+ return ParseAssembly(File.take(), 0, Err, Context);
}
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,