On Jan 2, 2009, at 3:47 PM, kapil anand wrote:
> Hi all,
>
> I am having some problem using the Function class. For my
> application, FunctionType is not known at the time I initialize the
> function. So, I just initialize the Function as return type
> void with no arguments. As I work on my function, I get to know the
> arguments and I insert the arguments in ArgumentList data structure
> of the function. The FunctionType is defined as const and I can't
> change that.
>
> When I insert a call to this function, I look at ArgumentList Data
> structure, and determine the number of arguments and pass them with
> the call. But, FunctionType is same as original type( with no
> arguments). The insertion of Call Instruction checks the
> functiontype and gives me an assertion failure that I am calling the
> function with wrong type.
>
> So, is there any way I can modify the functiontype after
> initializing the function?
Nope, all LLVM IR objects have a fixed type on construction. To
change the type of a function, instruction, etc you have to make a new
one.
-Chris