[clang] [analyzer] Report violations of the "returns_nonnull" attribute (PR #106048)

Arseniy Zaostrovnykh via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 26 08:08:15 PDT 2024


================
@@ -692,6 +692,14 @@ void NullabilityChecker::checkPreStmt(const ReturnStmt *S,
   NullConstraint Nullness = getNullConstraint(*RetSVal, State);
 
   Nullability RequiredNullability = getNullabilityAnnotation(RequiredRetType);
+  if (const auto *FunDecl = C.getLocationContext()->getDecl();
----------------
necto wrote:

`getNullabilityAnnotation` is concerned only with the type. It is used both for return types and function parameters by multiple checkers.
Handling the function annotation there would mean I have to pass the function declaration (which might not be available in the client of the API), which is only relevant in one case (and maybe another couple in TrustNonnullChecker). That means I would need to complicate the function definition and potentially increase the PR footprint by touching all call sites.

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


More information about the cfe-commits mailing list