module.get_X_named() methods throws if object of given name is not found.

updated docs.

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@27 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2008-07-31 16:22:22 +00:00
commit 95dd7669ca
14 changed files with 238 additions and 106 deletions

View file

@ -1483,7 +1483,10 @@ class GlobalVariable(GlobalValue):
@staticmethod
def get(module, name):
return GlobalVariable(_core.LLVMGetNamedGlobal(module.ptr, name), module)
ptr = _core.LLVMGetNamedGlobal(module.ptr, name)
if not ptr:
raise llvm.LLVMException, ("no global named `%s`" % name)
return GlobalVariable(ptr, name)
def __init__(self, ptr, module):
GlobalValue.__init__(self, ptr, module)
@ -1539,7 +1542,10 @@ class Function(GlobalValue):
@staticmethod
def get(module, name):
return Function(_core.LLVMGetNamedFunction(module.ptr, name), module)
ptr = _core.LLVMGetNamedFunction(module.ptr, name)
if not ptr:
raise llvm.LLVMException, ("no function named `%s`" % name)
return Function(ptr, module)
@staticmethod
def intrinsic(module, id, types):