[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 18 07:25:23 PDT 2025


================
@@ -1165,7 +1165,7 @@ ProgramStateRef StdLibraryFunctionsChecker::NotNullConstraint::apply(
   return State->assume(L, CannotBeNull);
 }
 
-void StdLibraryFunctionsChecker::NotNullConstraint::describe(
+void StdLibraryFunctionsChecker::NullnessConstraint::describe(
     DescriptionKind DK, const CallEvent &Call, ProgramStateRef State,
     const Summary &Summary, llvm::raw_ostream &Out) const {
   assert(CannotBeNull &&
----------------
balazske wrote:

Currently the `NotNullConstraint` is used in two ways:

- Argument preconditions where only a non-null condition is used. When `describe` is called here the `CannotBeNull` should be true. The `describeArgumentValue` is called on the negated version of it when `CannotBeNull` is false.
- Return value conditions at "cases" where it can be null or non-null. Here always a custom description text is used and `describe` or `describeArgumentValue` is not called. 

Purpose of the assertion seems to be only to make a simplification (not implement `describe` in the null and `describeArgumentValue` in the non-null case). The assertion could be extended with something like `getArgNo() != Ret &&` (verify the first use case above).

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


More information about the cfe-commits mailing list