[PATCH] D60910: [WIP] Dumping the AST to JSON
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 19 11:52:43 PDT 2019
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, riccibruno, steveire, dblaikie.
Herald added a subscriber: mgorny.
This is a work in progress patch that adds the ability to specify an AST dump format on the command line. By default, we continue to dump the AST with its usual tree view, but users can now optionally pass `-ast-dump=json` to dump to a machine-readable JSON format that makes it easier for third parties to consume the Clang AST in some fashion.
The patch can currently handle dumping a fair amount of declaration information, some statements, and very few expressions. I got it to the point where it was showing useful output in roughly the correct format, but I wanted to get community feedback for continuing the implementation. Once the current approach gains consensus, my plan is to commit the WIP and then do subsequent commits with post-commit review to finish the implementation (unless the changes are somehow interesting enough to warrant pre-commit review, of course).
The hybrid approach of using some LLVM JSON functionality and some streaming functionality is purposeful for performance reasons (collecting the entire AST into memory in a second form means ~2x the memory usage for the AST, which can be prohibitive for large compilation units). Testing this functionality with FileCheck is quite verbose, so if someone has suggestions for a better way to test the JSON output, I'd be happy to consider it.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 67935 bytes
Desc: not available
More information about the cfe-commits