From 200e0757c7411bd9ddf6ec17672f9f7bc27ffa4f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 2 Jul 2009 23:08:13 +0000 Subject: switch the .ll parser to use SourceMgr. llvm-svn: 74735 --- llvm/lib/AsmParser/Parser.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'llvm/lib/AsmParser/Parser.cpp') diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp index 17aae397eaa..d66c13d39c0 100644 --- a/llvm/lib/AsmParser/Parser.cpp +++ b/llvm/lib/AsmParser/Parser.cpp @@ -24,33 +24,38 @@ using namespace llvm; Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err, LLVMContext &Context) { std::string ErrorStr; - OwningPtr - F(MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr)); + MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr); if (F == 0) { Err = SMDiagnostic("", -1, -1, "Could not open input file '" + Filename + "'", ""); return 0; } + SourceMgr SM; + SM.AddNewSourceBuffer(F, SMLoc()); + OwningPtr M(new Module(Filename, Context)); - if (LLParser(F.get(), Err, M.get()).Run()) + if (LLParser(F, SM, Err, M.get()).Run()) return 0; return M.take(); } Module *llvm::ParseAssemblyString(const char *AsmString, Module *M, SMDiagnostic &Err, LLVMContext &Context) { - OwningPtr - F(MemoryBuffer::getMemBuffer(AsmString, AsmString+strlen(AsmString), - "")); + MemoryBuffer *F = + MemoryBuffer::getMemBuffer(AsmString, AsmString+strlen(AsmString), + ""); + SourceMgr SM; + SM.AddNewSourceBuffer(F, SMLoc()); + // If we are parsing into an existing module, do it. if (M) - return LLParser(F.get(), Err, M).Run() ? 0 : M; + return LLParser(F, SM, Err, M).Run() ? 0 : M; // Otherwise create a new module. OwningPtr M2(new Module("", Context)); - if (LLParser(F.get(), Err, M2.get()).Run()) + if (LLParser(F, SM, Err, M2.get()).Run()) return 0; return M2.take(); } -- cgit v1.2.3