llvm.org GIT mirror llvm / b12ab60
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 Rafael Espindola 6 years ago
2 changed file(s) with 26 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
4949 SMDiagnostic &Error,
5050 LLVMContext &Context);
5151
52 /// This function is the low-level interface to the LLVM Assembly Parser.
53 /// ParseAssemblyFile and ParseAssemblyString are wrappers around this function.
52 /// parseAssemblyFile and parseAssemblyString are wrappers around this function.
5453 /// @brief Parse LLVM Assembly from a MemoryBuffer.
5554 /// @param F The MemoryBuffer containing assembly
5655 /// @param Err Error result info.
5857 std::unique_ptr parseAssembly(std::unique_ptr F,
5958 SMDiagnostic &Err, LLVMContext &Context);
6059
60 /// This function is the low-level interface to the LLVM Assembly Parser.
61 /// This is kept as an independent function instead of being inlined into
62 /// parseAssembly for the convenience of interactive users that want to add
63 /// recently parsed bits to an existing module.
64 ///
65 /// @param F The MemoryBuffer containing assembly
66 /// @param M The module to add data to.
67 /// @param Err Error result info.
68 /// @return true on error.
69 bool parseAssemblyInto(std::unique_ptr F, Module &M,
70 SMDiagnostic &Err);
71
6172 } // End llvm namespace
6273
6374 #endif
2020 #include
2121 using namespace llvm;
2222
23 bool llvm::parseAssemblyInto(std::unique_ptr F, Module &M,
24 SMDiagnostic &Err) {
25 SourceMgr SM;
26 StringRef Buf = F->getBuffer();
27 SM.AddNewSourceBuffer(F.release(), SMLoc());
28
29 return LLParser(Buf, SM, Err, &M).Run();
30 }
31
2332 std::unique_ptr llvm::parseAssembly(std::unique_ptr F,
2433 SMDiagnostic &Err,
2534 LLVMContext &Context) {
26 SourceMgr SM;
27 MemoryBuffer *Buf = F.get();
28 SM.AddNewSourceBuffer(F.release(), SMLoc());
35 std::unique_ptr M =
36 make_unique(F->getBufferIdentifier(), Context);
2937
30 std::unique_ptr M =
31 make_unique(Buf->getBufferIdentifier(), Context);
32 if (LLParser(Buf->getBuffer(), SM, Err, M.get()).Run())
38 if (parseAssemblyInto(std::move(F), *M, Err))
3339 return nullptr;
40
3441 return std::move(M);
3542 }
3643