DynDispatchBifurcate.m revision e90d3f847dcce76237078b67db8895eb7a24189e
1// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic-bifurcate -verify %s 2 3typedef signed char BOOL; 4typedef struct objc_class *Class; 5typedef struct objc_object { 6 Class isa; 7} *id; 8@protocol NSObject - (BOOL)isEqual:(id)object; @end 9@interface NSObject <NSObject> {} 10+(id)alloc; 11-(id)init; 12-(id)autorelease; 13-(id)copy; 14- (Class)class; 15-(id)retain; 16@end 17 18@interface MyParent : NSObject 19- (int)getZero; 20@end 21@implementation MyParent 22- (int)getZero { 23 return 0; 24} 25@end 26 27@interface MyClass : MyParent 28- (int)getZero; 29@end 30 31MyClass *getObj(); 32 33// Check that we explore both paths - on one the calla are inlined and they are 34// not inlined on the other. 35// In this case, p can be either the object of type MyParent* or MyClass*: 36// - If it's MyParent*, getZero returns 0. 37// - If it's MyClass*, getZero returns 1 and 'return 5/m' is reachable. 38@implementation MyClass 39+ (int) testTypeFromParam:(MyParent*) p { 40 int m = 0; 41 int z = [p getZero]; 42 if (z) 43 return 5/m; // expected-warning {{Division by zero}} 44 return 5/[p getZero];// expected-warning {{Division by zero}} 45} 46 47- (int)getZero { 48 return 1; 49} 50 51@end