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

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 19 06:11:20 PDT 2025


https://github.com/PiotrZSL requested changes to this pull request.

I do not like this "CustomChecks"

What I would like to have in config is:

```
custom-call-main-function.Engine: Query
custom-call-main-function.Language: C
custom-call-main-function.Traverse: AsIs
custom-call-main-function.Code: 'match callExpr(callee(functionDecl(isMain()).bind("fn"))).bind("callee")'
custom-call-main-function.Diagnostic.Warning.BindName: callee
custom-call-main-function.Diagnostic.Warning.Message: "call to {fn} function"
custom-call-main-function.Diagnostic.Note.1.BindName: fn
custom-call-main-function.Diagnostic.Note.1.Message: "fn is defined here"
custom-call-main-function.Diagnostic.Note.2.BindName: fn
custom-call-main-function.Diagnostic.Note.2.Message: "fn here is not nice"
```

Main reason is simple, easy to modify check and add new check in subconfigs.
I do not see need for warnings, always someone can use warnings as errors.
If you do not want to split this into separate options, then at least move configs into invidual checks.

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


More information about the cfe-commits mailing list