aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/AsmParser/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/AsmParser/Parser.cpp')
-rw-r--r--llvm/lib/AsmParser/Parser.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp
index 7c65981..9bc9b241 100644
--- a/llvm/lib/AsmParser/Parser.cpp
+++ b/llvm/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);
}