如何查看 Clang AST? [英] How to view Clang AST?

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

问题描述

我正试图抓住 Clang.所以,我想在解析给定程序后查看 Clang 生成的 AST.是否可以以 .dot 或 .viz 格式转储 AST?有什么工具吗?

I am trying to get hold on Clang. So, I would like to view the AST generated by Clang after parsing the given program. Is it possible to dump AST in .dot or .viz format? Is there any tool out there?

推荐答案

Clang 支持使用 Graphviz 的 dotty 显示 AST -- 你可以抓取生成的临时 .dot 文件(名称被打印出来)获取图源.

Clang supports showing the AST with Graphviz's dotty -- you can grab the temporary .dot file generated (name is printed out) to get the graph source.

clang -cc1 -ast-view your_file.c

您还可以使用以下命令打印到命令行:

You can also print to the command line with:

clang -cc1 -ast-dump your_file.c

或:

clang -cc1 -ast-print your_file.c

或在 3.3 中:

clang -cc1 -ast-dump-xml your_file.c

但是这个后来被删除,正如 Lukas Kubanek 在评论中指出的那样.

but this was removed later as pointed by Lukas Kubanek in the comment.

这篇关于如何查看 Clang AST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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