From 2c189061184925c6a8ecbb5a19e648b230a41c0e Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 26 Sep 2012 21:48:26 +0000 Subject: Remove the `hasFnAttr' method from Function. The hasFnAttr method has been replaced by querying the Attributes explicitly. No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164725 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Function.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'include/llvm/Function.h') diff --git a/include/llvm/Function.h b/include/llvm/Function.h index fbd2594a45..6d3ee03fea 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -168,10 +168,10 @@ public: /// void setAttributes(const AttrListPtr &attrs) { AttributeList = attrs; } - /// hasFnAttr - Return true if this function has the given attribute. - bool hasFnAttr(Attributes N) const { - // Function Attributes are stored at ~0 index - return AttributeList.paramHasAttr(~0U, N); + /// getFnAttributes - Return the function attributes for querying. + /// + Attributes getFnAttributes() const { + return AttributeList.getFnAttributes(); } /// addFnAttr - Add function attributes to this function. @@ -195,6 +195,11 @@ public: void setGC(const char *Str); void clearGC(); + /// getParamAttributes - Return the parameter attributes for querying. + Attributes getParamAttributes(unsigned Idx) const { + return AttributeList.getParamAttributes(Idx); + } + /// @brief Determine whether the function has the given attribute. bool paramHasAttr(unsigned i, Attributes attr) const { return AttributeList.paramHasAttr(i, attr); @@ -213,7 +218,7 @@ public: /// @brief Determine if the function does not access memory. bool doesNotAccessMemory() const { - return hasFnAttr(Attribute::ReadNone); + return getFnAttributes().hasReadNoneAttr(); } void setDoesNotAccessMemory(bool DoesNotAccessMemory = true) { if (DoesNotAccessMemory) addFnAttr(Attribute::ReadNone); @@ -222,7 +227,7 @@ public: /// @brief Determine if the function does not access or only reads memory. bool onlyReadsMemory() const { - return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly); + return doesNotAccessMemory() || getFnAttributes().hasReadOnlyAttr(); } void setOnlyReadsMemory(bool OnlyReadsMemory = true) { if (OnlyReadsMemory) addFnAttr(Attribute::ReadOnly); @@ -231,7 +236,7 @@ public: /// @brief Determine if the function cannot return. bool doesNotReturn() const { - return hasFnAttr(Attribute::NoReturn); + return getFnAttributes().hasNoReturnAttr(); } void setDoesNotReturn(bool DoesNotReturn = true) { if (DoesNotReturn) addFnAttr(Attribute::NoReturn); @@ -240,7 +245,7 @@ public: /// @brief Determine if the function cannot unwind. bool doesNotThrow() const { - return hasFnAttr(Attribute::NoUnwind); + return getFnAttributes().hasNoUnwindAttr(); } void setDoesNotThrow(bool DoesNotThrow = true) { if (DoesNotThrow) addFnAttr(Attribute::NoUnwind); @@ -250,7 +255,7 @@ public: /// @brief True if the ABI mandates (or the user requested) that this /// function be in a unwind table. bool hasUWTable() const { - return hasFnAttr(Attribute::UWTable); + return getFnAttributes().hasUWTableAttr(); } void setHasUWTable(bool HasUWTable = true) { if (HasUWTable) -- cgit v1.2.3-70-g09d2 From 896f37f0f9fa928987a66dca6d67aec38895091b Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 26 Sep 2012 22:15:19 +0000 Subject: Query the parameter attributes directly instead of using the Attribute symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164727 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Function.h | 6 +++--- lib/VMCore/Function.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'include/llvm/Function.h') diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 6d3ee03fea..907b14f599 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -272,13 +272,13 @@ public: /// @brief Determine if the function returns a structure through first /// pointer argument. bool hasStructRetAttr() const { - return paramHasAttr(1, Attribute::StructRet); + return getParamAttributes(1).hasStructRetAttr(); } /// @brief Determine if the parameter does not alias other parameters. /// @param n The parameter to check. 1 is the first parameter, 0 is the return bool doesNotAlias(unsigned n) const { - return paramHasAttr(n, Attribute::NoAlias); + return getParamAttributes(n).hasNoAliasAttr(); } void setDoesNotAlias(unsigned n, bool DoesNotAlias = true) { if (DoesNotAlias) addAttribute(n, Attribute::NoAlias); @@ -288,7 +288,7 @@ public: /// @brief Determine if the parameter can be captured. /// @param n The parameter to check. 1 is the first parameter, 0 is the return bool doesNotCapture(unsigned n) const { - return paramHasAttr(n, Attribute::NoCapture); + return getParamAttributes(n).hasNoCaptureAttr(); } void setDoesNotCapture(unsigned n, bool DoesNotCapture = true) { if (DoesNotCapture) addAttribute(n, Attribute::NoCapture); diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 2e0b3168c9..012d27603a 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -78,7 +78,7 @@ unsigned Argument::getArgNo() const { /// in its containing function. bool Argument::hasByValAttr() const { if (!getType()->isPointerTy()) return false; - return getParent()->paramHasAttr(getArgNo()+1, Attribute::ByVal); + return getParent()->getParamAttributes(getArgNo()+1).hasByValAttr(); } unsigned Argument::getParamAlignment() const { @@ -91,21 +91,21 @@ unsigned Argument::getParamAlignment() const { /// it in its containing function. bool Argument::hasNestAttr() const { if (!getType()->isPointerTy()) return false; - return getParent()->paramHasAttr(getArgNo()+1, Attribute::Nest); + return getParent()->getParamAttributes(getArgNo()+1).hasNestAttr(); } /// 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()->paramHasAttr(getArgNo()+1, Attribute::NoAlias); + return getParent()->getParamAttributes(getArgNo()+1).hasNoAliasAttr(); } /// 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()->paramHasAttr(getArgNo()+1, Attribute::NoCapture); + return getParent()->getParamAttributes(getArgNo()+1).hasNoCaptureAttr(); } /// hasSRetAttr - Return true if this argument has the sret attribute on @@ -114,7 +114,7 @@ bool Argument::hasStructRetAttr() const { if (!getType()->isPointerTy()) return false; if (this != getParent()->arg_begin()) return false; // StructRet param must be first param - return getParent()->paramHasAttr(1, Attribute::StructRet); + return getParent()->getParamAttributes(1).hasStructRetAttr(); } /// addAttr - Add a Attribute to an argument -- cgit v1.2.3-70-g09d2 From 59e6586ee00ec145be50f9eb2f71ed308fb5e60a Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 26 Sep 2012 23:38:00 +0000 Subject: Buildbot Fix. This method can be called with a '0' argument which checks the return value. However, the method it calls doesn't expect '0' as a valid value. Call the correct method when it's 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164735 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Function.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/llvm/Function.h') diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 907b14f599..fa6d0d3f5b 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -278,7 +278,8 @@ public: /// @brief Determine if the parameter does not alias other parameters. /// @param n The parameter to check. 1 is the first parameter, 0 is the return bool doesNotAlias(unsigned n) const { - return getParamAttributes(n).hasNoAliasAttr(); + return n != 0 ? getParamAttributes(n).hasNoAliasAttr() : + AttributeList.getRetAttributes().hasNoAliasAttr(); } void setDoesNotAlias(unsigned n, bool DoesNotAlias = true) { if (DoesNotAlias) addAttribute(n, Attribute::NoAlias); -- cgit v1.2.3-70-g09d2