[clang] [analyzer] Prettify checker registration and unittest code (PR #147797)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 09:38:31 PDT 2025
================
@@ -112,26 +112,35 @@ class CheckerRegistry {
return true;
}
-public:
- /// Adds a checker to the registry. Use this non-templated overload when your
- /// checker requires custom initialization.
- void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction sfn,
+ /// Adds a checker to the registry. This private, most general variant is
+ /// intended for loading the checker definitions from `Checkers.td`.
+ /// FIXME: The checker registry should not bother with loading `DocsUri`
+ /// because it is (as of now) never queried from the checker registry.
+ void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction Sfn,
StringRef FullName, StringRef Desc, StringRef DocsUri,
bool IsHidden);
- /// Adds a checker to the registry. Use this templated overload when your
- /// checker does not require any custom initialization.
- /// This function isn't really needed and probably causes more headaches than
- /// the tiny convenience that it provides, but external plugins might use it,
- /// and there isn't a strong incentive to remove it.
+public:
+ /// Adds a checker to the registry. Use this for a checker defined in a
+ /// plugin if it requires custom registration functions.
+ void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction Sfn,
+ StringRef FullName, StringRef Desc, bool IsHidden = false) {
+ addChecker(Fn, Sfn, FullName, Desc, "NoDocsUri", IsHidden);
+ }
+
+ /// Adds a checker to the registry. Use this for a checker defined in a
+ /// plugin if it doesn't require custom registration functions.
template <class T>
- void addChecker(StringRef FullName, StringRef Desc, StringRef DocsUri,
- bool IsHidden = false) {
- // Avoid MSVC's Compiler Error C2276:
- // http://msdn.microsoft.com/en-us/library/850cstw1(v=VS.80).aspx
+ void addChecker(StringRef FullName, StringRef Desc, bool IsHidden = false) {
addChecker(&CheckerRegistry::initializeManager<CheckerManager, T>,
- &CheckerRegistry::returnTrue<T>, FullName, Desc, DocsUri,
- IsHidden);
+ &CheckerRegistry::returnTrue<T>, FullName, Desc,
----------------
NagyDonat wrote:
I, too, have no idea :upside_down_face: and I asked @Szelethus who added the template parameter in 2020, but he doesn't remember why was it added.
The projects can be compiled and linked without the template parameter, so I decided to remove it in https://github.com/llvm/llvm-project/pull/147797/commits/4c5c619929343fbee05e7be643710ce30aca3272
https://github.com/llvm/llvm-project/pull/147797
More information about the cfe-commits
mailing list