[PATCH] D157454: [NFC][Clang] Fix static analyzer concern about null value dereference

Tom Honermann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 9 08:44:18 PDT 2023


tahonermann added inline comments.


================
Comment at: clang/lib/CodeGen/CGObjC.cpp:222-223
   Selector Sel = MethodWithObjects->getSelector();
-  QualType ResultType = E->getType();
-  const ObjCObjectPointerType *InterfacePointerType
-    = ResultType->getAsObjCInterfacePointerType();
+  const ObjCObjectPointerType *InterfacePointerType =
+      cast<ObjCObjectPointerType>(E->getType());
   ObjCInterfaceDecl *Class
----------------
The previous code included a guarantee that `InterfacePointerType->getInterfaceType()` is non-null and this change loses that assurance. Presumably, we never ran into a violation of that guarantee in the past (since a SIGSEGV would likely have occurred below otherwise), but perhaps we should consider an assertion to ensure that guarantee is still met.


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

https://reviews.llvm.org/D157454



More information about the cfe-commits mailing list