From 16c4b3cf2943ae2327752cf3de39769d14cfcece Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 31 Jan 2013 23:53:05 +0000 Subject: [PATCH] Add iterators to the AttributeSet class so that we can access the Attributes in a nice way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174120 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Attributes.h | 5 +++++ lib/IR/Attributes.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 508277c1306..49ef884b702 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -270,6 +270,11 @@ public: /// \brief Return the attributes at the index as a string. std::string getAsString(unsigned Index) const; + typedef ArrayRef::iterator iterator; + + iterator begin(unsigned Idx); + iterator end(unsigned Idx); + /// operator==/!= - Provide equality predicates. bool operator==(const AttributeSet &RHS) const { return pImpl == RHS.pImpl; diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 14aba080abe..9d5f53bfdcd 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -740,6 +740,18 @@ AttributeSetNode *AttributeSet::getAttributes(unsigned Idx) const { return 0; } +AttributeSet::iterator AttributeSet::begin(unsigned Idx) { + if (!pImpl) + return ArrayRef().begin(); + return pImpl->begin(Idx); +} + +AttributeSet::iterator AttributeSet::end(unsigned Idx) { + if (!pImpl) + return ArrayRef().end(); + return pImpl->begin(Idx); +} + //===----------------------------------------------------------------------===// // AttributeSet Introspection Methods //===----------------------------------------------------------------------===//