An alternative approach would be to compile with "-g" and read the debug information.
This answer may help you read the debug information and figure out function parameters (it's Python, not bash, but I'd recommend using Python or Perl instead of bash anyway).
The resulting solution would be much more robust than anything based on text parsing. It will deal with all the different ways in which a function might be defined, and even with crazy things like functions defined in macros.
To convince you better (or help you get it right if you're not convinced), here's a list of test cases that may break your parsing:
// Many lines
const
char
*
f
(
int
x
)
{
}
// Count parenthesis!
void f(void (*f)(void *f)) {}
// Old style
void f(a, b)
int a;
char *b
{
}
// Not a function
int f=sizeof(int);
// Nesting
int f() {
int g() { return 1; }
return g();
}
// Just one
void f(int x /*, int y */) { }
// what if?
void (int x
#ifdef ALSO_Y
, int y
#endif
) { }
// A function called __attribute__?
static int __attribute__((always_inline)) f(int x) {}