使用clang API打印参数类型(ParmVarDecl) [英] Print the type of a parameter (ParmVarDecl) with clang API
本文介绍了使用clang API打印参数类型(ParmVarDecl)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用clang API在C ++源文件中打印参数的类型.
I need to print the type of a parameter in a C++ source file using the clang API.
如果我有一个用clang(ParmVarDecl* param
)表示的参数,则可以使用param->getNameAsString()
打印该参数的名称.我需要一种方法 param->getTypeAsString()
,但是没有这种方法.那么还有另一种方法可以完成此任务吗?
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?
推荐答案
在llvm irc中找到我的问题的答案:
Got the answer to my question in the llvm irc:
有一种方法std::string clang::QualType::getAsString(SplitQualType split)
这确实对我有用:
ParmVarDecl* param = *someParameter;
cout << QualType::getAsString(param->getType().split()) << endl;
这篇关于使用clang API打印参数类型(ParmVarDecl)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文