I have implemented an AST visitor using Clang. With this piece of code and I can retrieve the function call name correclty.
virtual bool VisitFunctionDecl(FunctionDecl *func)
{
numFunctions++;
string funcName = func->getNameInfo().getName().getAsString();
string funcType = func->getType().getAsString();
APIs << funcType << endl;
APIs << "\n" << funcName <<": ";
return true;
}
I want to extract also the function declaration type. for example int my_func(int a, int b){..} I want to extract the type int. The way its implemented it returns me the whole function declaration except the name. The above piece of code in funcType will return int (int a, int b)
How can I fix this?? Thank you!
It sounds like you're trying to find the return type, not the declared type of the function. Use getReturnType()
for this.