如何以JSON格式表示clang AST? [英] How to represent clang AST in JSON format?
本文介绍了如何以JSON格式表示clang AST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
clang-check -ast-dump -ast-dump-filter=<function_name> main.c
给出特定代码的AST(仅函数声明).
clang-check -ast-dump -ast-dump-filter=<function_name> main.c
gives a AST (only a function declaration) of the particular code.
我们如何以JSON格式表示生成的AST?
How can we represent generated AST in JSON format?
PS:我只希望AST用于函数声明.
PS: I Want AST for function declaration only.
推荐答案
使用-ast-dump=json
参数调用clang
.
这是最近才实施的(2019年5月),因此您需要Clang的最新版本.
This was implemented only recently (May 2019) so you need an up-to-date version of Clang.
有关详细信息,请参见 https://reviews.llvm.org/D60910 .
See https://reviews.llvm.org/D60910 for details.
在 https://处也有一个库,可通过libTooling导出更多较低级别的信息. github.com/facebook/facebook-clang-plugins
这篇关于如何以JSON格式表示clang AST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文