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

Elizabeth Andrews via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 9 10:10:10 PDT 2023


eandrews 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
----------------
tahonermann wrote:
> 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.
Hmmm... I guess in that case it was just make more sense to keep the old code and add an assert for InterfacePointerType?


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

https://reviews.llvm.org/D157454



More information about the cfe-commits mailing list