[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 11:52:50 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
----------------
eandrews wrote:
> 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?
Ah, yes, I think that is a better approach!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157454/new/
https://reviews.llvm.org/D157454
More information about the cfe-commits
mailing list