[RFC] Add the ability for clang-tidy to accept checks via plugins


At Sandia we are developing clang-tidy checks for our internal libraries in a llvm-project fork. The number one request from our users is that we allow checks to be added to clang-tidy via plugins so that they do not have to build a new clang-tidy exe just to get new checks.

We are willing to give implementing this a try, but I wanted to see if the community could explain why plugins don’t currently exist and help us get started in the process. Is it because there are difficult technical limitations? Or is it just that no one has spent much time on adding this feature?

Thanks for any advice and/or input.

-Cannada (Drew)


I put in an RFC 2 days ago about this.

I'm working on it, but come a little unstuck with figuring out how to
link the plugin correctly. I don't know enough about cmake to get it
working and would appreciate a little help.

Kind regards,
Nathan James

You can take some inspiration from the static analyzer, though we barely support plugins and don’t like to advertise the feature much.

https://reviews.llvm.org/D58065, section “Creating a checker plugin”.

Hi Kristóf,

I did get that working, but I was not of fan that method. I'd rather
use the llvm::Registry to load the module. As such I don't want to try
and land the feature in a state which I'd want to remove later (but
wouldn't be able to for backwards compatability reasons).

If I don't figure this out and no one else wants to contribute I would
consider using clang SA approach.