[llvm-commits] [llvm] r74714 - in /llvm/trunk: include/llvm/Function.h lib/VMCore/Function.cpp
Owen Anderson
resistor at mac.com
Thu Jul 2 11:04:09 PDT 2009
Author: resistor
Date: Thu Jul 2 13:03:58 2009
New Revision: 74714
URL: http://llvm.org/viewvc/llvm-project?rev=74714&view=rev
Log:
Add an accessor to Function so that Passes can easily get access to the context.
Modified:
llvm/trunk/include/llvm/Function.h
llvm/trunk/lib/VMCore/Function.cpp
Modified: llvm/trunk/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=74714&r1=74713&r2=74714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Thu Jul 2 13:03:58 2009
@@ -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 @@
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;
Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=74714&r1=74713&r2=74714&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Thu Jul 2 13:03:58 2009
@@ -114,6 +114,12 @@
// 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());
}
More information about the llvm-commits
mailing list