casts.m revision a4c7a4314ffbe402091695874e93d9b0a79c8099
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,core.experimental -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