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

查看:424
本文介绍了如何查看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天全站免登陆