I have posted the question below on the cfe-user mailing list, but didn’t get any reply. So I posting it here in hope of any help:
I am able to dump Clang AST for a single .c or .cpp file with following command in Windows command prompt:
clang -cc1 -ast-dump -I path_to_MinWG_inlcude source_file.c > clang_ast_file.txt
My question is whether it is possible to extract Clang ASTs for all source files for all projects in a Visual Studio solution without transforming each project into makefile based build?
Thank you for any help in advance.
P.S.: If this is the wrong place to ask this question, please point me to the correct place. Thank you.
It is possible to write a Visual Studio plugin that uses the project/solution information to figure out the set of compile commands to build the project. At that point you could pass that information to clang and write the output to a file, stdout, etc.
Thank you for your reply. I think ClangVSx project (https://github.com/ishani/ClangVSx) does exactly what you wrote.
I was just curious if you know if it is possible to substitute a wrapper around clang as c compiler in VS somehow?
Such approach works for me with makefile build setup. For example, this works:
Where clang_wrapper.bat first runs clang with -ast-dump option and redirects it to a text file, and then runs clang normally to compile source code.
You can download a Windows build of clang from http://llvm.org/builds/. This will give you the option in Visual Studio of selecting LLVM/Clang as the tool chain. Since this is something along the lines of a plugin it likely doesn’t work for the Express version of visual studio, but it will work for the Professional and higher versions.