Add iterators to the AttributeSet class so that we can access the Attributes in a...
authorBill Wendling <isanbard@gmail.com>
Thu, 31 Jan 2013 23:53:05 +0000 (23:53 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 31 Jan 2013 23:53:05 +0000 (23:53 +0000)
llvm-svn: 174120

llvm/include/llvm/IR/Attributes.h
llvm/lib/IR/Attributes.cpp

index 508277c..49ef884 100644 (file)
@@ -270,6 +270,11 @@ public:
   /// \brief Return the attributes at the index as a string.
   std::string getAsString(unsigned Index) const;
 
+  typedef ArrayRef<Attribute>::iterator iterator;
+
+  iterator begin(unsigned Idx);
+  iterator end(unsigned Idx);
+
   /// operator==/!= - Provide equality predicates.
   bool operator==(const AttributeSet &RHS) const {
     return pImpl == RHS.pImpl;
index 14aba08..9d5f53b 100644 (file)
@@ -740,6 +740,18 @@ AttributeSetNode *AttributeSet::getAttributes(unsigned Idx) const {
   return 0;
 }
 
+AttributeSet::iterator AttributeSet::begin(unsigned Idx) {
+  if (!pImpl)
+    return ArrayRef<Attribute>().begin();
+  return pImpl->begin(Idx);
+}
+
+AttributeSet::iterator AttributeSet::end(unsigned Idx) {
+  if (!pImpl)
+    return ArrayRef<Attribute>().end();
+  return pImpl->begin(Idx);
+}
+
 //===----------------------------------------------------------------------===//
 // AttributeSet Introspection Methods
 //===----------------------------------------------------------------------===//