forked from OSchip/llvm-project
[analyzer] Do the self-init check only on NSObject subclasses. Patch by Jean-Daniel Dupas!
llvm-svn: 124249
This commit is contained in:
parent
d5cd645c74
commit
3ae681eb12
|
@ -270,11 +270,23 @@ static bool shouldRunOnFunctionOrMethod(const NamedDecl *ND) {
|
|||
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(ND);
|
||||
if (!MD)
|
||||
return false;
|
||||
if (!MD->getClassInterface()->getSuperClass())
|
||||
return false;
|
||||
if (!isInitializationMethod(MD))
|
||||
return false;
|
||||
|
||||
// self = [super init] applies only to NSObject subclasses.
|
||||
// For instance, NSProxy doesn't implement -init.
|
||||
ASTContext& Ctx = MD->getASTContext();
|
||||
IdentifierInfo* NSObjectII = &Ctx.Idents.get("NSObject");
|
||||
ObjCInterfaceDecl* ID = MD->getClassInterface()->getSuperClass();
|
||||
for ( ; ID ; ID = ID->getSuperClass()) {
|
||||
IdentifierInfo *II = ID->getIdentifier();
|
||||
|
||||
if (II == NSObjectII)
|
||||
break;
|
||||
}
|
||||
if (!ID)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
-(id)init;
|
||||
-(id)release;
|
||||
@end
|
||||
@interface NSProxy <NSObject> {}
|
||||
@end
|
||||
|
||||
//#import "Foundation/NSObject.h"
|
||||
typedef unsigned NSUInteger;
|
||||
typedef int NSInteger;
|
||||
|
@ -48,6 +51,10 @@ extern void *somePtr;
|
|||
-(void)doSomething;
|
||||
@end
|
||||
|
||||
@interface MyProxyObj : NSProxy {}
|
||||
-(id)init;
|
||||
@end
|
||||
|
||||
@implementation MyObj
|
||||
|
||||
-(id)init {
|
||||
|
@ -137,3 +144,9 @@ extern void *somePtr;
|
|||
-(void)doSomething {}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MyProxyObj
|
||||
|
||||
- (id)init { return self; }
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue