Print AST Dump from clang with runToolOnCode

  abstract-syntax-tree, c++, clang

I need to implement a simple clang tool that prints the AST of a given file as with the command clang -cc1 -ast-dump <filename>.

That is, I need to output to the screen or file a dump for a given file.

I don’t need complex logic or optimization, I just need to display a dump. I have looked at various examples, however it is not entirely clear how to print or save to file.

How can I do that?

Is it possible to do this by calling runToolOnCode?

Source: Windows Questions C++