Getting FunctionDecl argument name as string

Hi guys,

In a FunctionDecl with body, I want to get all the argument names and types.

I am able to get these on console by printing to llvm::errs() as following

llvm::errs() << f->getParamDecl(i)->getOriginalType().getAsString() << “\n”;
llvm::errs() << *f->getParamDecl(i)<< “\n”;

The first one is a string. However, I can not get the string for argument name. Though, I am able to successfully print it using llvm::errs().

Can someone please help me with it? If I can write it to some file stream, that would also work.

I looked at ParmVarDecl but I didn’t find anything useful to achieve it.

Have you had a look at ParmVarDecl’s base classes? I think that getName() from NamedDecl does what you want.