[PATCH] D152194: [NFC][CLANG] Fix nullptr dereference issue found by static analyzer tool
Soumi Manna via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 5 13:28:06 PDT 2023
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.
This patch uses castAs instead of getAs which will assert if the type doesn't match in findMethodDecl(clang::ObjCMessageExpr const *, clang::ObjCObjectPointerType const *, clang::ASTContext &).
Repository:
rG LLVM Github Monorepo
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
@@ -743,7 +743,7 @@
QualType ReceiverType = MessageExpr->getReceiverType();
const auto *ReceiverObjectPtrType =
- ReceiverType->getAs<ObjCObjectPointerType>();
+ ReceiverType->castAs<ObjCObjectPointerType>();
// Do this "devirtualization" on instance and class methods only. Trust the
// static type on super and super class calls.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152194.528561.patch
Type: text/x-patch
Size: 624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230605/b708170a/attachment.bin>
More information about the cfe-commits
mailing list