summaryrefslogtreecommitdiff
path: root/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-01 00:13:50 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-01 00:13:50 +0000
commit30d2c76800bc821aff6e224e0bd11d88a793303e (patch)
treeba88f05408d8520e88d9833fb7b99444dfc6851f /lib/IR/Attributes.cpp
parentfdd1eafe867734df285bbdb01cf1d21f63716798 (diff)
downloadllvm-30d2c76800bc821aff6e224e0bd11d88a793303e.tar.gz
llvm-30d2c76800bc821aff6e224e0bd11d88a793303e.tar.bz2
llvm-30d2c76800bc821aff6e224e0bd11d88a793303e.tar.xz
Use iterators instead of relying upon a bitmask of attributes to remove attributes from an AttrBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Attributes.cpp')
-rw-r--r--lib/IR/Attributes.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 9d5f53bfdc..01e0235b57 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -749,7 +749,7 @@ AttributeSet::iterator AttributeSet::begin(unsigned Idx) {
AttributeSet::iterator AttributeSet::end(unsigned Idx) {
if (!pImpl)
return ArrayRef<Attribute>().end();
- return pImpl->begin(Idx);
+ return pImpl->end(Idx);
}
//===----------------------------------------------------------------------===//
@@ -852,18 +852,24 @@ AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
}
AttrBuilder &AttrBuilder::removeAttributes(AttributeSet A, uint64_t Index) {
- uint64_t Mask = A.Raw(Index);
+ unsigned Idx = ~0U;
+ for (unsigned I = 0, E = A.getNumSlots(); I != E; ++I)
+ if (A.getSlotIndex(I) == Index) {
+ Idx = I;
+ break;
+ }
- for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
- I = Attribute::AttrKind(I + 1)) {
- if (Mask & AttributeImpl::getAttrMask(I)) {
- Attrs.erase(I);
+ assert(Idx != ~0U && "Couldn't find index in AttributeSet!");
- if (I == Attribute::Alignment)
- Alignment = 0;
- else if (I == Attribute::StackAlignment)
- StackAlignment = 0;
- }
+ for (AttributeSet::iterator I = A.begin(Idx), E = A.end(Idx); I != E; ++I) {
+ ConstantInt *CI = cast<ConstantInt>(I->getAttributeKind());
+ Attribute::AttrKind Kind = Attribute::AttrKind(CI->getZExtValue());
+ Attrs.erase(Kind);
+
+ if (Kind == Attribute::Alignment)
+ Alignment = 0;
+ else if (Kind == Attribute::StackAlignment)
+ StackAlignment = 0;
}
return *this;