diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-09-11 01:01:40 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-09-11 01:01:40 +0000 |
commit | e23fa984f5094b58c0b57260ade5a6728336d3ab (patch) | |
tree | 3dba8d3bcdb1b1b2cb9f91e5d2af6888552e75ed /bindings/python/llvm/tests | |
parent | e9cf283e081cb68f0276aa4b893f290b9c26a0c7 (diff) | |
download | external_llvm-e23fa984f5094b58c0b57260ade5a6728336d3ab.zip external_llvm-e23fa984f5094b58c0b57260ade5a6728336d3ab.tar.gz external_llvm-e23fa984f5094b58c0b57260ade5a6728336d3ab.tar.bz2 |
[python-bindings] Added support for iterating over a function's basic blocks, dumping/getting names of those bb, f/w iteration.
Tests are included.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190473 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/llvm/tests')
-rw-r--r-- | bindings/python/llvm/tests/test_core.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bindings/python/llvm/tests/test_core.py b/bindings/python/llvm/tests/test_core.py index a1f79a4..67e294b 100644 --- a/bindings/python/llvm/tests/test_core.py +++ b/bindings/python/llvm/tests/test_core.py @@ -78,3 +78,25 @@ class TestCore(TestBase): self.assertEqual(f.name, functions[i]) f.dump() + def test_function_basicblock_iteration(self): + m = parse_bitcode(MemoryBuffer(filename=self.get_test_bc())) + i = 0 + + bb_list = ['b1', 'b2', 'end'] + + f = m.first + while f.name != "f6": + f = f.next + + # Forward + for bb in f: + self.assertEqual(bb.name, bb_list[i]) + bb.dump() + i += 1 + + # Backwards + for bb in reversed(f): + i -= 1 + self.assertEqual(bb.name, bb_list[i]) + bb.dump() + |