aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/IR/Function.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/IR/Function.h')
-rw-r--r--include/llvm/IR/Function.h56
1 files changed, 30 insertions, 26 deletions
diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h
index 9bdaebac82..568b55c87b 100644
--- a/include/llvm/IR/Function.h
+++ b/include/llvm/IR/Function.h
@@ -85,7 +85,7 @@ private:
BasicBlockListType BasicBlocks; ///< The basic blocks
mutable ArgumentListType ArgumentList; ///< The formal arguments
ValueSymbolTable *SymTab; ///< Symbol table of args/instructions
- AttributeSet AttributeList; ///< Parameter attributes
+ AttributeSet AttributeSets; ///< Parameter attributes
// HasLazyArguments is stored in Value::SubclassData.
/*bool HasLazyArguments;*/
@@ -162,24 +162,25 @@ public:
/// getAttributes - Return the attribute list for this Function.
///
- const AttributeSet &getAttributes() const { return AttributeList; }
+ AttributeSet getAttributes() const { return AttributeSets; }
/// setAttributes - Set the attribute list for this Function.
///
- void setAttributes(const AttributeSet &attrs) { AttributeList = attrs; }
+ void setAttributes(AttributeSet attrs) { AttributeSets = attrs; }
/// addFnAttr - Add function attributes to this function.
///
void addFnAttr(Attribute::AttrKind N) {
- // Function Attribute are stored at ~0 index
- addAttribute(AttributeSet::FunctionIndex, Attribute::get(getContext(), N));
+ setAttributes(AttributeSets.addAttribute(getContext(),
+ AttributeSet::FunctionIndex, N));
}
- /// removeFnAttr - Remove function attributes from this function.
- ///
- void removeFnAttr(Attribute N) {
- // Function Attribute are stored at ~0 index
- removeAttribute(~0U, N);
+ /// \brief Return true if the function has the attribute.
+ bool hasFnAttribute(Attribute::AttrKind Kind) const {
+ return AttributeSets.hasAttribute(AttributeSet::FunctionIndex, Kind);
+ }
+ bool hasFnAttribute(StringRef Kind) const {
+ return AttributeSets.hasAttribute(AttributeSet::FunctionIndex, Kind);
}
/// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm
@@ -189,20 +190,23 @@ public:
void setGC(const char *Str);
void clearGC();
- /// addAttribute - adds the attribute to the list of attributes.
- void addAttribute(unsigned i, Attribute attr);
+ /// @brief adds the attribute to the list of attributes.
+ void addAttribute(unsigned i, Attribute::AttrKind attr);
+
+ /// @brief adds the attributes to the list of attributes.
+ void addAttributes(unsigned i, AttributeSet attrs);
- /// removeAttribute - removes the attribute from the list of attributes.
- void removeAttribute(unsigned i, Attribute attr);
+ /// @brief removes the attributes from the list of attributes.
+ void removeAttributes(unsigned i, AttributeSet attr);
/// @brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
- return AttributeList.getParamAlignment(i);
+ return AttributeSets.getParamAlignment(i);
}
/// @brief Determine if the function does not access memory.
bool doesNotAccessMemory() const {
- return AttributeList.hasAttribute(AttributeSet::FunctionIndex,
+ return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
Attribute::ReadNone);
}
void setDoesNotAccessMemory() {
@@ -212,7 +216,7 @@ public:
/// @brief Determine if the function does not access or only reads memory.
bool onlyReadsMemory() const {
return doesNotAccessMemory() ||
- AttributeList.hasAttribute(AttributeSet::FunctionIndex,
+ AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
Attribute::ReadOnly);
}
void setOnlyReadsMemory() {
@@ -221,7 +225,7 @@ public:
/// @brief Determine if the function cannot return.
bool doesNotReturn() const {
- return AttributeList.hasAttribute(AttributeSet::FunctionIndex,
+ return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
Attribute::NoReturn);
}
void setDoesNotReturn() {
@@ -230,7 +234,7 @@ public:
/// @brief Determine if the function cannot unwind.
bool doesNotThrow() const {
- return AttributeList.hasAttribute(AttributeSet::FunctionIndex,
+ return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
Attribute::NoUnwind);
}
void setDoesNotThrow() {
@@ -239,7 +243,7 @@ public:
/// @brief Determine if the call cannot be duplicated.
bool cannotDuplicate() const {
- return AttributeList.hasAttribute(AttributeSet::FunctionIndex,
+ return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
Attribute::NoDuplicate);
}
void setCannotDuplicate() {
@@ -249,7 +253,7 @@ public:
/// @brief True if the ABI mandates (or the user requested) that this
/// function be in a unwind table.
bool hasUWTable() const {
- return AttributeList.hasAttribute(AttributeSet::FunctionIndex,
+ return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
Attribute::UWTable);
}
void setHasUWTable() {
@@ -264,25 +268,25 @@ public:
/// @brief Determine if the function returns a structure through first
/// pointer argument.
bool hasStructRetAttr() const {
- return AttributeList.hasAttribute(1, Attribute::StructRet);
+ return AttributeSets.hasAttribute(1, Attribute::StructRet);
}
/// @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 AttributeList.hasAttribute(n, Attribute::NoAlias);
+ return AttributeSets.hasAttribute(n, Attribute::NoAlias);
}
void setDoesNotAlias(unsigned n) {
- addAttribute(n, Attribute::get(getContext(), Attribute::NoAlias));
+ addAttribute(n, Attribute::NoAlias);
}
/// @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 AttributeList.hasAttribute(n, Attribute::NoCapture);
+ return AttributeSets.hasAttribute(n, Attribute::NoCapture);
}
void setDoesNotCapture(unsigned n) {
- addAttribute(n, Attribute::get(getContext(), Attribute::NoCapture));
+ addAttribute(n, Attribute::NoCapture);
}
/// copyAttributesFrom - copy all additional attributes (those not needed to