diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-01-23 00:45:55 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-01-23 00:45:55 +0000 |
commit | 8246df61f6de716acf1f8c64fac3c19970a2c174 (patch) | |
tree | eea5feb78eb13d53687b1211b304c2388ef2f63c /lib/IR | |
parent | 4d79724e130e69e3ce6327680460f399c18cb7eb (diff) | |
download | external_llvm-8246df61f6de716acf1f8c64fac3c19970a2c174.zip external_llvm-8246df61f6de716acf1f8c64fac3c19970a2c174.tar.gz external_llvm-8246df61f6de716acf1f8c64fac3c19970a2c174.tar.bz2 |
Use the AttributeSet when removing multiple attributes. Use Attribute::AttrKind
when removing one attribute. This further encapsulates the use of the attributes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173214 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/Attributes.cpp | 10 | ||||
-rw-r--r-- | lib/IR/Core.cpp | 12 | ||||
-rw-r--r-- | lib/IR/Function.cpp | 9 | ||||
-rw-r--r-- | lib/IR/Instructions.cpp | 14 |
4 files changed, 33 insertions, 12 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index c67b1f3..a3abd36 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -730,6 +730,16 @@ AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx, return get(C, NewAttrList); } +AttributeSet AttributeSet::removeAttribute(LLVMContext &C, unsigned Idx, + Attribute::AttrKind Attr) const { + return removeAttr(C, Idx, Attribute::get(C, Attr)); +} + +AttributeSet AttributeSet::removeAttributes(LLVMContext &C, unsigned Idx, + AttributeSet Attrs) const { + return removeAttr(C, Idx, Attrs.getAttributes(Idx)); +} + AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx, Attribute Attrs) const { #ifndef NDEBUG diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index e72eb69..0e42536 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -1394,8 +1394,9 @@ void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { const AttributeSet PAL = Func->getAttributes(); AttrBuilder B(PA); const AttributeSet PALnew = - PAL.removeAttr(Func->getContext(), AttributeSet::FunctionIndex, - Attribute::get(Func->getContext(), B)); + PAL.removeAttributes(Func->getContext(), AttributeSet::FunctionIndex, + AttributeSet::get(Func->getContext(), + AttributeSet::FunctionIndex, B)); Func->setAttributes(PALnew); } @@ -1686,9 +1687,10 @@ void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute PA) { CallSite Call = CallSite(unwrap<Instruction>(Instr)); AttrBuilder B(PA); - Call.setAttributes( - Call.getAttributes().removeAttr(Call->getContext(), index, - Attribute::get(Call->getContext(), B))); + Call.setAttributes(Call.getAttributes() + .removeAttributes(Call->getContext(), index, + AttributeSet::get(Call->getContext(), + index, B))); } void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index 4d047f6..f2f3ec9 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -133,7 +133,10 @@ void Argument::addAttr(Attribute attr) { /// removeAttr - Remove a Attribute from an argument void Argument::removeAttr(Attribute attr) { - getParent()->removeAttribute(getArgNo() + 1, attr); + AttrBuilder B(attr); + getParent()->removeAttributes(getArgNo() + 1, + AttributeSet::get(getParent()->getContext(), + getArgNo() + 1, B)); } @@ -263,9 +266,9 @@ void Function::addAttributes(unsigned i, AttributeSet attrs) { setAttributes(PAL); } -void Function::removeAttribute(unsigned i, Attribute attrs) { +void Function::removeAttributes(unsigned i, AttributeSet attrs) { AttributeSet PAL = getAttributes(); - PAL = PAL.removeAttr(getContext(), i, attrs); + PAL = PAL.removeAttributes(getContext(), i, attrs); setAttributes(PAL); } diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index 8597d5c..8a0a465 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -334,14 +334,18 @@ CallInst::CallInst(const CallInst &CI) void CallInst::addAttribute(unsigned i, Attribute attr) { AttributeSet PAL = getAttributes(); AttrBuilder B(attr); - PAL = PAL.addAttributes(getContext(), i, - AttributeSet::get(getContext(), i, B)); + LLVMContext &Context = getContext(); + PAL = PAL.addAttributes(Context, i, + AttributeSet::get(Context, i, B)); setAttributes(PAL); } void CallInst::removeAttribute(unsigned i, Attribute attr) { AttributeSet PAL = getAttributes(); - PAL = PAL.removeAttr(getContext(), i, attr); + AttrBuilder B(attr); + LLVMContext &Context = getContext(); + PAL = PAL.removeAttributes(Context, i, + AttributeSet::get(Context, i, B)); setAttributes(PAL); } @@ -599,7 +603,9 @@ void InvokeInst::addAttribute(unsigned i, Attribute attr) { void InvokeInst::removeAttribute(unsigned i, Attribute attr) { AttributeSet PAL = getAttributes(); - PAL = PAL.removeAttr(getContext(), i, attr); + AttrBuilder B(attr); + PAL = PAL.removeAttributes(getContext(), i, + AttributeSet::get(getContext(), i, B)); setAttributes(PAL); } |