From 03e54f2c123a9618bdd4b9dc89478f047b952562 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Tue, 4 Dec 2012 13:50:16 -0600 Subject: [PATCH] Expose preserve flag for Module.link_in --- llvm/core.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/llvm/core.py b/llvm/core.py index b264b50..bfbab1c 100644 --- a/llvm/core.py +++ b/llvm/core.py @@ -450,7 +450,7 @@ class Module(llvm.Ownable, llvm.Cacheable): llvm::Module::AnyPointerSize.""" return _core.LLVMModuleGetPointerSize(self.ptr) - def link_in(self, other): + def link_in(self, other, preserve=False): """Link the `other' module into this one. The `other' module is linked into this one such that types, @@ -463,12 +463,12 @@ class Module(llvm.Ownable, llvm.Cacheable): Linker class. """ check_is_module(other) - other.forget() # remove it from object cache - ret = _core.LLVMLinkModules(self.ptr, other.ptr) - if isinstance(ret, str): - raise llvm.LLVMException(ret) - # Do not try to destroy the other module's llvm::Module*. - other._own(llvm.DummyOwner()) + if not preserve: + other.forget() # remove it from object cache + _core.LLVMLinkModules(self.ptr, other.ptr, int(bool(preserve))) + if not preserve: + # Do not try to destroy the other module's llvm::Module*. + other._own(llvm.DummyOwner()) def get_type_named(self, name): """Return a Type object with the given name."""