Skip to content

Commit

Permalink
Add capability to get and set the personalitty function from the C API
Browse files Browse the repository at this point in the history
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
  • Loading branch information
axw committed Jul 14, 2015
1 parent ce0f2ed commit 7c492a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/llvm-c/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
8 changes: 8 additions & 0 deletions lib/IR/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,14 @@ void LLVMDeleteFunction(LLVMValueRef Fn) {
unwrap<Function>(Fn)->eraseFromParent();
}

LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn) {
return wrap(unwrap<Function>(Fn)->getPersonalityFn());
}

void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn) {
unwrap<Function>(Fn)->setPersonalityFn(unwrap<Constant>(PersonalityFn));
}

unsigned LLVMGetIntrinsicID(LLVMValueRef Fn) {
if (Function *F = dyn_cast<Function>(unwrap(Fn)))
return F->getIntrinsicID();
Expand Down

0 comments on commit 7c492a1

Please sign in to comment.