summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-10-15 07:29:08 +0000
committerBill Wendling <isanbard@gmail.com>2012-10-15 07:29:08 +0000
commit07aae2e7d58fe23e370e0cbb9e1a3def99434c36 (patch)
tree9961bc6b914ce55768f0ea5d168fb892894ca9db /include
parentad4643f54ba52d1f93426a9853934df8ce3271a0 (diff)
downloadllvm-07aae2e7d58fe23e370e0cbb9e1a3def99434c36.tar.gz
llvm-07aae2e7d58fe23e370e0cbb9e1a3def99434c36.tar.bz2
llvm-07aae2e7d58fe23e370e0cbb9e1a3def99434c36.tar.xz
Add an enum for the return and function indexes into the AttrListPtr object. This gets rid of some magic numbers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165924 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Attributes.h10
-rw-r--r--include/llvm/Instructions.h22
2 files changed, 19 insertions, 13 deletions
diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h
index d0833c3b3f..03ee520440 100644
--- a/include/llvm/Attributes.h
+++ b/include/llvm/Attributes.h
@@ -330,6 +330,12 @@ class AttributeListImpl;
/// AttrListPtr - This class manages the ref count for the opaque
/// AttributeListImpl object and provides accessors for it.
class AttrListPtr {
+public:
+ enum AttrIndex {
+ ReturnIndex = 0U,
+ FunctionIndex = ~0U
+ };
+private:
/// AttrList - The attributes that we are managing. This can be null
/// to represent the empty attributes list.
AttributeListImpl *AttrList;
@@ -368,12 +374,12 @@ public:
/// getRetAttributes - The attributes for the ret value are
/// returned.
Attributes getRetAttributes() const {
- return getAttributes(0);
+ return getAttributes(ReturnIndex);
}
/// getFnAttributes - The function attributes are returned.
Attributes getFnAttributes() const {
- return getAttributes(~0U);
+ return getAttributes(FunctionIndex);
}
/// paramHasAttr - Return true if the specified parameter index has the
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 7b68aef874..dba852fc84 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -1274,7 +1274,7 @@ public:
void setIsNoInline() {
Attributes::Builder B;
B.addAttribute(Attributes::NoInline);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Return true if the call can return twice
@@ -1284,7 +1284,7 @@ public:
void setCanReturnTwice() {
Attributes::Builder B;
B.addAttribute(Attributes::ReturnsTwice);
- addAttribute(~0U, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call does not access memory.
@@ -1294,7 +1294,7 @@ public:
void setDoesNotAccessMemory() {
Attributes::Builder B;
B.addAttribute(Attributes::ReadNone);
- addAttribute(~0U, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call does not access or only reads memory.
@@ -1304,7 +1304,7 @@ public:
void setOnlyReadsMemory() {
Attributes::Builder B;
B.addAttribute(Attributes::ReadOnly);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call cannot return.
@@ -1312,7 +1312,7 @@ public:
void setDoesNotReturn() {
Attributes::Builder B;
B.addAttribute(Attributes::NoReturn);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call cannot unwind.
@@ -1320,7 +1320,7 @@ public:
void setDoesNotThrow() {
Attributes::Builder B;
B.addAttribute(Attributes::NoUnwind);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call returns a structure through first
@@ -3029,7 +3029,7 @@ public:
void setIsNoInline() {
Attributes::Builder B;
B.addAttribute(Attributes::NoInline);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call does not access memory.
@@ -3039,7 +3039,7 @@ public:
void setDoesNotAccessMemory() {
Attributes::Builder B;
B.addAttribute(Attributes::ReadNone);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call does not access or only reads memory.
@@ -3049,7 +3049,7 @@ public:
void setOnlyReadsMemory() {
Attributes::Builder B;
B.addAttribute(Attributes::ReadOnly);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call cannot return.
@@ -3057,7 +3057,7 @@ public:
void setDoesNotReturn() {
Attributes::Builder B;
B.addAttribute(Attributes::NoReturn);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call cannot unwind.
@@ -3065,7 +3065,7 @@ public:
void setDoesNotThrow() {
Attributes::Builder B;
B.addAttribute(Attributes::NoUnwind);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call returns a structure through first