diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index ad5a104aa05ef7b2d2be9b62c791503a66fec62b..bfc00ed2e0eae1c631124057fe2020945e90d283 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -592,21 +592,27 @@ ObjCMessageKind ObjCMethodCall::getMessageKind() const { const Decl *ObjCMethodCall::getRuntimeDefinition() const { const ObjCMessageExpr *E = getOriginExpr(); - Selector Sel = E->getSelector(); assert(E); + Selector Sel = E->getSelector(); if (E->isInstanceMessage()) { - const MemRegion *Receiver = getReceiverSVal().getAsRegion(); - DynamicTypeInfo TI = getState()->getDynamicTypeInfo(Receiver); - const ObjCObjectPointerType *T = - dyn_cast(TI.getType().getTypePtr()); - if (!T) - return 0; - if (ObjCInterfaceDecl *IDecl = T->getInterfaceDecl()) { - // Find the method implementation. - return IDecl->lookupPrivateMethod(Sel); + + // Find the the receiver type. + const ObjCObjectPointerType *ReceiverT = 0; + QualType SupersType = E->getSuperType(); + if (!SupersType.isNull()) { + ReceiverT = cast(SupersType.getTypePtr()); + } else { + const MemRegion *Receiver = getReceiverSVal().getAsRegion(); + DynamicTypeInfo TI = getState()->getDynamicTypeInfo(Receiver); + ReceiverT = dyn_cast(TI.getType().getTypePtr()); } + // Lookup the method implementation. + if (ReceiverT) + if (ObjCInterfaceDecl *IDecl = ReceiverT->getInterfaceDecl()) + return IDecl->lookupPrivateMethod(Sel); + } else { // This is a class method. // If we have type info for the receiver class, we are calling via diff --git a/clang/test/Analysis/self-init.m b/clang/test/Analysis/self-init.m index 10b0c4da47b646be7ee91eb7ce5923eaef3be14a..b0c51a2b37e19f47f534bc6c6340865737616cff 100644 --- a/clang/test/Analysis/self-init.m +++ b/clang/test/Analysis/self-init.m @@ -1,3 +1,4 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -analyzer-ipa=dynamic -fno-builtin %s -verify // RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -fno-builtin %s -verify @class NSZone, NSCoder;