From 7c492a17521b12b59c379cc3bfc6ffbe8415153c Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 14 Jul 2015 01:23:06 +0000 Subject: [PATCH] Add capability to get and set the personalitty function from the C API Summary: The capability was lost with D10429 where the personality function was set at function level rather than landing pad level. Now there is no way to get/set the personality function from the C API. That is a problem. Note that the whole thing could be avoided by improving the C API testing, as started by D10725 Reviewers: chandlerc, bogner, majnemer, andrew.w.kaylor, rafael, rnk, axw Subscribers: rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D10946 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242104 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 14 ++++++++++++++ lib/IR/Core.cpp | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 713894f5763..15290072abe 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -1887,6 +1887,20 @@ LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, */ void LLVMDeleteFunction(LLVMValueRef Fn); +/** + * Obtain the personality function attached to the function. + * + * @see llvm::Function::getPersonalityFn() + */ +LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn); + +/** + * Set the personality function attached to the function. + * + * @see llvm::Function::setPersonalityFn() + */ +void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn); + /** * Obtain the ID number from a function instance. * diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index 23e923d4112..e0e729d534b 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -1691,6 +1691,14 @@ void LLVMDeleteFunction(LLVMValueRef Fn) { unwrap(Fn)->eraseFromParent(); } +LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn) { + return wrap(unwrap(Fn)->getPersonalityFn()); +} + +void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn) { + unwrap(Fn)->setPersonalityFn(unwrap(PersonalityFn)); +} + unsigned LLVMGetIntrinsicID(LLVMValueRef Fn) { if (Function *F = dyn_cast(unwrap(Fn))) return F->getIntrinsicID(); -- 2.34.1