casts.m revision 773d847fbe93479f7499e2076c9d8d99870c5fb0
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s 2 3// Test function pointer casts. Currently we track function addresses using 4// loc::FunctionVal. Because casts can be arbitrary, do we need to model 5// functions with regions? 6typedef void* (*MyFuncTest1)(void); 7 8MyFuncTest1 test1_aux(void); 9void test1(void) { 10 void *x; 11 void* (*p)(void); 12 p = ((void*) test1_aux()); 13 if (p != ((void*) 0)) x = (*p)(); 14} 15 16// Test casts from void* to function pointers. Same issue as above: 17// should we eventually model function pointers using regions? 18void* test2(void *p) { 19 MyFuncTest1 fp = (MyFuncTest1) p; 20 return (*fp)(); 21} 22 23// <radar://10087620> 24// A cast from int onjective C property reference to int. 25typedef signed char BOOL; 26@protocol NSObject - (BOOL)isEqual:(id)object; @end 27@interface NSObject <NSObject> {} - (id)init; @end 28typedef enum { 29 EEOne, 30 EETwo 31} RDR10087620Enum; 32@interface RDR10087620 : NSObject { 33 RDR10087620Enum elem; 34} 35@property (readwrite, nonatomic) RDR10087620Enum elem; 36static void 37adium_media_ready_cb(RDR10087620 *InObj) 38{ 39 InObj.elem |= EEOne; 40} 41@end