I need to write a Python program that parses C source code files and adds a hidden parameter at the end of each function declaration.
More precisely, I need to change something like this:
void f(int a, int b, int c) { ... }
into something like this:
void f(int a, int b, int c, int hiddenArg) { ... }
Obviously, I am going to need to edit all the calls to this function from other functions, too.
I need to do this using pycparser
, but I can not figure out the proper way to edit an AST once I have read it. Is there a proper way to do this that I am missing (or any way whatsoever)?