[llvm-commits] [llvm] r173644 - Remove another use of AttributeWithIndex, using the AttributeSetImpl accessors instead.

Bill Wendling isanbard at gmail.com
Sun Jan 27 17:11:42 PST 2013


Author: void
Date: Sun Jan 27 19:11:42 2013
New Revision: 173644

URL: http://llvm.org/viewvc/llvm-project?rev=173644&view=rev
Log:
Remove another use of AttributeWithIndex, using the AttributeSetImpl accessors instead.

Modified:
    llvm/trunk/lib/IR/Attributes.cpp

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=173644&r1=173643&r2=173644&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Sun Jan 27 19:11:42 2013
@@ -735,14 +735,22 @@ uint64_t AttributeSet::Raw(unsigned Inde
   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(Attr
   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;





More information about the llvm-commits mailing list