I would like to make a LibTooling tool that takes precisely the same compilation string as clang. For example
clang a.c -O3 b.c -I/myinclude -DMY_DEFINE c.c
. Should be replaced by my-tool a.c -O3 b.c -I/myinclude -DMY_DEFINE c.c
Officially suggested by clang documentation way to parse arguments in LibTooling-based tools is CommonOptionsParser. It expects a different format of command-line string and by default relies on the compile_commands.json file. I can simulate desired behavior if I put all source files before --
and everything else after it, like this: my-tool a.c b.c c.c -- -O3 -I/myinclude -DMY_DEFINE
. Is it possible to implement this without such hacking of parameter string using llvm/clang API?