[clang] [analyzer] Prettify checker registration and unittest code (PR #147797)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 06:34:49 PDT 2025
=?utf-8?q?Donát?= Nagy <donat.nagy at ericsson.com>,
=?utf-8?q?Donát?= Nagy <donat.nagy at ericsson.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/147797 at github.com>
================
@@ -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,
----------------
steakhal wrote:
just a random comment: I never understood why does `returnTrue` depend on type `T` if it just returns true xD
https://github.com/llvm/llvm-project/pull/147797
More information about the cfe-commits
mailing list