[analyzer] Nullability: Don't infer nullable when passing as nullable parameter.
authorArtem Dergachev <artem.dergachev@gmail.com>
Sat, 9 Nov 2019 02:04:27 +0000 (18:04 -0800)
committerArtem Dergachev <artem.dergachev@gmail.com>
Sat, 9 Nov 2019 02:27:14 +0000 (18:27 -0800)
You can't really infer anything from that.

clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
clang/test/Analysis/nullability.m [new file with mode: 0644]

index 4322ac2..9220487 100644 (file)
@@ -728,11 +728,6 @@ void NullabilityChecker::checkPreCall(const CallEvent &Call,
       }
       continue;
     }
-    // No tracked nullability yet.
-    if (ArgExprTypeLevelNullability != Nullability::Nullable)
-      continue;
-    State = State->set<NullabilityMap>(
-        Region, NullabilityState(ArgExprTypeLevelNullability, ArgExpr));
   }
   if (State != OrigState)
     C.addTransition(State);
diff --git a/clang/test/Analysis/nullability.m b/clang/test/Analysis/nullability.m
new file mode 100644 (file)
index 0000000..f777900
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker core,nullability -w -verify %s
+
+// expected-no-diagnostics
+
+id _Nonnull conjure_nonnull();
+void use_nullable(_Nullable id x);
+
+id _Nonnull foo() {
+  void *j = conjure_nonnull();
+  use_nullable(j);
+  return j; // no-warning
+}