Linux kernel compile_commands.json

FYI, I have been working on using clang LibTooling on the Linux kernel.

A couple of months ago, I wrote a script that generates compile_commands.json directly from the output of the Linux KBuild system and committed it to the Linux kernel source tree as scripts/gen_compile_commands.py.

I’ve been using this script and its output successfully ever since to run LibTooling-based tools on the kernel, including the static analyzer, clangd (through Vim), analyze-build (for creating the AST files for cross-TU static analysis), etc. This was also the motivation for my recent AST patch (r354916) to handle GNU ChooseExpr.

Those who are looking to use clang tools on the Linux kernel can see the upstream source (scripts/gen_compile_commands.py: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b30204640192234d18f9168f19f9cd693485b86d).