Writing Module Pass to modify arguments of a function

Hi everyone,

I’m struggling on a module pass, my goal is to change the number of arguments of a function found in the IR( the first function found).

My approach is using a modulepass ,creating a function with exactly one argument then cloning the first found function using CloneFunctionInto; then i replace uses of the old function using Old_func->replaceAllUsesWith(new_Func).

I have the end code figured however, I’m stuck at the beginning of the loop :

"for (Module::iterator F = M.begin(), e = M.end(); F != e; ++F) {

Function *Func=M.getAtIndex(F);"

Now the problem is there is no such function as getAtIndex, so how do i know the function i’m currently at so i can use it in the Old_func variable?

If any of you can point me in the right direction, any help is greatly appreciated, thank you!