[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

Congcong Cai via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 20 15:31:44 PDT 2025


HerrCai0907 wrote:

> clang-query doesn't really lend itself to "find this pattern, replace with this other pattern", and clang-tidy requires enough boilerplate for checks that it's a heavy-handed solution. It might make more sense to design a tool specific for code transformations -- something that can be easily run over a compile_commands.json file, for example.

I think transforming code and detecting code are totally different things. If someone want a tools to help him automatically replace code, it should be done by other tools.

Here the only thing I want to support is let adding custom checks for special projects possible. They are lots of projects have some code guidelines which is not suitable for every projects. so they cannot be supported in official clangtidy. For example, in our projects, we cannot use static variable because linker script cannot place them correct, but it definitely cannot  be merged in mainline.
If we limit the usage as a checker. then clangtidy is the best way to support it. we can reuse the config, nolint and so on.

https://github.com/llvm/llvm-project/pull/131804


More information about the cfe-commits mailing list