Skip to content

Commit

Permalink
add some casts to support a change in the getOrInsertFunction interface
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32984 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Jan 7, 2007
1 parent 52a457c commit 6a98754
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions examples/Fibonacci/fibonacci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ using namespace llvm;
static Function *CreateFibFunction(Module *M) {
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
Function *FibF = M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
(Type *)0);
Function *FibF =
cast<Function>(M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
(Type *)0));

// Add a basic block to the function.
BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
Expand Down
8 changes: 5 additions & 3 deletions examples/HowToUseJIT/HowToUseJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ int main() {
// Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int".
// The '0' terminates the list of argument types.
Function *Add1F = M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
(Type *)0);
Function *Add1F =
cast<Function>(M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
(Type *)0));

// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
Expand All @@ -78,7 +79,8 @@ int main() {

// Now we going to create function `foo', which returns an int and takes no
// arguments.
Function *FooF = M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0);
Function *FooF =
cast<Function>(M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0));

// Add a basic block to the FooF function.
BB = new BasicBlock("EntryBlock", FooF);
Expand Down
16 changes: 8 additions & 8 deletions examples/ParallelJIT/ParallelJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
#include <iostream>
using namespace llvm;

static Function* createAdd1(Module* M)
{
static Function* createAdd1(Module *M) {
// Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int".
// The '0' terminates the list of argument types.
Function *Add1F = M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
(Type *)0);
Function *Add1F =
cast<Function>(M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
(Type *)0));

// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
Expand All @@ -59,12 +59,12 @@ static Function* createAdd1(Module* M)
return Add1F;
}

static Function *CreateFibFunction(Module *M)
{
static Function *CreateFibFunction(Module *M) {
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
Function *FibF = M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
(Type *)0);
Function *FibF =
cast<Function>(M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
(Type *)0));

// Add a basic block to the function.
BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
Expand Down

0 comments on commit 6a98754

Please sign in to comment.