[analyzer] Refactor codes in findMethodDecl()
authorManna, Soumi <soumi.manna@intel.com>
Thu, 29 Jun 2023 02:51:15 +0000 (19:51 -0700)
committerManna, Soumi <soumi.manna@intel.com>
Thu, 29 Jun 2023 03:40:02 +0000 (20:40 -0700)
commita806ec4857c2c662c89755edba56d893ae1beeb4
treeb5d050e51c9b9ac7813ea43be2e031cd55661bf5
parent310a6f12b5b80f6b77d8551c53e0fc2a2844df07
[analyzer] Refactor codes in findMethodDecl()

In findMethodDecl(clang::ObjCMessageExpr const *, clang::ObjCObjectPointerType const *, clang::ASTContext &), if the MessageExpr->getReceiverKind() is not Instance or Class, we never dereference pointer “ReceiverObjectPtrType”. Also, we don't dereference the pointer “ReceiverObjectPtrType” if ReceiverType is ObjCIdType or ObhjCClassType. So the pointer “ReceiverObjectPtrType”is only used in this branch and the declaration should be here.

This patch directly uses ReceiverType->castAs<ObjCObjectPointerType>() instead of ReceiverObjectPtrType when calling canAssignObjCInterfaces() to express the intent more clearly.

Reviewed By: erichkeane, steakhal

Differential Revision: https://reviews.llvm.org/D152194
clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp