C#: Exclude nullness sources that are deemed non-null.

This commit is contained in:
Anders Schack-Mulligen
2025-10-29 12:57:55 +01:00
parent 0df0816c95
commit 72f1fe5d58

View File

@@ -442,13 +442,16 @@ class DereferenceableExpr extends Expr {
/** Holds if `guard` suggests that this expression may be `null`. */
predicate guardSuggestsMaybeNull(Guards::Guard guard) {
guard = this.getANullnessNullCheck(_, true)
or
LogicInput::additionalNullCheck(guard, _, this, true)
or
guard.isEquality(this, any(Expr n | nullValueImplied(n)), _)
or
Guards::nullGuard(guard, any(GuardValue v | exists(v.asBooleanValue())), this, true)
not nonNullValueImplied(this) and
(
guard = this.getANullnessNullCheck(_, true)
or
LogicInput::additionalNullCheck(guard, _, this, true)
or
guard.isEquality(this, any(Expr n | nullValueImplied(n)), _)
or
Guards::nullGuard(guard, any(GuardValue v | exists(v.asBooleanValue())), this, true)
)
}
}