From 03eefb3a3887a706efeffc8752057ae1a6b76c71 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 29 Jan 2013 20:45:34 +0000 Subject: [PATCH] Add a couple of accessor methods to get the kind and values of an attribute. llvm-svn: 173828 --- llvm/include/llvm/IR/Attributes.h | 7 +++++++ llvm/lib/IR/Attributes.cpp | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h index 1578789df605..5ebb6296cd61 100644 --- a/llvm/include/llvm/IR/Attributes.h +++ b/llvm/include/llvm/IR/Attributes.h @@ -28,6 +28,7 @@ class AttrBuilder; class AttributeImpl; class AttributeSetImpl; class AttributeSetNode; +class Constant; class LLVMContext; class Type; @@ -130,6 +131,12 @@ public: /// \brief Return true if attributes exist bool hasAttributes() const; + /// \brief Return the kind of this attribute. + Constant *getAttributeKind() const; + + /// \brief Return the value (if present) of the non-target-specific attribute. + ArrayRef getAttributeValues() const; + /// \brief Returns the alignment field of an attribute as a byte alignment /// value. unsigned getAlignment() const; diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index a3f62ae07648..1a971109c22b 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -83,6 +83,14 @@ bool Attribute::hasAttributes() const { return pImpl && pImpl->hasAttributes(); } +Constant *Attribute::getAttributeKind() const { + return pImpl ? pImpl->getAttributeKind() : 0; +} + +ArrayRef Attribute::getAttributeValues() const { + return pImpl ? pImpl->getAttributeValues() : ArrayRef(); +} + /// This returns the alignment field of an attribute as a byte alignment value. unsigned Attribute::getAlignment() const { if (!hasAttribute(Attribute::Alignment)) -- 2.34.1