C++ 是否可以使用Clang AST打印具有名称的QualType函数指针?

C++ 是否可以使用Clang AST打印具有名称的QualType函数指针?,c++,clang,function-pointers,clang++,llvm-clang,C++,Clang,Function Pointers,Clang++,Llvm Clang,是否有任何简单可靠的方法(即不是regex)将函数指针声明的QualType作为字符串,但附加名称?我尝试利用QualType::getAsString(constprintingpolicy&Policy),但不幸的是,这种配置没有选项 e、 g int(*)(void)--int(*此处的任何名称)(void)您可以创建并打印它 假设ctx是您的,而type是您的QualType,您可以执行以下操作: // Create identifier. IdentifierInfo id = ctx

是否有任何简单可靠的方法(即不是regex)将函数指针声明的
QualType
作为字符串,但附加名称?我尝试利用
QualType::getAsString(constprintingpolicy&Policy)
,但不幸的是,这种配置没有选项

e、 g

int(*)(void)
--int(*此处的任何名称)(void)

您可以创建并打印它

假设
ctx
是您的,而
type
是您的
QualType
,您可以执行以下操作:

// Create identifier.
IdentifierInfo id = ctx.Idents.get("whatever_name_here");
// Create variable declaration.
VarDecl *vd = VarDecl::Create(ctx, ctx.getTranslationUnitDecl(), 
    SourceLocation(), SourceLocation(), &id, type, nullptr, StorageClass:SC_None);
// Print it.
vd->print(/* put your llvm::raw_stream here */, ctx.getPrintingPolicy());
您是否研究过可以提供的参数?(特别是完全合格的名称成员)