Remove another use of AttributeWithIndex, using the AttributeSetImpl accessors instead.
authorBill Wendling <isanbard@gmail.com>
Mon, 28 Jan 2013 00:46:02 +0000 (00:46 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 28 Jan 2013 00:46:02 +0000 (00:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173642 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Attributes.cpp

index 59d3ef03dd83d2da5d2752edd684f601cfaf9c50..c41fb318db20d4d1c439bc6c044b04b1c89ed04b 100644 (file)
@@ -752,10 +752,11 @@ Attribute AttributeSet::getAttributes(unsigned Idx) const {
 bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
   if (pImpl == 0) return false;
 
-  ArrayRef<AttributeWithIndex> Attrs = pImpl->getAttributes();
-  for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
-    if (Attrs[i].Attrs.hasAttribute(Attr))
-      return true;
+  for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I)
+    for (AttributeSetImpl::iterator II = pImpl->begin(I),
+           IE = pImpl->end(I); II != IE; ++II)
+      if (II->hasAttribute(Attr))
+        return true;
 
   return false;
 }
@@ -788,11 +789,12 @@ AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
     return *this;
 
   SmallVector<AttributeWithIndex, 8> NewAttrList;
-  if (pImpl == 0)
+  if (pImpl == 0) {
     NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
-  else {
+  else {
     ArrayRef<AttributeWithIndex> OldAttrList = pImpl->getAttributes();
     unsigned i = 0, e = OldAttrList.size();
+
     // Copy attributes for arguments before this one.
     for (; i != e && OldAttrList[i].Index < Idx; ++i)
       NewAttrList.push_back(OldAttrList[i]);