[PATCH] D159549: [analyzer] Fix false negative when accessing a nonnull property from a nullable object

tripleCC via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 27 07:00:15 PDT 2023


tripleCC added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:903-904
   if (!TrackedNullability &&
-      getNullabilityAnnotation(ReturnType) == Nullability::Nullable) {
+      getNullabilityAnnotation(Call.getOriginExpr()->getType()) ==
+          Nullability::Nullable) {
     State = State->set<NullabilityMap>(Region, Nullability::Nullable);
----------------
steakhal wrote:
> I'm not sure if `getOriginExpr` is always non-null. How do you know?
> I'm not sure if `getOriginExpr` is always non-null. How do you know?
The getOriginExpr my be null ,  I optimized this logic to only perform the operation if getOriginExpr is not null.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159549



More information about the cfe-commits mailing list