Skip to content
Snippets Groups Projects
Commit 5808eb80 authored by Anna Zaks's avatar Anna Zaks
Browse files

[analyzer] Handle inlining of instance calls to super.

Use self-init.m for testing. (It used to have a bunch of failing tests
with dynamic inlining turned on.)

llvm-svn: 161012
parent 160dcdf2
No related branches found
No related tags found
No related merge requests found
...@@ -592,21 +592,27 @@ ObjCMessageKind ObjCMethodCall::getMessageKind() const { ...@@ -592,21 +592,27 @@ ObjCMessageKind ObjCMethodCall::getMessageKind() const {
const Decl *ObjCMethodCall::getRuntimeDefinition() const { const Decl *ObjCMethodCall::getRuntimeDefinition() const {
const ObjCMessageExpr *E = getOriginExpr(); const ObjCMessageExpr *E = getOriginExpr();
Selector Sel = E->getSelector();
assert(E); assert(E);
Selector Sel = E->getSelector();
if (E->isInstanceMessage()) { if (E->isInstanceMessage()) {
const MemRegion *Receiver = getReceiverSVal().getAsRegion();
DynamicTypeInfo TI = getState()->getDynamicTypeInfo(Receiver); // Find the the receiver type.
const ObjCObjectPointerType *T = const ObjCObjectPointerType *ReceiverT = 0;
dyn_cast<ObjCObjectPointerType>(TI.getType().getTypePtr()); QualType SupersType = E->getSuperType();
if (!T) if (!SupersType.isNull()) {
return 0; ReceiverT = cast<ObjCObjectPointerType>(SupersType.getTypePtr());
if (ObjCInterfaceDecl *IDecl = T->getInterfaceDecl()) { } else {
// Find the method implementation. const MemRegion *Receiver = getReceiverSVal().getAsRegion();
return IDecl->lookupPrivateMethod(Sel); DynamicTypeInfo TI = getState()->getDynamicTypeInfo(Receiver);
ReceiverT = dyn_cast<ObjCObjectPointerType>(TI.getType().getTypePtr());
} }
// Lookup the method implementation.
if (ReceiverT)
if (ObjCInterfaceDecl *IDecl = ReceiverT->getInterfaceDecl())
return IDecl->lookupPrivateMethod(Sel);
} else { } else {
// This is a class method. // This is a class method.
// If we have type info for the receiver class, we are calling via // If we have type info for the receiver class, we are calling via
......
// 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 // RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -fno-builtin %s -verify
@class NSZone, NSCoder; @class NSZone, NSCoder;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment