[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Tue May 13 06:20:12 PDT 2025


================
@@ -56,11 +54,11 @@ static const Expr *getDenomExpr(const ExplodedNode *N) {
 
 void DivZeroChecker::reportBug(StringRef Msg, ProgramStateRef StateZero,
                                CheckerContext &C) const {
-  if (!isPartEnabled(DivideZeroChecker))
+  if (!DivideZeroChecker.isEnabled())
     return;
   if (ExplodedNode *N = C.generateErrorNode(StateZero)) {
-    auto R = std::make_unique<PathSensitiveBugReport>(
-        BugTypes[DivideZeroChecker], Msg, N);
+    auto R = std::make_unique<PathSensitiveBugReport>(DivideZeroChecker.getBT(),
+                                                      Msg, N);
----------------
NagyDonat wrote:

I would like to preserve that `CheckerFrontendWithBugType` is a transparent lightweight composition of the two classes, so I'd prefer deriving from `BugType` because that way `PathSensitiveBugReport` doesn't need to know that `CheckerFrontendWithBugType`  exists.

Anyway, this "magic" is not too unusual in C++ code and I don't think that it would cause confusion so I'll implement it.

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


More information about the cfe-commits mailing list