Attempting compile after a clang-tidy invocation


I’m writing some tools with clang-tidy using AST matchers.

I’m storing the changes in yamls files. It would be useful to try to compile the result after doing that storage.

I think the way to do that is:

After handleErrors in clangtidy.cpp,

  • Create an in-memory filesystem containing buffers for each of the files changed in the replacements.
  • Create an overlay filesystem combining the real filesystem and my in memory one.
  • Apply the replacements with applyAllReplacements in the normal way.
  • Compile in the normal way with the same args.

I think I can create the virtual filesystem, but I’m not sure how to create the compiler invocation with the correct args. Do I need to go back to the compiledb and filter out the args etc?

Is there some simple way to do this that I’m missing?