From c416795feaaa2052f7b46fa7a3f9b6ec3751b1eb Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 14 Oct 2012 07:35:59 +0000 Subject: Remove the bitwise assignment OR operator from the Attributes class. Replace it with the equivalent from the builder class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165895 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Attributes.cpp | 11 +++++------ lib/VMCore/Core.cpp | 8 +++++--- lib/VMCore/Function.cpp | 2 +- lib/VMCore/Instructions.cpp | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'lib/VMCore') diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index 0f24f97f83..635ad1409f 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -96,10 +96,6 @@ bool Attributes::isEmptyOrSingleton() const { Attributes Attributes::operator & (const Attributes &A) const { return Attributes(Raw() & A.Raw()); } -Attributes &Attributes::operator |= (const Attributes &A) { - Attrs.Bits |= A.Raw(); - return *this; -} Attributes &Attributes::operator &= (const Attributes &A) { Attrs.Bits &= A.Raw(); return *this; @@ -504,7 +500,8 @@ Attributes &AttrListPtr::getAttributesAtIndex(unsigned i) const { return AttrList->Attrs[i].Attrs; } -AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const { +AttrListPtr AttrListPtr::addAttr(LLVMContext &C, unsigned Idx, + Attributes Attrs) const { Attributes OldAttrs = getAttributes(Idx); #ifndef NDEBUG // FIXME it is not obvious how this should work for alignment. @@ -532,7 +529,9 @@ AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const { // If there are attributes already at this index, merge them in. if (i != e && OldAttrList[i].Index == Idx) { - Attrs |= OldAttrList[i].Attrs; + Attrs = + Attributes::get(C, Attributes::Builder(Attrs). + addAttributes(OldAttrList[i].Attrs)); ++i; } diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index bafdfa3079..c6da24be93 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -1381,7 +1381,8 @@ void LLVMSetGC(LLVMValueRef Fn, const char *GC) { void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { Function *Func = unwrap(Fn); const AttrListPtr PAL = Func->getAttributes(); - const AttrListPtr PALnew = PAL.addAttr(~0U, Attributes(PA)); + const AttrListPtr PALnew = PAL.addAttr(Func->getContext(), ~0U, + Attributes(PA)); Func->setAttributes(PALnew); } @@ -1667,7 +1668,7 @@ void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute PA) { CallSite Call = CallSite(unwrap(Instr)); Call.setAttributes( - Call.getAttributes().addAttr(index, Attributes(PA))); + Call.getAttributes().addAttr(Call->getContext(), index, Attributes(PA))); } void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, @@ -1682,7 +1683,8 @@ void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, CallSite Call = CallSite(unwrap(Instr)); Attributes::Builder B; B.addAlignmentAttr(align); - Call.setAttributes(Call.getAttributes().addAttr(index, Attributes::get(B))); + Call.setAttributes(Call.getAttributes().addAttr(Call->getContext(), index, + Attributes::get(B))); } /*--.. Operations on call instructions (only) ..............................--*/ diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 15e9f7cfdc..cbf1037f17 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -249,7 +249,7 @@ void Function::dropAllReferences() { void Function::addAttribute(unsigned i, Attributes attr) { AttrListPtr PAL = getAttributes(); - PAL = PAL.addAttr(i, attr); + PAL = PAL.addAttr(getContext(), i, attr); setAttributes(PAL); } diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 15bc3ae1bc..e807edc512 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -332,7 +332,7 @@ CallInst::CallInst(const CallInst &CI) void CallInst::addAttribute(unsigned i, Attributes attr) { AttrListPtr PAL = getAttributes(); - PAL = PAL.addAttr(i, attr); + PAL = PAL.addAttr(getContext(), i, attr); setAttributes(PAL); } @@ -588,7 +588,7 @@ bool InvokeInst::paramHasAttr(unsigned i, Attributes::AttrVal A) const { void InvokeInst::addAttribute(unsigned i, Attributes attr) { AttrListPtr PAL = getAttributes(); - PAL = PAL.addAttr(i, attr); + PAL = PAL.addAttr(getContext(), i, attr); setAttributes(PAL); } -- cgit v1.2.3