I am working on a large C/C++ project that's compiled using Microsoft Visual Studio Compiler cl.exe. I am having a compilation database for that project. This is just a file containing a list of commands that one needs to run in order to compile each source code file. Each command has the name of the compiler, the file which is to be compiled, and a set of compiler flags determining various aspects of the compilation.
I want to run the whole entire project through a custom clang-based tool. In order to do that, I would just pass the compilation database JSON file into that tool. But there's one issue here. The compilation database file uses the cl.exe compiler in the command. Now cl.exe and clang.exe have different compiler flags. For instance to disable optimizations cl.exe takes /Od and clang.exe takes -O0. So a compilation command that's written for cl.exe will not work when given to clang.exe.
So as a solution I am creating a python script to parse that JSON file and convert the MSVC compiler flags into the corresponding Clang compiler flags. As I am parsing the command line flags, I am indexing them into a dictionary where the key is the string of the MSVC compiler flag, and the data is the Clang compiler flag, for quickly replacing them.
Now my question is:
How do I know which MSVC compiler flags correspond to which Clang compiler flags? Where do I actually get the data to fill in this dictionary from? I am looking for a table listing the MSVC compiler flags and their corresponding Clang compiler flags. Or if such a table doesn't exist yet I want the answerer to provide such a table in the answer to the question.
Assume that I cannot use clang-cl for this project. The reason why is that the recipient of that compilation database are the applications Doxygen and SourceTrail, which use a compilation database to construct an AST from which they generate documentation about the code. As far as I know they don't support clang-cl, just regular clang compiler, but if you do know how to make them work with clang-cl then I will accept that answer.