brintos

brintos / llvm-project-archived public Read only

0
0
Text · 885 B · d787c7e Raw
38 lines · plain
1// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s2 3typedef signed char BOOL;4@protocol NSObject  - (BOOL)isEqual:(id)object; @end5@interface NSObject <NSObject> {}6+(id)alloc;7-(id)init;8+(id)new;9-(id)autorelease;10-(id)copy;11- (Class)class;12-(id)retain;13@end14void clang_analyzer_eval(BOOL);15 16@interface SomeOtherClass : NSObject17- (int)getZero;18@end19@implementation SomeOtherClass20- (int)getZero { return 0; }21@end22 23@interface MyClass : NSObject24- (int)getZero;25@end26 27@implementation MyClass28- (int)getZero { return 1; }29 30// TODO: Not only we should correctly determine that the type of o at runtime 31// is MyClass, but we should also warn about it. 32+ (void) testCastToParent {33  id a = [[self alloc] init];34  SomeOtherClass *o = a;  35  clang_analyzer_eval([o getZero] == 0); // expected-warning{{FALSE}}36}37@end38