How to use clang-tidy for smaller projects

Stephen,

Thanks for your detailed response.

This bug covers adding a plugin extension interface to clang-tidy:
https://bugs.llvm.org//show_bug.cgi?id=32739

Alexander Kornienko's comment about "statically-linked-out-of-tree
checks" seems to be what I am looking for, but that isn't really
documented anywhere that I can find. I'm just not sure where to start
on this since several of the headers are internal to
clang-tools-extra.

I also recall that its possible to compile each of the llvm projects
separately, but I am unsure how to configure CMake the use the system
installed version of the libraries, or even if my distribution
installs enough components to do that. I use CMake from time to time,
but I have to admit I am a little intimidated by the 1330 different
CMake settings in the HEAD branch. I also am pretty sure how to use
the system libraries for clang-tools-extra isn't documented anywhere
either. That would get me most of the way towards the kind of
solution that I am looking for.

Aside from that, it is possible to write/generate bindings for the two
steps of clang-tidy (AST Matching followed by Rewriting). You can see an
exploration of that here:
https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching

These tools in your talk are amazing! I would love to see them merged
upstream (both to LLVM and to CompilerExplorer).

Respectfully,
Robert Underwood

Hi Robert,

Alexander Kornienko's comment about "statically-linked-out-of-tree
checks" seems to be what I am looking for, but that isn't really
documented anywhere that I can find. I'm just not sure where to start
on this since several of the headers are internal to
clang-tools-extra.

My understanding is that creating a libtooling-based standalone tool
that can analyze the AST and emit diagnostics / fixits is not something
that requires clang-tools-extra headers. See the tool template here:

https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/tool-template

If that's too minimal, I while ago I also wrote a toy tool to play with
this, and came up with

https://github.com/vmiklos/vmexam/blob/master/llvm/libtooling/readability-avoid-auto.cxx

That just follows in-tree tools, but is a self-contained example in ~100
lines of code, including AST matchers and emitting fixits (see the
Makefile for an end-to-end demo).

Regards,

Miklos