如何让 clang 转储没有颜色的 AST? [英] How do I get clang to dump the AST without color?
问题描述
使用 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
这篇关于如何让 clang 转储没有颜色的 AST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!