对于带有 Clang 和 Codegen 的 MSVC 2015,如何让 -ast-dump 工作?

For MSVC 2015 with Clang and Codegen, how do I get -ast-dump to work?

我已经为 Visual C++ 2015 安装了 Clang 和 Codegen。我制作了一个新的控制台应用程序,打印出“Hello, world!”并将 Debug x86 和 Release x86 中的 Platform Toolset 设置为:

Clang 3.7 with Microsoft CodeGen (v140_clang_3_7)

我关闭了预编译头,在 C/C++ -> 命令行下,我在 Debug x86 和 Release x86 中添加了一个新命令:

-ast-dump

然后我在调试模式下构建程序。该程序构建成功并给出了预期的结果;但是,clang.exe:

发出警告

1> Source.cpp

1>clang.exe : warning : argument unused during compilation: '-ast-dump'

1> tester5.vcxproj -> c:\users\erika\documents\visual studio 2015\Projects\tester5\Debug\tester5.exe

为什么参数 -ast-dump 在编译过程中没有被使用?我如何从此处获取 Clang 来转储 AST?

您需要使用 -Xclang -ast-dump(以及您喜欢的任何其他选项)