Source to Source

Dear all,

I’m new to the mailing list.

I’m trying to find the file format description of the AST files generated with

clang -emit-ast …

Could you give me any pointer? Thanks

What do you want to “do” with the file generated? In general, I would have thought the tools provided by Clang would be more suitable than trying to parse the output from clang with this option - it’s more of a tool to debug the compiler than something intended to use for further processing. Clang already comes with several sets of tools for reformatting, modifying/matching code patterns, etc.

I’m also copying the reply to “cfe-dev” that is the mailing list for Clang and related tools, rather than the llvm-dev, which is the mailing list for the LLVM part of the clang+llvm set of tools/products.

I would like to manipulate the AST from a C++ source code from a Java application. As far as I know there are no good and open source methods to get a detailed AST from C++ in Java.

May it be that clang (as it happens in gcc) try to discourage people to work with the AST outside llvm tools because of uninteded license use fears?

I would like to manipulate the AST from a C++ source code from a Java
application. As far as I know there are no good and open source methods to
get a detailed AST from C++ in Java.

May it be that clang (as it happens in gcc) try to discourage people to
work with the AST outside llvm tools because of uninteded license use fears?

Not at all. For instance, we provide language bindings for AST traversal to
C and Python. If there were sufficient interest in Java bindings (including
patches to add the support in the first place, sufficient maintainers with
a solid track record, an interested user community, ...) it would not be
unreasonable to ship the bindings with Clang alongside the Python bindings.
The only reason we don't have these bindings is that, to date, there has
not been that level of interest.