aboutsummaryrefslogtreecommitdiff
path: root/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-13 08:42:21 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-13 08:42:21 +0000
commit0e9d5d059c4aa959e9ef4dff011dbd38d45a1016 (patch)
tree6285ed6170465ecafbd34e65f5a0b075b7dea5a3 /lib/IR/Attributes.cpp
parent80806961035807d1b9566cdd34233c1b4cf49282 (diff)
Add some accessor and query methods for retrieving Attribute objects and such.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175046 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Attributes.cpp')
-rw-r--r--lib/IR/Attributes.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 8249be4574..7d0bec2b11 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -441,6 +441,30 @@ bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const {
return false;
}
+bool AttributeSetNode::hasAttribute(StringRef Kind) const {
+ for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
+ E = AttrList.end(); I != E; ++I)
+ if (I->hasAttribute(Kind))
+ return true;
+ return false;
+}
+
+Attribute AttributeSetNode::getAttribute(Attribute::AttrKind Kind) const {
+ for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
+ E = AttrList.end(); I != E; ++I)
+ if (I->hasAttribute(Kind))
+ return *I;
+ return Attribute();
+}
+
+Attribute AttributeSetNode::getAttribute(StringRef Kind) const {
+ for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
+ E = AttrList.end(); I != E; ++I)
+ if (I->hasAttribute(Kind))
+ return *I;
+ return Attribute();
+}
+
unsigned AttributeSetNode::getAlignment() const {
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I)
@@ -760,6 +784,11 @@ bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
return ASN ? ASN->hasAttribute(Kind) : false;
}
+bool AttributeSet::hasAttribute(unsigned Index, StringRef Kind) const {
+ AttributeSetNode *ASN = getAttributes(Index);
+ return ASN ? ASN->hasAttribute(Kind) : false;
+}
+
bool AttributeSet::hasAttributes(unsigned Index) const {
AttributeSetNode *ASN = getAttributes(Index);
return ASN ? ASN->hasAttributes() : false;
@@ -779,6 +808,18 @@ bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
return false;
}
+Attribute AttributeSet::getAttribute(unsigned Index,
+ Attribute::AttrKind Kind) const {
+ AttributeSetNode *ASN = getAttributes(Index);
+ return ASN ? ASN->getAttribute(Kind) : Attribute();
+}
+
+Attribute AttributeSet::getAttribute(unsigned Index,
+ StringRef Kind) const {
+ AttributeSetNode *ASN = getAttributes(Index);
+ return ASN ? ASN->getAttribute(Kind) : Attribute();
+}
+
unsigned AttributeSet::getParamAlignment(unsigned Index) const {
AttributeSetNode *ASN = getAttributes(Index);
return ASN ? ASN->getAlignment() : 0;