diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-01-28 01:11:42 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-01-28 01:11:42 +0000 |
commit | e2501f56a620be88665d04dc481f40ef3275eea0 (patch) | |
tree | 1e4f86bdec59d781e5a54f150ba7c054d7d9d7c7 /lib/IR | |
parent | 70cdaaae925862b9d52d41729e93cf6417c3370b (diff) | |
download | external_llvm-e2501f56a620be88665d04dc481f40ef3275eea0.zip external_llvm-e2501f56a620be88665d04dc481f40ef3275eea0.tar.gz external_llvm-e2501f56a620be88665d04dc481f40ef3275eea0.tar.bz2 |
Remove another use of AttributeWithIndex, using the AttributeSetImpl accessors instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173644 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/Attributes.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index c41fb318..6745486 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -735,14 +735,22 @@ uint64_t AttributeSet::Raw(unsigned Index) const { return pImpl ? pImpl->Raw(Index) : 0; } -/// getAttributes - The attributes for the specified index are returned. +/// \brief The attributes for the specified index are returned. +/// +/// FIXME: This shouldn't return 'Attribute'. Attribute AttributeSet::getAttributes(unsigned Idx) const { if (pImpl == 0) return Attribute(); - ArrayRef<AttributeWithIndex> Attrs = pImpl->getAttributes(); - for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i) - if (Attrs[i].Index == Idx) - return Attrs[i].Attrs; + // Loop through to find the attribute we want. + for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I) { + if (pImpl->getSlotIndex(I) != Idx) continue; + + AttrBuilder B; + for (AttributeSetImpl::const_iterator II = pImpl->begin(I), + IE = pImpl->end(I); II != IE; ++II) + B.addAttributes(*II); + return Attribute::get(pImpl->getContext(), B); + } return Attribute(); } @@ -753,7 +761,7 @@ bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const { if (pImpl == 0) return false; for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I) - for (AttributeSetImpl::iterator II = pImpl->begin(I), + for (AttributeSetImpl::const_iterator II = pImpl->begin(I), IE = pImpl->end(I); II != IE; ++II) if (II->hasAttribute(Attr)) return true; |