[cfe-users] source code for parameter declaration?

Markus Grabner grabner at icg.tugraz.at
Fri Dec 28 01:02:02 PST 2012


	Hi!

    I'm trying to parse C function declarations with the clang API and found 
that the type and identifier names of a parameter (given by an instance "x" of 
class clang::ParmVarDecl) can be obtained by x.getType().getAsString() and 
x.getName(), respectively. In many cases, simply concatenating these two 
strings gives valid C code corresponding to the parameter represented by "x". 
However, this obviously doesn't work for function pointers (e.g., "void 
(*function)(int)", where "void (*)(int)" is the type name and "function" is 
the identifier name).

So my question is: is it possible, given an instance of class 
clang::ParmVarDecl, to obtain the corresponding source code of that parameter 
(i.e., code which would produce exactly the same clang::ParmVarDecl instance)?

	Thanks & kind regards,
		Markus




More information about the cfe-users mailing list