Best strategy to add a parameter to a function

I am trying to build a function (C++ Builder) and at the same time extend its parameter set. Here's what I try to do:

Value* arg0 = add_param_float("arg0");
Value* tmp = builder->CreateFAdd(arg0,some_previous_value);
Value* arg1 = add_param_float("arg1");

The function add_param_float should add a 'float' parameter to the function and return its value. Right now it's implemented like this

Value* add_param_float() {
     return new llvm::Argument( llvm::Type::getFloatTy(llvm::getGlobalContext()) , param_next() , mainFunc );

where param_next just figures some new, unused name for the argument and mainFunc is the function being built.

This works to a certain extent. I am seeing issues with certain type printers and I assume the way the argument is added to the function is not a strictly valid thing to do.
I guess one cannot change the function type once it's created. (Then maybe the constructor of Argument should not be public).

However, in my setup I need to add new arguments to the function. What would be the best way to do it?

I was thinking of implementing a new function like CloneFunction which takes an additional argument that can be added to it. But, is this really necessary? Isn't there a simpler, more straight-forward way to do this?

Any help/thoughts is appreciated!

Hi Frank,

I regularly run into problems similar to yours. The only way I got around them was always to create a new function with the desired type, specify the mapping of the arguments, and use CloneFunctionInto.
Everything but efficient, but at least works reliably.