[cfe-commits] r161012 - in /cfe/trunk: lib/StaticAnalyzer/Core/CallEvent.cpp test/Analysis/self-init.m
Anna Zaks
ganna at apple.com
Mon Jul 30 16:48:36 PDT 2012
Author: zaks
Date: Mon Jul 30 18:48:36 2012
New Revision: 161012
URL: http://llvm.org/viewvc/llvm-project?rev=161012&view=rev
Log:
[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.)
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/self-init.m
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=161012&r1=161011&r2=161012&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Mon Jul 30 18:48:36 2012
@@ -592,21 +592,27 @@
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<ObjCObjectPointerType>(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<ObjCObjectPointerType>(SupersType.getTypePtr());
+ } else {
+ const MemRegion *Receiver = getReceiverSVal().getAsRegion();
+ 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 {
// This is a class method.
// If we have type info for the receiver class, we are calling via
Modified: cfe/trunk/test/Analysis/self-init.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/self-init.m?rev=161012&r1=161011&r2=161012&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/self-init.m (original)
+++ cfe/trunk/test/Analysis/self-init.m Mon Jul 30 18:48:36 2012
@@ -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;
More information about the cfe-commits
mailing list