0

我们有一个针对各种平台的产品。其中一些平台的编译使用 MSVC 而不是 clang。

我们使用 clang libtooling 接口,我们提供了一个 compile_commands.json 文件来指示如何编译每个翻译单元。clang 如何使用提供的 compile_commands.json 信息?它是否使用所有标志,但通过自己的编译器运行它?是否可以将 libtooling 与具有 MSVC 编译说明的 compile_commands.json 一起使用?每个平台的 compile_commands.json 是由我们的内部构建系统创建的,类似于 cmake 生成它的方式。

4

1 回答 1

2

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.

于 2019-12-18T05:24:25.677 回答