[PATCH] D11468: [Static Analyzer] The first implementation of nullability checker.

Anna Zaks via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 24 18:46:26 PDT 2015


zaks.anna added a comment.

Gabor, there is a lot of the same steps that all callbacks go through. I think refactoring those into subroutines will help with readability of the checker.

Looking forward to seeing a new version soon!
Anna.


================
Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:607
@@ +606,3 @@
+
+void NullabilityChecker::checkPostStmt(const ExplicitCastExpr *CE,
+                                       CheckerContext &C) const {
----------------
+ comment

// We trust the explicit casts. If there is a disagreement in nullability annotations of destination and source or if '0' is casted to a nonnull type, track the value as having contradictory nullability. This will allow users to suppress nullability warnings.

================
Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:618
@@ +617,3 @@
+
+  if (DestNullability == Nullability::Unspecified)
+    return;
----------------
What is users try to suppress a FP using a cast to unspecified?

================
Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:671
@@ +670,3 @@
+  ProgramStateRef State = C.getState();
+  ConditionTruthVal IsNull = State->isNull(V.castAs<DefinedOrUnknownSVal>());
+  bool RhsIsNull = IsNull.isConstrainedTrue();
----------------
We know that V is not undef here? 

================
Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:676
@@ +675,3 @@
+  Nullability LocNullability = getNullability(LocType);
+  // The null pointer is loaded to a reference is handled in another checker.
+  if (Filter.CheckNullPassedToNonnull && RhsIsNull &&
----------------
This comment is not clear.


http://reviews.llvm.org/D11468





More information about the cfe-commits mailing list