Question
Parse clang AST from `compile_commands.json` ignoring PCH
I'm trying to parse an AST of the whole project using a compilation database (compile_commands.json), but it contains pch files and commands related to generate those, resulting in errors during parsing: error: PCH file uses a newer PCH format that cannot be read 1 error generated.
The project has been configured (via CMake) and compiled using a different compiler, and the whole reason to make a tool instead of a plugin is not to be bound to a particular compiler. I might try an ad hoc solution to strip compile_commands.json
from pch-related stuff, but I doubt it will work properly and worth the hustle.
The initialization is basically like this:
auto options_parser =
CommonOptionsParser::create(argc, argv, option_category);
if (!options_parser) {
llvm::errs() << options_parser.takeError();
return -1;
}
ClangTool tool(options_parser->getCompilations(),
options_parser->getCompilations().getAllFiles());
Is possible to configure the tool not to handle pch-related stuff?