如何克隆或创建CAST的AST Stmt节点? [英] How to clone or create an AST Stmt node of clang?

查看:76
本文介绍了如何克隆或创建CAST的AST Stmt节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过clang LibTooling修改AST.如何克隆AST节点或添加新节点,例如我想用ADD操作码创建一个BinaryOperator

I want to modify the AST by clang LibTooling. How can I clone an AST node or add a new one, e.g. I'd like to create a BinaryOperator with ADD opcode

推荐答案

在Clang中创建新的AST节点非常繁琐,因此不建议使用libTooling.相反,您应该读取" AST并发出代码或代码更改(重写,替换等).

Creating new AST nodes is quite cumbersome in Clang, and it's not the recommended way to use libTooling. Rather, you should "read" the AST and emit back code, or code changes (rewritings, replacements, etc).

请参见此文章和与之链接的其他文章(和代码示例),以获取有关正确方法的更多信息.

See this article and other articles (and code samples) linked from it for more information on the right way to do this.

这篇关于如何克隆或创建CAST的AST Stmt节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆