diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-19 22:05:47 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-19 22:05:47 +0000 |
commit | b12ab608fe80d5597090063ee3d72377d7560914 (patch) | |
tree | 6fe253608ebb6e8439c8f15be523b516453a3a7f /lib/AsmParser/Parser.cpp | |
parent | 97eadf21c8ec4dd5e1e669edb3b454231bd4d27a (diff) |
Split parseAssembly into parseAssembly and parseAssemblyInto.
This should restore the functionality of parsing new code into an existing
module without the confusing interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/Parser.cpp')
-rw-r--r-- | lib/AsmParser/Parser.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index 7c6598106ec..9bc9b241666 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -21,17 +21,24 @@ #include <system_error> using namespace llvm; -std::unique_ptr<Module> llvm::parseAssembly(std::unique_ptr<MemoryBuffer> F, - SMDiagnostic &Err, - LLVMContext &Context) { +bool llvm::parseAssemblyInto(std::unique_ptr<MemoryBuffer> F, Module &M, + SMDiagnostic &Err) { SourceMgr SM; - MemoryBuffer *Buf = F.get(); + StringRef Buf = F->getBuffer(); SM.AddNewSourceBuffer(F.release(), SMLoc()); + return LLParser(Buf, SM, Err, &M).Run(); +} + +std::unique_ptr<Module> llvm::parseAssembly(std::unique_ptr<MemoryBuffer> F, + SMDiagnostic &Err, + LLVMContext &Context) { std::unique_ptr<Module> M = - make_unique<Module>(Buf->getBufferIdentifier(), Context); - if (LLParser(Buf->getBuffer(), SM, Err, M.get()).Run()) + make_unique<Module>(F->getBufferIdentifier(), Context); + + if (parseAssemblyInto(std::move(F), *M, Err)) return nullptr; + return std::move(M); } |