1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

Add an accessor to Function so that Passes can easily get access to the context.

llvm-svn: 74714
This commit is contained in:
Owen Anderson 2009-07-02 18:03:58 +00:00
parent 45b575e63c
commit 5c79283f31
2 changed files with 11 additions and 0 deletions

View File

@ -27,6 +27,7 @@
namespace llvm {
class FunctionType;
class LLVMContext;
// Traits for intrusive list of basic blocks...
template<> struct ilist_traits<BasicBlock>
@ -126,6 +127,10 @@ public:
const Type *getReturnType() const; // Return the type of the ret val
const FunctionType *getFunctionType() const; // Return the FunctionType for me
/// 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();
/// isVarArg - Return true if this function takes a variable number of
/// arguments.
bool isVarArg() const;

View File

@ -114,6 +114,12 @@ void Argument::removeAttr(Attributes attr) {
// Helper Methods in Function
//===----------------------------------------------------------------------===//
LLVMContext* Function::getContext() {
Module* M = getParent();
if (M) return &M->getContext();
return 0;
}
const FunctionType *Function::getFunctionType() const {
return cast<FunctionType>(getType()->getElementType());
}