如何获得c声转储无颜色的AST? [英] How do I get clang to dump the AST without color?

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

问题描述

使用 clang-check 转储源代码的AST,可以通过以下命令完成:

Using clang-check to dump a source code's AST, can be done with the following command:

$ clang-check -ast-dump file.c --

但是,此命令的输出将在终端中显示为彩色。

当我将输出定向到文件时,我被所有颜色转义代码所困扰:

However, the output of this command will appear colorful within the terminal.
When I direct the output to a file, I'm stuck with all of the color escape codes:

$ clang-check -ast-dump file.c -- > out.txt  

示例:

[0;1;32mTranslationUnitDecl[0m[0;33m 0x227c5c0[0m <[0;33m<invalid sloc>[0m> [0;33m<invalid sloc>[0m
[0;34m|-[0m[0;1;32mTypedefDecl[0m[0;33m 0x227cac0[0m <[0;33m<invalid sloc>[0m> [0;33m<invalid sloc>[0m implicit[0;1;36m __int128_t[0m [0;32m'__int128'[0m
[0;34m|-[0m[0;1;32mTypedefDecl[0m[0;33m 0x227cb20[0m <[0;33m<invalid sloc>[0m> [0;33m<invalid sloc>[0m implicit[0;1;36m __uint128_t[0m [0;32m'unsigned __int128'[0m
[0;34m|-[0m[0;1;32mTypedefDecl[0m[0;33m 0x227ce70[0m <[0;33m<invalid sloc>[0m> [0;33m<invalid sloc>[0m implicit[0;1;36m __builtin_va_list[0m [0;32m'__va_list_tag [1]'[0m
...

在clang-check中是否有禁用颜色的标记?

我尝试添加以下标记,但无效:

Is there a flag to disable colors in clang-check?
I tried adding the following flag, but it did not work:

--extra-arg="--no-color-diagnostics"


推荐答案

您几乎是正确的。尝试

$ clang-check -ast-dump test.c --extra-arg="-fno-color-diagnostics" -- 

此外, -fno-diagnostics-color -fdiagnostics-color = never 似乎也可以工作

Additionally, -fno-diagnostics-color and -fdiagnostics-color=never also seems to work

参考: http://clang.llvm.org/docs/UsersManual.html#formatting-of-diagnostics

这篇关于如何获得c声转储无颜色的AST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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