Using clang-cl with -emit-ast

How to call clang-cl with -emit-ast command-line argument? I tried -Xclang -emit-ast and got “unknown argument: -emit-ast”

Hi Daniel,

I’m using clang on Windows to generate an AST from header files for some driver research I’m doing for my Ph.D. I found setting environment flags to be a pain. What would be necessary to expose this flag from clang-cl?

If you just want to look at the AST, you can use -Xclang -ast-dump.

If you really need -emit-ast from clang-cl, the way to expose it would
be add Flags<[CoreOption]> to emit_ast in
include/clang/Driver/Options.td, and check that it works. If it does,
you can send a patch for it :slight_smile:

- Hans

I sent another email about the -ast-dump, but basically the Python clang bindings aren’t able to read it from disk after it’s been saved.

Details in this stackoverflow question:
https://stackoverflow.com/questions/34162906/parsing-ast-generated-by-clang-with-clang-python-bindings

I will get started with implementing exposing the flag. Hopefully I’ll have a patch in the next few days :slight_smile: