I need to print the type of a parameter in a C++ source file using the clang API.
If I have a parameter representation in clang (ParmVarDecl* param
) I can print the name of the parameter using param->getNameAsString()
. I would need a method param->getTypeAsString()
, but there is no such method. So is there another way to do this task?
Got the answer to my question in the llvm irc:
There is a method std::string clang::QualType::getAsString(SplitQualType split)
So this does work for me:
ParmVarDecl* param = *someParameter;
cout << QualType::getAsString(param->getType().split()) << endl;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With