Ted Kremenek | 62bca24 | 2009-01-22 22:42:16 +0000 | [diff] [blame] | 1 | // RUN: clang -analyze -checker-simple -verify %s && |
Ted Kremenek | be1fe1e | 2009-02-17 04:27:41 +0000 | [diff] [blame] | 2 | // RUN: clang -analyze -checker-cfref -analyzer-store=basic -verify %s && |
| 3 | // RUN: clang -analyze -checker-cfref -analyzer-store=region -verify %s |
Ted Kremenek | e866a7c | 2008-04-30 04:40:48 +0000 | [diff] [blame] | 4 | // |
Ted Kremenek | 8318304 | 2009-01-24 06:11:36 +0000 | [diff] [blame] | 5 | // Just exercise the analyzer on code that has at one point caused issues |
| 6 | // (i.e., no assertions or crashes). |
Ted Kremenek | e866a7c | 2008-04-30 04:40:48 +0000 | [diff] [blame] | 7 | |
| 8 | |
| 9 | static const char * f1(const char *x, char *y) { |
| 10 | while (*x != 0) { |
| 11 | *y++ = *x++; |
| 12 | } |
| 13 | } |
Ted Kremenek | 8318304 | 2009-01-24 06:11:36 +0000 | [diff] [blame] | 14 | |
| 15 | // This following case checks that we properly handle typedefs when getting |
| 16 | // the RvalueType of an ElementRegion. |
| 17 | typedef struct F12_struct {} F12_typedef; |
| 18 | typedef void* void_typedef; |
| 19 | void_typedef f2_helper(); |
| 20 | static void f2(void *buf) { |
| 21 | F12_typedef* x; |
| 22 | x = f2_helper(); |
Douglas Gregor | 3e41d60 | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 23 | memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, void const *}} \ |
| 24 | // expected-note{{please include the header <string.h> or explicitly provide a declaration for 'memcpy'}} |
Ted Kremenek | 8318304 | 2009-01-24 06:11:36 +0000 | [diff] [blame] | 25 | } |