Mapping Clang C code AST to Code

Hi,

I have been trying without much success figuring a way to map the -ast-view from Clang cc1 option to code, and --ast-dump-XML as well. Is this possible? If so, how?

Please let me know if this is the wrong list to post this..

Best Regards,

Neither of these is directly possible. The AST-printing facilities do not print well-formed code, and the XML dumps are both incomplete and not necessarily well structured for anything other than debugging the compiler. That's why both options are hidden behind the compiler's internal -cc1 interface.

What are you actually trying to accomplish?

  - Doug

I am interested on seeing this sort of information on the tree. Do you believe it would be hard to implement this given what information the other parts that already exist get the tree? I could contribute to it. Few pointers where to look into the source would be very appreciated.

Specifically I want to see code lines and the values of operators etc.

Best,

I am interested on seeing this sort of information on the tree. Do you believe it would be hard to implement this given what information the other parts that already exist get the tree? I could contribute to it. Few pointers where to look into the source would be very appreciated.

Specifically I want to see code lines and the values of operators etc.

All of the information is in the tree. It’s simply the Decl and Stmt printers that are not complete. Both live in the AST library.

  • Doug