From aa6a406c46f6a2e0725817ff7b0cf620f250e5d9 Mon Sep 17 00:00:00 2001 From: "mdevan.foobar" Date: Tue, 3 Aug 2010 16:31:41 +0000 Subject: [PATCH] Add and remove function attributes (Krzysztof Goj) git-svn-id: http://llvm-py.googlecode.com/svn/trunk@89 8d1e9007-1d4e-0410-b67e-1979fd6579aa --- llvm/_core.c | 5 +++++ llvm/core.py | 6 ++++++ test/testall.py | 3 +++ 3 files changed, 14 insertions(+) diff --git a/llvm/_core.c b/llvm/_core.c index 8569e15..17e271a 100644 --- a/llvm/_core.c +++ b/llvm/_core.c @@ -512,6 +512,9 @@ _wrap_obj2obj(LLVMGetDoesNotThrow, LLVMValueRef, int) _wrap_objint2none(LLVMSetDoesNotThrow, LLVMValueRef) _wrap_obj2none(LLVMViewFunctionCFG, LLVMValueRef) _wrap_obj2none(LLVMViewFunctionCFGOnly, LLVMValueRef) +_wrap_objenum2none(LLVMAddFunctionAttr, LLVMValueRef, LLVMAttribute) +_wrap_objenum2none(LLVMRemoveFunctionAttr, LLVMValueRef, LLVMAttribute) + static PyObject * _wLLVMVerifyFunction(PyObject *self, PyObject *args) @@ -1390,6 +1393,8 @@ static PyMethodDef core_methods[] = { _method( LLVMVerifyFunction ) _method( LLVMViewFunctionCFG ) _method( LLVMViewFunctionCFGOnly ) + _method( LLVMAddFunctionAttr ) + _method( LLVMRemoveFunctionAttr ) /* Arguments */ _method( LLVMCountParams ) diff --git a/llvm/core.py b/llvm/core.py index ba97f51..afc7a51 100644 --- a/llvm/core.py +++ b/llvm/core.py @@ -1349,6 +1349,12 @@ class Function(GlobalValue): def viewCFG(self): return _core.LLVMViewFunctionCFG(self.ptr) + def add_attribute(self, attr): + _core.LLVMAddFunctionAttr(self.ptr, attr) + + def remove_attribute(self, attr): + _core.LLVMRemoveFunctionAttr(self.ptr, attr) + def viewCFGOnly(self): return _core.LLVMViewFunctionCFGOnly(self.ptr) diff --git a/test/testall.py b/test/testall.py index 0562770..586a402 100755 --- a/test/testall.py +++ b/test/testall.py @@ -295,6 +295,9 @@ def do_function(): g = f.append_basic_block('a') g = f.get_entry_basic_block() g = list(f.basic_blocks) + f.add_attribute(ATTR_NO_RETURN) + f.add_attribute(ATTR_ALWAYS_INLINE) + f.remove_attribute(ATTR_NO_RETURN) # LLVM misbehaves: #try: # f.verify()