[PATCH] D152194: [StaticAnalyzer] Fix nullptr dereference issue found by static analyzer tool
Soumi Manna via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 6 19:45:51 PDT 2023
Manna updated this revision to Diff 529133.
Manna retitled this revision from "[NFC][CLANG] Fix nullptr dereference issue found by static analyzer tool" to "[StaticAnalyzer] Fix nullptr dereference issue found by static analyzer tool".
Manna edited the summary of this revision.
Manna added a comment.
Herald added a subscriber: szepet.
Thank you @erichkeane and @steakhal for reviews and feedbacks. I have updated patch to address your review comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152194/new/
https://reviews.llvm.org/D152194
Files:
clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
Index: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -742,8 +742,6 @@
const ObjCMethodDecl *Method = nullptr;
QualType ReceiverType = MessageExpr->getReceiverType();
- const auto *ReceiverObjectPtrType =
- ReceiverType->getAs<ObjCObjectPointerType>();
// Do this "devirtualization" on instance and class methods only. Trust the
// static type on super and super class calls.
@@ -753,7 +751,8 @@
// type, look up the method in the tracked type, not in the receiver type.
// This way we preserve more information.
if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType() ||
- ASTCtxt.canAssignObjCInterfaces(ReceiverObjectPtrType, TrackedType)) {
+ ASTCtxt.canAssignObjCInterfaces(
+ ReceiverType->castAs<ObjCObjectPointerType>(), TrackedType)) {
const ObjCInterfaceDecl *InterfaceDecl = TrackedType->getInterfaceDecl();
// The method might not be found.
Selector Sel = MessageExpr->getSelector();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152194.529133.patch
Type: text/x-patch
Size: 1206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230607/f2381804/attachment.bin>
More information about the cfe-commits
mailing list