X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAsmParser%2FParser.cpp;h=d777ab91af81b48dc8388c628da6c864796102c7;hb=b3cabb44c32b5a3aba9b4d23aae9723d498ea7a9;hp=e511cbe29c756d6cb63559655f665c28ab74edd6;hpb=b019491b8d7b171cd0835ba34f3b28b24dfcc3e0;p=oota-llvm.git diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index e511cbe29c7..d777ab91af8 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -13,11 +13,12 @@ #include "llvm/Assembly/Parser.h" #include "LLParser.h" -#include "llvm/Module.h" #include "llvm/ADT/OwningPtr.h" -#include "llvm/Support/SourceMgr.h" +#include "llvm/IR/Module.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/system_error.h" #include using namespace llvm; @@ -41,16 +42,14 @@ Module *llvm::ParseAssembly(MemoryBuffer *F, Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err, LLVMContext &Context) { - std::string ErrorStr; - MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr); - if (F == 0) { - Err = SMDiagnostic(Filename, - "Could not open input file '" + Filename + "': " + - ErrorStr); + OwningPtr File; + if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { + Err = SMDiagnostic(Filename, SourceMgr::DK_Error, + "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,