Search code examples
xcodeclangllvmabstract-syntax-treellvm-clang

Can clang produce an AST dump and a binary in the same run


If I'm trying to do some offline processing of the AST of a project, is there any way for LLVM to produce AST files alongside the object files it produces during a build? As it stands it seems like there would have to be a second run to get the AST, which just seems inefficient given that the AST would be generated as part of the binary build.

Specifically I'm hoping to get xcodebuild to do this, but any pointers would probably help.


Solution

  • This is not possible without changing how the front-end works. In just the same way you can't generate both object files and executables at the same time, you can't produce AST dumps and object files at the same time.

    When you pass commands like -c or -E or -ast-dump, it cuts the compilation pipe-line off at a particular point.