Index: include/llvm/IR/Argument.h =================================================================== --- include/llvm/IR/Argument.h +++ include/llvm/IR/Argument.h @@ -121,6 +121,13 @@ /// \brief Add a Attribute to an argument. void addAttr(AttributeSet AS); + /// \brief Return the attribute object for the given attribute kind. + Attribute getAttr(StringRef Kind) const; + + /// \brief Return true if this argument has the attribute of the + /// specified kind. + bool hasAttr(StringRef Kind) const; + /// \brief Remove a Attribute from an argument. void removeAttr(AttributeSet AS); Index: include/llvm/IR/Function.h =================================================================== --- include/llvm/IR/Function.h +++ include/llvm/IR/Function.h @@ -274,6 +274,16 @@ return AttributeSets.getDereferenceableOrNullBytes(i); } + /// \brief Return the attribute object that exists at the given index. + Attribute getAttribute(unsigned i, StringRef Kind) const { + return AttributeSets.getAttribute(i, Kind); + } + + /// \brief Return true if attribute exists at the given index. + bool hasAttribute(unsigned i, StringRef Kind) const { + return AttributeSets.hasAttribute(i, Kind); + } + /// @brief Determine if the function does not access memory. bool doesNotAccessMemory() const { return AttributeSets.hasAttribute(AttributeSet::FunctionIndex, Index: lib/IR/Function.cpp =================================================================== --- lib/IR/Function.cpp +++ lib/IR/Function.cpp @@ -198,6 +198,14 @@ getArgNo() + 1, B)); } +Attribute Argument::getAttr(StringRef Kind) const { + return getParent()->getAttribute(getArgNo()+1, Kind); +} + +bool Argument::hasAttr(StringRef Kind) const { + return getParent()->hasAttribute(getArgNo()+1, Kind); +} + /// removeAttr - Remove attributes from an argument. void Argument::removeAttr(AttributeSet AS) { assert(AS.getNumSlots() <= 1 &&