Add a parameter to FunctionDecl

Hi,
   I am using clang to create and parse an AST. I have a function in an
ASTVisitor called "VisitFunctionDecl" which gives me a functiondecl object.
I need to add a new parameter to this declaration in source code e.g.

int foo()
{

}

  should be converted to

int foo(int a)
{
}

   I need to find the location just before the ending bracket. Is there any
way to do that? Also, can I ensure that the new parameter being added
doesn't conflict with some variable in the function?

Regards,
Adil

Hi,
   I am using clang to create and parse an AST. I have a function in an
ASTVisitor called "VisitFunctionDecl" which gives me a functiondecl object.
I need to add a new parameter to this declaration in source code e.g.

int foo()
{

}

  should be converted to

int foo(int a)
{
}

   I need to find the location just before the ending bracket. Is there any
way to do that?

Get a FunctionTypeLoc out of the decl; that stores the relevant locations.

Also, can I ensure that the new parameter being added
doesn't conflict with some variable in the function?

You can use a RecursiveASTVisitor or something like that to visit all
the declarations in the function.

-Eli

Hi,
There is no function to get FunctionTypeLoc from a FunctionDecl. Is there any other way to get a FunctionTypeLoc?

Regards,
Adil

You get a TypeSourceInfo from the FunctionDecl, get a TypeLoc from the
TypeSourceInfo, then convert that to a FunctionTypeLoc.

-Eli