summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index a0eec5f0d2f..427efbba4f8 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -89,16 +89,14 @@ bool Argument::hasNonNullAttr() const {
/// in its containing function.
bool Argument::hasByValAttr() const {
if (!getType()->isPointerTy()) return false;
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::ByVal);
+ return hasAttribute(Attribute::ByVal);
}
/// \brief Return true if this argument has the inalloca attribute on it in
/// its containing function.
bool Argument::hasInAllocaAttr() const {
if (!getType()->isPointerTy()) return false;
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::InAlloca);
+ return hasAttribute(Attribute::InAlloca);
}
bool Argument::hasByValOrInAllocaAttr() const {
@@ -130,53 +128,46 @@ uint64_t Argument::getDereferenceableOrNullBytes() const {
/// it in its containing function.
bool Argument::hasNestAttr() const {
if (!getType()->isPointerTy()) return false;
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::Nest);
+ return hasAttribute(Attribute::Nest);
}
/// hasNoAliasAttr - Return true if this argument has the noalias attribute on
/// it in its containing function.
bool Argument::hasNoAliasAttr() const {
if (!getType()->isPointerTy()) return false;
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::NoAlias);
+ return hasAttribute(Attribute::NoAlias);
}
/// hasNoCaptureAttr - Return true if this argument has the nocapture attribute
/// on it in its containing function.
bool Argument::hasNoCaptureAttr() const {
if (!getType()->isPointerTy()) return false;
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::NoCapture);
+ return hasAttribute(Attribute::NoCapture);
}
/// hasSRetAttr - Return true if this argument has the sret attribute on
/// it in its containing function.
bool Argument::hasStructRetAttr() const {
if (!getType()->isPointerTy()) return false;
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::StructRet);
+ return hasAttribute(Attribute::StructRet);
}
/// hasReturnedAttr - Return true if this argument has the returned attribute on
/// it in its containing function.
bool Argument::hasReturnedAttr() const {
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::Returned);
+ return hasAttribute(Attribute::Returned);
}
/// hasZExtAttr - Return true if this argument has the zext attribute on it in
/// its containing function.
bool Argument::hasZExtAttr() const {
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::ZExt);
+ return hasAttribute(Attribute::ZExt);
}
/// hasSExtAttr Return true if this argument has the sext attribute on it in its
/// containing function.
bool Argument::hasSExtAttr() const {
- return getParent()->getAttributes().
- hasAttribute(getArgNo()+1, Attribute::SExt);
+ return hasAttribute(Attribute::SExt);
}
/// Return true if this argument has the readonly or readnone attribute on it
@@ -208,6 +199,11 @@ void Argument::removeAttr(AttributeSet AS) {
getArgNo() + 1, B));
}
+/// hasAttribute - Checks if an argument has a given attribute.
+bool Argument::hasAttribute(Attribute::AttrKind Kind) const {
+ return getParent()->hasAttribute(getArgNo() + 1, Kind);
+}
+
//===----------------------------------------------------------------------===//
// Helper Methods in Function
//===----------------------------------------------------------------------===//
@@ -349,6 +345,12 @@ void Function::addAttributes(unsigned i, AttributeSet attrs) {
setAttributes(PAL);
}
+void Function::removeAttribute(unsigned i, Attribute::AttrKind attr) {
+ AttributeSet PAL = getAttributes();
+ PAL = PAL.removeAttribute(getContext(), i, attr);
+ setAttributes(PAL);
+}
+
void Function::removeAttributes(unsigned i, AttributeSet attrs) {
AttributeSet PAL = getAttributes();
PAL = PAL.removeAttributes(getContext(), i, attrs);
OpenPOWER on IntegriCloud