system-header-simulator.h revision 9a0b3c2f7c440c53b65bd1b085a7471d9f7ed490
1// Like the compiler, the static analyzer treats some functions differently if 2// they come from a system header -- for example, it is assumed that system 3// functions do not arbitrarily free() their parameters, and that some bugs 4// found in system headers cannot be fixed by the user and should be 5// suppressed. 6#pragma clang system_header 7 8typedef struct _FILE FILE; 9extern FILE *stdin; 10extern FILE *stdout; 11extern FILE *stderr; 12// Include a variant of standard streams that occur in the pre-processed file. 13extern FILE *__stdinp; 14extern FILE *__stdoutp; 15extern FILE *__stderrp; 16 17int scanf(const char *restrict format, ...); 18int fscanf(FILE *restrict, const char *restrict, ...); 19int printf(const char *restrict format, ...); 20int fprintf(FILE *restrict, const char *restrict, ...); 21int getchar(void); 22 23// Note, on some platforms errno macro gets replaced with a function call. 24extern int errno; 25 26typedef __typeof(sizeof(int)) size_t; 27 28size_t strlen(const char *); 29 30char *strcpy(char *restrict, const char *restrict); 31 32typedef unsigned long __darwin_pthread_key_t; 33typedef __darwin_pthread_key_t pthread_key_t; 34int pthread_setspecific(pthread_key_t, const void *); 35 36typedef long long __int64_t; 37typedef __int64_t __darwin_off_t; 38typedef __darwin_off_t fpos_t; 39 40void setbuf(FILE * restrict, char * restrict); 41int setvbuf(FILE * restrict, char * restrict, int, size_t); 42 43FILE *fopen(const char * restrict, const char * restrict); 44int fclose(FILE *); 45FILE *funopen(const void *, 46 int (*)(void *, char *, int), 47 int (*)(void *, const char *, int), 48 fpos_t (*)(void *, fpos_t, int), 49 int (*)(void *)); 50 51int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*)); 52 53typedef void (*freeCallback) (void*); 54typedef struct { 55 int i; 56 freeCallback fc; 57} StWithCallback; 58 59int dealocateMemWhenDoneByVal(void*, StWithCallback); 60int dealocateMemWhenDoneByRef(StWithCallback*, const void*); 61 62typedef struct CGContext *CGContextRef; 63CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height, 64 size_t bitsPerComponent, size_t bytesPerRow, 65 CGColorSpaceRef space, 66 CGBitmapInfo bitmapInfo*/); 67void *CGBitmapContextGetData(CGContextRef context); 68 69// Include xpc. 70typedef struct _xpc_connection_s * xpc_connection_t; 71typedef void (*xpc_finalizer_t)(void *value); 72void xpc_connection_set_context(xpc_connection_t connection, void *context); 73void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer); 74void xpc_connection_resume(xpc_connection_t connection); 75 76//The following is a fake system header function 77void fakeSystemHeaderCallInt(int *); 78 79typedef struct __SomeStruct { 80 char * p; 81} SomeStruct; 82void fakeSystemHeaderCall(SomeStruct *); 83