[clang] [NFC][analyzer] Framework for multipart checkers (PR #130985)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 12 11:27:55 PDT 2025
NagyDonat wrote:
The reason why I the support for multiple `RegisteredNames` instead of a single `Name` is directly introduced within `CheckerBase` is that this significantly simplifies the implementation. [1]
However if you wish so I could easily introduce a `static_assert` which ensures that multipart checkers must be declared as
```c++
class FancyChecker: public Checker<check::Something, check::SomethingElse, MultipleParts> {
...
}
```
or even as
```c++
class FancyChecker: public Checker<check::Something, check::SomethingElse, MultipleParts<CK_NumCheckKinds>> {
...
}
```
[1]: Code that can handle an arbitrary number of names is trivially capable of handling a single name; so if every checker has an array of `RegisteredNames` under the hood (which may be an 1-element array), then the same code can handle both the simple and the complex checkers. On the other hand, if some checkers have a single `Name` while others have an array of multiple names, then the two cases must be handled separately by ugly `if (HasMultipleNames) {...} else {...}` conditionals.
https://github.com/llvm/llvm-project/pull/130985
More information about the cfe-commits
mailing list