diff options
author | Chris Lattner <sabre@nondot.org> | 2009-07-02 23:08:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-07-02 23:08:13 +0000 |
commit | eeb4a84ac8d91fb1d5a7c484a1c7047409faee30 (patch) | |
tree | a74754636cc687794c2d224169dec37702cc34be /lib/AsmParser/Parser.cpp | |
parent | 92bcb426c3e4503c99324afd4ed0a73521711a56 (diff) |
switch the .ll parser to use SourceMgr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74735 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/Parser.cpp')
-rw-r--r-- | lib/AsmParser/Parser.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index 17aae397ea..d66c13d39c 100644 --- a/lib/AsmParser/Parser.cpp +++ b/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<MemoryBuffer> - 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<Module> 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<MemoryBuffer> - F(MemoryBuffer::getMemBuffer(AsmString, AsmString+strlen(AsmString), - "<string>")); + MemoryBuffer *F = + MemoryBuffer::getMemBuffer(AsmString, AsmString+strlen(AsmString), + "<string>"); + 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<Module> M2(new Module("<string>", Context)); - if (LLParser(F.get(), Err, M2.get()).Run()) + if (LLParser(F, SM, Err, M2.get()).Run()) return 0; return M2.take(); } |