From 46d5dd9b058f31637f2449b2925f13a5707d126d Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 16 Oct 2012 05:23:31 +0000 Subject: Use the Attributes::get method which takes an AttrVal value directly to simplify the code a bit. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166009 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Function.h | 12 +++------- include/llvm/Instructions.h | 55 ++++++++++++++++++--------------------------- 2 files changed, 25 insertions(+), 42 deletions(-) (limited to 'include') diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 26b148d848..e211e9ab52 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -178,9 +178,7 @@ public: /// void addFnAttr(Attributes::AttrVal N) { // Function Attributes are stored at ~0 index - AttrBuilder B; - B.addAttribute(N); - addAttribute(~0U, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), N)); } /// removeFnAttr - Remove function attributes from this function. @@ -278,9 +276,7 @@ public: return getParamAttributes(n).hasAttribute(Attributes::NoAlias); } void setDoesNotAlias(unsigned n) { - AttrBuilder B; - B.addAttribute(Attributes::NoAlias); - addAttribute(n, Attributes::get(getContext(), B)); + addAttribute(n, Attributes::get(getContext(), Attributes::NoAlias)); } /// @brief Determine if the parameter can be captured. @@ -289,9 +285,7 @@ public: return getParamAttributes(n).hasAttribute(Attributes::NoCapture); } void setDoesNotCapture(unsigned n) { - AttrBuilder B; - B.addAttribute(Attributes::NoCapture); - addAttribute(n, Attributes::get(getContext(), B)); + addAttribute(n, Attributes::get(getContext(), Attributes::NoCapture)); } /// copyAttributesFrom - copy all additional attributes (those not needed to diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 97612b6f85..40dbbaabe6 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1281,9 +1281,8 @@ public: /// @brief Return true if the call should not be inlined. bool isNoInline() const { return hasFnAttr(Attributes::NoInline); } void setIsNoInline() { - AttrBuilder B; - B.addAttribute(Attributes::NoInline); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::NoInline)); } /// @brief Return true if the call can return twice @@ -1291,9 +1290,8 @@ public: return hasFnAttr(Attributes::ReturnsTwice); } void setCanReturnTwice() { - AttrBuilder B; - B.addAttribute(Attributes::ReturnsTwice); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::ReturnsTwice)); } /// @brief Determine if the call does not access memory. @@ -1301,9 +1299,8 @@ public: return hasFnAttr(Attributes::ReadNone); } void setDoesNotAccessMemory() { - AttrBuilder B; - B.addAttribute(Attributes::ReadNone); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::ReadNone)); } /// @brief Determine if the call does not access or only reads memory. @@ -1311,25 +1308,22 @@ public: return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly); } void setOnlyReadsMemory() { - AttrBuilder B; - B.addAttribute(Attributes::ReadOnly); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::ReadOnly)); } /// @brief Determine if the call cannot return. bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); } void setDoesNotReturn() { - AttrBuilder B; - B.addAttribute(Attributes::NoReturn); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::NoReturn)); } /// @brief Determine if the call cannot unwind. bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); } void setDoesNotThrow() { - AttrBuilder B; - B.addAttribute(Attributes::NoUnwind); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::NoUnwind)); } /// @brief Determine if the call returns a structure through first @@ -3036,9 +3030,8 @@ public: /// @brief Return true if the call should not be inlined. bool isNoInline() const { return hasFnAttr(Attributes::NoInline); } void setIsNoInline() { - AttrBuilder B; - B.addAttribute(Attributes::NoInline); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::NoInline)); } /// @brief Determine if the call does not access memory. @@ -3046,9 +3039,8 @@ public: return hasFnAttr(Attributes::ReadNone); } void setDoesNotAccessMemory() { - AttrBuilder B; - B.addAttribute(Attributes::ReadNone); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::ReadNone)); } /// @brief Determine if the call does not access or only reads memory. @@ -3056,25 +3048,22 @@ public: return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly); } void setOnlyReadsMemory() { - AttrBuilder B; - B.addAttribute(Attributes::ReadOnly); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::ReadOnly)); } /// @brief Determine if the call cannot return. bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); } void setDoesNotReturn() { - AttrBuilder B; - B.addAttribute(Attributes::NoReturn); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::NoReturn)); } /// @brief Determine if the call cannot unwind. bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); } void setDoesNotThrow() { - AttrBuilder B; - B.addAttribute(Attributes::NoUnwind); - addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B)); + addAttribute(AttrListPtr::FunctionIndex, + Attributes::get(getContext(), Attributes::NoUnwind)); } /// @brief Determine if the call returns a structure through first -- cgit v1.2.3