Using clang::tooling::RefactoringTool on cross-compiled code with different /usr/include


I've been working on a project that involves writing clang refactoring and analysis tools and we had similar problems. It's possible to ignore the compilation database and pass arguments directly to the clang front end like this:

   your-tool <tool arguments> -- -std=c++14 -DDEBUG -I/home/someone/include -I/some/other/directory

Everything after the -- is used by the clang front end when it's parsing your source files; I think you may be able to use this to solve your problem.

When you use -- I think it ignores the compilation database and just uses whatever you supply on the command line. We've found this to be considerably more convenient than using compilation databases. Unfortunately this feature doesn't seem to be very well publicised: I think we only discovered it by looking at the Clang sources...

Best wishes,

Kenneth MacKenzie