#ifndef LLVM_FUNCTION_H
#define LLVM_FUNCTION_H
-#include "llvm/GlobalValue.h"
-#include "llvm/CallingConv.h"
-#include "llvm/BasicBlock.h"
#include "llvm/Argument.h"
#include "llvm/Attributes.h"
+#include "llvm/BasicBlock.h"
+#include "llvm/CallingConv.h"
+#include "llvm/GlobalValue.h"
#include "llvm/Support/Compiler.h"
namespace llvm {
BasicBlockListType BasicBlocks; ///< The basic blocks
mutable ArgumentListType ArgumentList; ///< The formal arguments
ValueSymbolTable *SymTab; ///< Symbol table of args/instructions
- AttrListPtr AttributeList; ///< Parameter attributes
+ AttributeSet AttributeList; ///< Parameter attributes
// HasLazyArguments is stored in Value::SubclassData.
/*bool HasLazyArguments;*/
-
+
// The Calling Convention is stored in Value::SubclassData.
/*CallingConv::ID CallingConvention;*/
Type *getReturnType() const; // Return the type of the ret val
FunctionType *getFunctionType() const; // Return the FunctionType for me
- /// getContext - Return a pointer to the LLVMContext associated with this
+ /// getContext - Return a pointer to the LLVMContext associated with this
/// function, or NULL if this function is not bound to a context yet.
LLVMContext &getContext() const;
setValueSubclassData((getSubclassDataFromValue() & 1) |
(static_cast<unsigned>(CC) << 1));
}
-
+
/// getAttributes - Return the attribute list for this Function.
///
- const AttrListPtr &getAttributes() const { return AttributeList; }
+ const AttributeSet &getAttributes() const { return AttributeList; }
/// setAttributes - Set the attribute list for this Function.
///
- void setAttributes(const AttrListPtr &attrs) { AttributeList = attrs; }
+ void setAttributes(const AttributeSet &attrs) { AttributeList = attrs; }
/// getFnAttributes - Return the function attributes for querying.
///
/// addFnAttr - Add function attributes to this function.
///
- void addFnAttr(Attributes::AttrVal N) {
- // Function Attributes are stored at ~0 index
- Attributes::Builder B;
- B.addAttribute(N);
- addAttribute(~0U, Attributes::get(B));
+ void addFnAttr(Attributes::AttrVal N) {
+ // Function Attributes are stored at ~0 index
+ addAttribute(AttributeSet::FunctionIndex, Attributes::get(getContext(), N));
}
/// removeFnAttr - Remove function attributes from this function.
///
void removeFnAttr(Attributes N) {
- // Function Attributes are stored at ~0 index
+ // Function Attributes are stored at ~0 index
removeAttribute(~0U, N);
}
/// addAttribute - adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attributes attr);
-
+
/// removeAttribute - removes the attribute from the list of attributes.
void removeAttribute(unsigned i, Attributes attr);
return hasUWTable() || !doesNotThrow();
}
- /// @brief Determine if the function returns a structure through first
+ /// @brief Determine if the function returns a structure through first
/// pointer argument.
bool hasStructRetAttr() const {
return getParamAttributes(1).hasAttribute(Attributes::StructRet);
return getParamAttributes(n).hasAttribute(Attributes::NoAlias);
}
void setDoesNotAlias(unsigned n) {
- Attributes::Builder B;
- B.addAttribute(Attributes::NoAlias);
- addAttribute(n, Attributes::get(B));
+ addAttribute(n, Attributes::get(getContext(), Attributes::NoAlias));
}
/// @brief Determine if the parameter can be captured.
return getParamAttributes(n).hasAttribute(Attributes::NoCapture);
}
void setDoesNotCapture(unsigned n) {
- Attributes::Builder B;
- B.addAttribute(Attributes::NoCapture);
- addAttribute(n, Attributes::get(B));
+ addAttribute(n, Attributes::get(getContext(), Attributes::NoCapture));
}
/// copyAttributesFrom - copy all additional attributes (those not needed to