Index: include/llvm-c/Core.h =================================================================== --- include/llvm-c/Core.h +++ include/llvm-c/Core.h @@ -1893,6 +1893,25 @@ void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); /** + * Add an attribute to the return value of a function. + * + * @see llvm::Function::addAttribute() + */ +void LLVMAddFunctionReturnAttr(LLVMValueRef Fn, LLVMAttribute PA); + +/** + * Obtain an attribute from the return value of a function. + * + * @see llvm::Function::getAttributes() + */ +LLVMAttribute LLVMGetFunctionReturnAttr(LLVMValueRef Fn); + +/** + * Remove an attribute from the return value of a function. + */ +void LLVMRemoveFunctionReturnAttr(LLVMValueRef Fn, LLVMAttribute PA); + +/** * @defgroup LLVMCCoreValueFunctionParameters Function Parameters * * Functions in this group relate to arguments/parameters on functions. Index: lib/IR/Core.cpp =================================================================== --- lib/IR/Core.cpp +++ lib/IR/Core.cpp @@ -1600,6 +1600,34 @@ return (LLVMAttribute)PAL.Raw(AttributeSet::FunctionIndex); } +void LLVMAddFunctionReturnAttr(LLVMValueRef Fn, LLVMAttribute PA) { + Function *Func = unwrap(Fn); + const AttributeSet PAL = Func->getAttributes(); + AttrBuilder B(PA); + const AttributeSet PALnew = + PAL.addAttributes(Func->getContext(), AttributeSet::ReturnIndex, + AttributeSet::get(Func->getContext(), + AttributeSet::ReturnIndex, B)); + Func->setAttributes(PALnew); +} + +void LLVMRemoveFunctionReturnAttr(LLVMValueRef Fn, LLVMAttribute PA) { + Function *Func = unwrap(Fn); + const AttributeSet PAL = Func->getAttributes(); + AttrBuilder B(PA); + const AttributeSet PALnew = + PAL.removeAttributes(Func->getContext(), AttributeSet::ReturnIndex, + AttributeSet::get(Func->getContext(), + AttributeSet::ReturnIndex, B)); + Func->setAttributes(PALnew); +} + +LLVMAttribute LLVMGetFunctionReturnAttr(LLVMValueRef Fn) { + Function *Func = unwrap(Fn); + const AttributeSet PAL = Func->getAttributes(); + return (LLVMAttribute)PAL.Raw(AttributeSet::ReturnIndex); +} + /*--.. Operations on parameters ............................................--*/ unsigned LLVMCountParams(LLVMValueRef FnRef) {