We have a product which targets a large variety of platforms. Compilation for some of those platforms is using MSVC rather than clang.
We are using the clang libtooling interface where we provide a compile_commands.json file to indicate how to compile each translation unit. How does clang use the provided compile_commands.json information? Does it use all the flags, but run it through its own compiler? Is it possible to use libtooling with a compile_commands.json having instructions on MSVC compilation? Our compile_commands.json for each platform is created by our internal build system, similarly to how cmake would generate it.
Does it use all the flags, but run it through its own compiler?
Yes, it runs lexical and syntax analysis just as if you execute clang
with all these flags directly.
Is it possible to use libtooling with a compile_commands.json having instructions on MSVS compilation?
Clang can mimic MSVC cl.exe
when being run as clang-cl.exe
or passed --driver-mode=cl
flag. So, if your command line contain cl.exe
style flags (like /MD
and /Z7
), theoretically it should be possible to use libtooling too.