[PATCH] D77722: [analyzer] Do not report NSError null dereference for _Nonnull params

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 8 06:28:02 PDT 2020


NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

> `NonnullParamChecker`

Yup, looks like that's actually the one that deals with `__attribute__((nonnull))`, as opposed to `_Nonnull`.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:521
+  // Annotations that we want to consider make sense only for types.
+  auto Region = dyn_cast_or_null<TypedValueRegion>(Location.getAsRegion());
+  if (!Region)
----------------
[[ https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable | Too much `auto` ]]!


================
Comment at: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:527
+
+  auto StoredVal = State->getSVal(Region).getAs<loc::MemRegionVal>();
+  if (!StoredVal)
----------------
([[ https://reviews.llvm.org/D33672?id=171506#inline-475812 | this `auto` is good ]])


================
Comment at: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:537
+    // be considered non-null as annotated by the developer.
+    if (auto NewState = State->assume(*StoredVal, true)) {
+      Context.addTransition(NewState);
----------------
Ok, so we're continuing normally if the value is already known to have been assigned to null. We could sink the analysis instead but presumably it's not our job as another checker must have warned before we get there (let's comment about this maybe).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77722/new/

https://reviews.llvm.org/D77722





More information about the cfe-commits mailing list