一个人可以使用clang ast使用名称打印功能指针的质量
Can one print the QualType of function pointers with a name using Clang AST?
是否有任何简单可靠的方式(又称不正表)将函数指针的 QualType
获取为字符串,但是附加了一个名称?我试图考虑利用QualType::getAsString(const PrintingPolicy &Policy)
,但不幸的是,该配置没有选择。
,例如
int (*)(void)
----> int (*whatever_name_here)(void)
您可以创建VarDecl
并打印。
假设ctx
是您的ASTContext
,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());
相关文章:
- 链表删除功能的单指针 // 是可能的
- 对于非常量指针类型的参数,未调用具有常量指针模板类型参数的功能
- char* 除了作为C++中的指针之外,还有其他功能吗?
- 具有小对象优化功能的智能指针
- 如何定义和设置指向模板类方法的功能指针
- 将状态传递给功能指针
- 如何使用指针向量为班级制作复制功能
- 我对C 中共享指针列表进行排序的功能未完成类型
- 如何使用结构内的功能指针调用私有函数
- 如何将自己的智能指针传递到功能
- 模板功能以检查智能指针是否为空
- 如何存储指针以功能模板,该模板将可呼叫对象作为其参数之一
- 功能指针不起作用(C )
- 将C 方法作为功能指针传递
- 字符指针功能以复制C 中的字符串
- 指针?指针功能
- 反向指针功能问题
- 无效指针功能的输出
- 更好地解释C++指针功能
- 用memcpy c 读取并写入指针功能