| Jordan Rose | 8c888b1 | 2013-02-01 19:50:01 +0000 | [diff] [blame] | 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. |
| Anna Zaks | eb31a76 | 2012-01-04 23:54:01 +0000 | [diff] [blame] | 6 | #pragma clang system_header |
| 7 | |
| Jordan Rose | 262e0d4 | 2013-04-15 20:39:45 +0000 | [diff] [blame] | 8 | #ifdef __cplusplus |
| 9 | #define restrict /*restrict*/ |
| 10 | #endif |
| 11 | |
| Anna Zaks | eb31a76 | 2012-01-04 23:54:01 +0000 | [diff] [blame] | 12 | typedef struct _FILE FILE; |
| 13 | extern FILE *stdin; |
| Anna Zaks | ca23eb2 | 2012-02-29 18:42:47 +0000 | [diff] [blame] | 14 | extern FILE *stdout; |
| 15 | extern FILE *stderr; |
| 16 | // Include a variant of standard streams that occur in the pre-processed file. |
| 17 | extern FILE *__stdinp; |
| 18 | extern FILE *__stdoutp; |
| 19 | extern FILE *__stderrp; |
| 20 | |
| Jordan Rose | 9a0b3c2 | 2013-04-15 20:39:37 +0000 | [diff] [blame] | 21 | int scanf(const char *restrict format, ...); |
| Anna Zaks | ca23eb2 | 2012-02-29 18:42:47 +0000 | [diff] [blame] | 22 | int fscanf(FILE *restrict, const char *restrict, ...); |
| Jordan Rose | 9a0b3c2 | 2013-04-15 20:39:37 +0000 | [diff] [blame] | 23 | int printf(const char *restrict format, ...); |
| 24 | int fprintf(FILE *restrict, const char *restrict, ...); |
| 25 | int getchar(void); |
| Anna Zaks | eb31a76 | 2012-01-04 23:54:01 +0000 | [diff] [blame] | 26 | |
| 27 | // Note, on some platforms errno macro gets replaced with a function call. |
| 28 | extern int errno; |
| 29 | |
| NAKAMURA Takumi | 9620aa8 | 2012-09-20 11:03:56 +0000 | [diff] [blame] | 30 | typedef __typeof(sizeof(int)) size_t; |
| 31 | |
| 32 | size_t strlen(const char *); |
| Anna Zaks | 15d0ae1 | 2012-02-11 23:46:36 +0000 | [diff] [blame] | 33 | |
| Anna Zaks | ca23eb2 | 2012-02-29 18:42:47 +0000 | [diff] [blame] | 34 | char *strcpy(char *restrict, const char *restrict); |
| Anton Yartsev | b7a747b | 2013-11-17 09:18:48 +0000 | [diff] [blame] | 35 | void *memcpy(void *dst, const void *src, size_t n); |
| Anna Zaks | 15d0ae1 | 2012-02-11 23:46:36 +0000 | [diff] [blame] | 36 | |
| Anna Zaks | 0d389b8 | 2012-02-23 01:05:27 +0000 | [diff] [blame] | 37 | typedef unsigned long __darwin_pthread_key_t; |
| 38 | typedef __darwin_pthread_key_t pthread_key_t; |
| Anna Zaks | ca23eb2 | 2012-02-29 18:42:47 +0000 | [diff] [blame] | 39 | int pthread_setspecific(pthread_key_t, const void *); |
| 40 | |
| 41 | typedef long long __int64_t; |
| 42 | typedef __int64_t __darwin_off_t; |
| 43 | typedef __darwin_off_t fpos_t; |
| 44 | |
| 45 | void setbuf(FILE * restrict, char * restrict); |
| 46 | int setvbuf(FILE * restrict, char * restrict, int, size_t); |
| 47 | |
| Jordan Rose | 9a0b3c2 | 2013-04-15 20:39:37 +0000 | [diff] [blame] | 48 | FILE *fopen(const char * restrict, const char * restrict); |
| 49 | int fclose(FILE *); |
| Anna Zaks | ca23eb2 | 2012-02-29 18:42:47 +0000 | [diff] [blame] | 50 | FILE *funopen(const void *, |
| 51 | int (*)(void *, char *, int), |
| 52 | int (*)(void *, const char *, int), |
| 53 | fpos_t (*)(void *, fpos_t, int), |
| 54 | int (*)(void *)); |
| 55 | |
| Anna Zaks | aca0ac5 | 2012-05-03 23:50:28 +0000 | [diff] [blame] | 56 | int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*)); |
| Anna Zaks | b79d862 | 2012-05-03 23:50:33 +0000 | [diff] [blame] | 57 | |
| 58 | typedef void (*freeCallback) (void*); |
| 59 | typedef struct { |
| 60 | int i; |
| 61 | freeCallback fc; |
| 62 | } StWithCallback; |
| 63 | |
| 64 | int dealocateMemWhenDoneByVal(void*, StWithCallback); |
| 65 | int dealocateMemWhenDoneByRef(StWithCallback*, const void*); |
| Jordan Rose | 1bf908d | 2012-06-16 00:09:20 +0000 | [diff] [blame] | 66 | |
| 67 | typedef struct CGContext *CGContextRef; |
| 68 | CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height, |
| 69 | size_t bitsPerComponent, size_t bytesPerRow, |
| 70 | CGColorSpaceRef space, |
| 71 | CGBitmapInfo bitmapInfo*/); |
| 72 | void *CGBitmapContextGetData(CGContextRef context); |
| Anna Zaks | 52a0481 | 2012-06-20 23:35:57 +0000 | [diff] [blame] | 73 | |
| 74 | // Include xpc. |
| 75 | typedef struct _xpc_connection_s * xpc_connection_t; |
| 76 | typedef void (*xpc_finalizer_t)(void *value); |
| 77 | void xpc_connection_set_context(xpc_connection_t connection, void *context); |
| 78 | void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer); |
| 79 | void xpc_connection_resume(xpc_connection_t connection); |
| Anna Zaks | 233e26a | 2013-02-07 23:05:43 +0000 | [diff] [blame] | 80 | |
| Jordan Rose | 374ae32 | 2013-05-10 17:07:16 +0000 | [diff] [blame] | 81 | //The following are fake system header functions for generic testing. |
| Anna Zaks | 233e26a | 2013-02-07 23:05:43 +0000 | [diff] [blame] | 82 | void fakeSystemHeaderCallInt(int *); |
| Jordan Rose | 374ae32 | 2013-05-10 17:07:16 +0000 | [diff] [blame] | 83 | void fakeSystemHeaderCallIntPtr(int **); |
| Anna Zaks | 233e26a | 2013-02-07 23:05:43 +0000 | [diff] [blame] | 84 | |
| 85 | typedef struct __SomeStruct { |
| 86 | char * p; |
| 87 | } SomeStruct; |
| 88 | void fakeSystemHeaderCall(SomeStruct *); |