X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAsmParser%2FParser.cpp;h=d777ab91af81b48dc8388c628da6c864796102c7;hb=b3cabb44c32b5a3aba9b4d23aae9723d498ea7a9;hp=aac4027fc57899c84296feb8ba50b706d6b3ac58;hpb=82b5a30724e478ff7fbfe1483f6058657202939b;p=oota-llvm.git diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index aac4027fc57..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,22 +42,20 @@ 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("", -1, -1, - "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, SMDiagnostic &Err, LLVMContext &Context) { MemoryBuffer *F = - MemoryBuffer::getMemBuffer(AsmString, AsmString+strlen(AsmString), + MemoryBuffer::getMemBuffer(StringRef(AsmString, strlen(AsmString)), ""); return ParseAssembly(F, M, Err, Context);