Add support for module named metadata
This is mainly useful to get access to top-level debug information through 'llvm.dbg.cu'. Wraps LLVM C-API functions `LLVMGetNamedMetadataNumOperands`, `LLVMGetNamedMetadataOperands` and `LLVMAddNamedMetadataOperand`. Also add testcase.
This commit is contained in:
parent
5ee6bba66b
commit
6e6bd1ea71
3 changed files with 46 additions and 1 deletions
|
|
@ -16,7 +16,7 @@ else:
|
|||
|
||||
from llvm import __version__
|
||||
from llvm.core import (Module, Type, GlobalVariable, Function, Builder,
|
||||
Constant)
|
||||
Constant, MetaData)
|
||||
import llvm.passes as lp
|
||||
import llvm.ee as le
|
||||
|
||||
|
|
@ -390,6 +390,19 @@ tests.append(TestUses)
|
|||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestMetaData(unittest.TestCase):
|
||||
# test module metadata
|
||||
def test_metadata(self):
|
||||
m = Module.new('a')
|
||||
metadata = MetaData.get(m, []) # empty metadata node
|
||||
MetaData.add_named_operand(m, 'foo', metadata)
|
||||
self.assertEqual(MetaData.get_named_operands(m, 'foo'), [metadata])
|
||||
self.assertEqual(MetaData.get_named_operands(m, 'bar'), [])
|
||||
|
||||
tests.append(TestMetaData)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def run(verbosity=1):
|
||||
print('llvmpy is installed in: ' + os.path.dirname(__file__))
|
||||
print('llvmpy version: ' + __version__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue