| 1 | // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify |
| 2 | // expected-no-diagnostics |
| 3 | |
| 4 | typedef struct _FILE FILE; |
| 5 | typedef __typeof(sizeof(int)) size_t; |
| 6 | extern FILE *stdin; |
| 7 | typedef long ssize_t; |
| 8 | ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); |
| 9 | int printf(const char * __restrict, ...); |
| 10 | int snprintf(char *, size_t, const char *, ...); |
| 11 | void free(void *ptr); |
| 12 | |
| 13 | struct GetLineTestStruct { |
| 14 | ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); |
| 15 | }; |
| 16 | |
| 17 | void getlineTest(void) { |
| 18 | FILE *fp; |
| 19 | char *line = 0; |
| 20 | size_t len = 0; |
| 21 | ssize_t read; |
| 22 | struct GetLineTestStruct T; |
| 23 | |
| 24 | while ((read = T.getline(&line, &len, stdin)) != -1) { |
| 25 | printf("%s", line); // no warning |
| 26 | } |
| 27 | free(line); |
| 28 | } |
| 29 | |
| 30 | class opaque; |
| 31 | void testOpaqueClass(opaque *obj) { |
| 32 | char buf[20]; |
| 33 | snprintf(buf, 20, "%p", obj); // don't crash trying to load *obj |
| 34 | } |
| 35 | |
| 36 | |