mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-08 18:30:04 +00:00
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
This commit is contained in:
parent
97eadf21c8
commit
b12ab608fe
@ -50,8 +50,7 @@ std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
|
|||||||
SMDiagnostic &Error,
|
SMDiagnostic &Error,
|
||||||
LLVMContext &Context);
|
LLVMContext &Context);
|
||||||
|
|
||||||
/// This function is the low-level interface to the LLVM Assembly Parser.
|
/// parseAssemblyFile and parseAssemblyString are wrappers around this function.
|
||||||
/// ParseAssemblyFile and ParseAssemblyString are wrappers around this function.
|
|
||||||
/// @brief Parse LLVM Assembly from a MemoryBuffer.
|
/// @brief Parse LLVM Assembly from a MemoryBuffer.
|
||||||
/// @param F The MemoryBuffer containing assembly
|
/// @param F The MemoryBuffer containing assembly
|
||||||
/// @param Err Error result info.
|
/// @param Err Error result info.
|
||||||
@ -59,6 +58,18 @@ std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
|
|||||||
std::unique_ptr<Module> parseAssembly(std::unique_ptr<MemoryBuffer> F,
|
std::unique_ptr<Module> parseAssembly(std::unique_ptr<MemoryBuffer> F,
|
||||||
SMDiagnostic &Err, LLVMContext &Context);
|
SMDiagnostic &Err, LLVMContext &Context);
|
||||||
|
|
||||||
|
/// This function is the low-level interface to the LLVM Assembly Parser.
|
||||||
|
/// This is kept as an independent function instead of being inlined into
|
||||||
|
/// parseAssembly for the convenience of interactive users that want to add
|
||||||
|
/// recently parsed bits to an existing module.
|
||||||
|
///
|
||||||
|
/// @param F The MemoryBuffer containing assembly
|
||||||
|
/// @param M The module to add data to.
|
||||||
|
/// @param Err Error result info.
|
||||||
|
/// @return true on error.
|
||||||
|
bool parseAssemblyInto(std::unique_ptr<MemoryBuffer> F, Module &M,
|
||||||
|
SMDiagnostic &Err);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,17 +21,24 @@
|
|||||||
#include <system_error>
|
#include <system_error>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
bool llvm::parseAssemblyInto(std::unique_ptr<MemoryBuffer> F, Module &M,
|
||||||
|
SMDiagnostic &Err) {
|
||||||
|
SourceMgr SM;
|
||||||
|
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,
|
std::unique_ptr<Module> llvm::parseAssembly(std::unique_ptr<MemoryBuffer> F,
|
||||||
SMDiagnostic &Err,
|
SMDiagnostic &Err,
|
||||||
LLVMContext &Context) {
|
LLVMContext &Context) {
|
||||||
SourceMgr SM;
|
|
||||||
MemoryBuffer *Buf = F.get();
|
|
||||||
SM.AddNewSourceBuffer(F.release(), SMLoc());
|
|
||||||
|
|
||||||
std::unique_ptr<Module> M =
|
std::unique_ptr<Module> M =
|
||||||
make_unique<Module>(Buf->getBufferIdentifier(), Context);
|
make_unique<Module>(F->getBufferIdentifier(), Context);
|
||||||
if (LLParser(Buf->getBuffer(), SM, Err, M.get()).Run())
|
|
||||||
|
if (parseAssemblyInto(std::move(F), *M, Err))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return std::move(M);
|
return std::move(M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user