Fix for issue #10.

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@59 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2009-01-10 11:00:00 +00:00
commit 58ceb85afb
2 changed files with 25 additions and 2 deletions

View file

@ -1940,8 +1940,11 @@ class Builder(object):
Next instruction inserted will be first one in the block."""
# Avoids using "blk.instructions", which will fetch all the
# instructions into a list. Don't try this at home, though.
first_inst = Instruction(_core.LLVMGetFirstInstruction(self.block.ptr))
self.position_before(first_inst)
inst_ptr = _core.LLVMGetFirstInstruction(self.block.ptr)
if inst_ptr:
# Issue #10: inst_ptr can be None if b/b has no insts.
inst = Instruction(inst_ptr)
self.position_before(inst)
def position_at_end(self, bblk):
"""Position the builder at the end of the given block.