diff options
author | Reid Kleckner <rnk@google.com> | 2017-04-13 23:12:13 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-04-13 23:12:13 +0000 |
commit | f021fab2afdc3d9534dbddcccecf892986b9654b (patch) | |
tree | cd67c5baeda9bf396894c99f325324a735cbf066 /llvm/lib/IR/Function.cpp | |
parent | 9a016602e9246c5e76e7b8443ba968f35e7b0b88 (diff) | |
download | bcm5719-llvm-f021fab2afdc3d9534dbddcccecf892986b9654b.tar.gz bcm5719-llvm-f021fab2afdc3d9534dbddcccecf892986b9654b.zip |
[IR] Make getParamAttributes take argument numbers, not ArgNo+1
Add hasParamAttribute() and use it instead of hasAttribute(ArgNo+1,
Kind) everywhere.
The fact that the AttributeList index for an argument is ArgNo+1 should
be a hidden implementation detail.
NFC
llvm-svn: 300272
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 3953a6e1352..c4bb9e83acd 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -49,8 +49,7 @@ void Argument::setParent(Function *parent) { bool Argument::hasNonNullAttr() const { if (!getType()->isPointerTy()) return false; - if (getParent()->getAttributes(). - hasAttribute(getArgNo()+1, Attribute::NonNull)) + if (getParent()->hasParamAttribute(getArgNo(), Attribute::NonNull)) return true; else if (getDereferenceableBytes() > 0 && getType()->getPointerAddressSpace() == 0) @@ -64,13 +63,11 @@ bool Argument::hasByValAttr() const { } bool Argument::hasSwiftSelfAttr() const { - return getParent()->getAttributes(). - hasAttribute(getArgNo()+1, Attribute::SwiftSelf); + return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftSelf); } bool Argument::hasSwiftErrorAttr() const { - return getParent()->getAttributes(). - hasAttribute(getArgNo()+1, Attribute::SwiftError); + return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftError); } bool Argument::hasInAllocaAttr() const { @@ -81,8 +78,8 @@ bool Argument::hasInAllocaAttr() const { bool Argument::hasByValOrInAllocaAttr() const { if (!getType()->isPointerTy()) return false; AttributeList Attrs = getParent()->getAttributes(); - return Attrs.hasAttribute(getArgNo() + 1, Attribute::ByVal) || - Attrs.hasAttribute(getArgNo() + 1, Attribute::InAlloca); + return Attrs.hasParamAttribute(getArgNo(), Attribute::ByVal) || + Attrs.hasParamAttribute(getArgNo(), Attribute::InAlloca); } unsigned Argument::getParamAlignment() const { @@ -136,10 +133,9 @@ bool Argument::hasSExtAttr() const { } bool Argument::onlyReadsMemory() const { - return getParent()->getAttributes(). - hasAttribute(getArgNo()+1, Attribute::ReadOnly) || - getParent()->getAttributes(). - hasAttribute(getArgNo()+1, Attribute::ReadNone); + AttributeList Attrs = getParent()->getAttributes(); + return Attrs.hasParamAttribute(getArgNo(), Attribute::ReadOnly) || + Attrs.hasParamAttribute(getArgNo(), Attribute::ReadNone); } void Argument::addAttr(AttributeList AS) { @@ -161,7 +157,7 @@ void Argument::removeAttr(AttributeList AS) { } bool Argument::hasAttribute(Attribute::AttrKind Kind) const { - return getParent()->hasAttribute(getArgNo() + 1, Kind); + return getParent()->hasParamAttribute(getArgNo(), Kind); } //===----------------------------------------------------------------------===// |