Many non-compiler-engineers would like to write simple AST checkers.
The necessity to compile the compiler often becomes an impenetrable obstacle for them (further complicated by the fact that in a corporate setup often a *specific* version of the compiler is required to compile the given project).
This patch adds a an ability to load a checker from a YAML file with a very simple grammar, significantly lowering the entry bar for the authorship to AST-based checkers.
Short FAQ I anticipate:
Q: Why not just use clang-query?
A: This is a very similar approach, but meant to be friendly to the build system, so the new checker can be run on the entire codebase at once.
Q: Why not put it in clang-tidy?
A: Again, in order to be friendly to the build system. With this setup, it's sufficient to add an extra line to CFLAGS. Doing that with clang-tidy could be more difficult, as not all projects are based on a compilation database (and currently Apple does not even ship clang-tidy in the toolchain).
Q: How expensive is linking Clang with dynamic AST matchers?
A: We already link with static AST matchers, so this change should not matter much. Changes I've seen are below few percent.
Q: Why not give the ability to load multiple files which checker descriptions at once?
A: Currently it's not done due to a technical limitation in CheckerRegistry, to be addressed in subsequent patches.