[clang] [clang][analyzer] Add checker 'core.NullPointerArithm' (PR #157129)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 8 05:44:25 PDT 2025


================
@@ -173,9 +178,11 @@ static bool isDeclRefExprToReference(const Expr *E) {
   return false;
 }
 
-void DereferenceChecker::reportBug(const DerefBugType &BT,
-                                   ProgramStateRef State, const Stmt *S,
-                                   CheckerContext &C) const {
+void DereferenceChecker::reportDerefBug(const DerefBugType &BT,
+                                        ProgramStateRef State, const Stmt *S,
+                                        CheckerContext &C) const {
+  assert(&BT != &NullPointerArithmBug && "Invalid use of function");
+
----------------
NagyDonat wrote:

```suggestion
```
You don't need this assertion because it's already enforced by type system: the parameter `BT` is a `const DerefBugType &`, so it's impossible pass `NullPointerArithBug` (which is a plain `BugType`) to it. Strong typing is a nice feature :smile: 

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


More information about the cfe-commits mailing list