Hi All,

I am writing to find out if there is any method of obtaining or
constructing a function parameter list string as it would have been
defined in the source code?

For example for the function:
int Function(std::string v1, std::string v2) {return F(v1, v2);}

I would like to obtain a string that looks like:
"std::string v1, std::string v2"

OR:
"std::string, std::string"


I am currently doing something like this using DECL_ARGUMENTS(fndecl)
and then for each of the arguments in the list (skipping the "this" arg
for member functions and the occasional in_charge_identifier or
vtt_parm_identifier args) I obtain a string representation of the type
and use this to construct the function parameter string.

Anyhow, there are a number of "special" cases that i need to handle
using this method, such as DECL_ARGUMENTS returning a NULL_TREE or the
... parameter type etc. With all this i still do not quite get the
results i need.


What i find is that often the resulting parameter string is not exactly
or even functionally the same as what is specified in the source code.
For example some functions that receive a std::string parameter by value
are modified by the compiler for optimization reasons to pass the
parameter in by reference instead, and this shows up in the resulting
parameter string i construct.

So for the example before i would sometimes find that the string contains:
"std::string&, std::string&"


What i need to achieve:

BEST OPTION:
I need to get a string exactly the same as defined in the source code.
It is fine for this to include parameter names and default argument
values if that is how it has to be.

SECOND BEST OPTION:
Otherwise i need to at least obtain names for the types as they were
specified. I.e. without the optimizations applied or this parameter
added or typedefs substituted etc.


Is this possible? And if so where is the best place to look?

By the way i am using the source for GCC 4.0.1 in case that makes a
difference.

Thanks,
Brendon.


Reply via email to