Add a pointer to the owning LLVMContext to Module. This requires threading LLVMContext through a lot
of the bitcode reader and ASM parser APIs, as well as supporting it in all of the tools.
Patches for Clang and LLVM-GCC to follow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74614 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp
index 759e00e..7759c70 100644
--- a/lib/AsmParser/Parser.cpp
+++ b/lib/AsmParser/Parser.cpp
@@ -20,7 +20,8 @@
#include <cstring>
using namespace llvm;
-Module *llvm::ParseAssemblyFile(const std::string &Filename, ParseError &Err) {
+Module *llvm::ParseAssemblyFile(const std::string &Filename, ParseError &Err,
+ LLVMContext* Context) {
Err.setFilename(Filename);
std::string ErrorStr;
@@ -31,14 +32,14 @@
return 0;
}
- OwningPtr<Module> M(new Module(Filename));
+ OwningPtr<Module> M(new Module(Filename, Context));
if (LLParser(F.get(), Err, M.get()).Run())
return 0;
return M.take();
}
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
- ParseError &Err) {
+ ParseError &Err, LLVMContext* Context) {
Err.setFilename("<string>");
OwningPtr<MemoryBuffer>
@@ -50,7 +51,7 @@
return LLParser(F.get(), Err, M).Run() ? 0 : M;
// Otherwise create a new module.
- OwningPtr<Module> M2(new Module("<string>"));
+ OwningPtr<Module> M2(new Module("<string>", Context));
if (LLParser(F.get(), Err, M2.get()).Run())
return 0;
return M2.take();