Ted Kremenek | 565e465 | 2010-02-05 02:06:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -verify %s |
| 2 | // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify %s |
Ted Kremenek | e866a7c | 2008-04-30 04:40:48 +0000 | [diff] [blame] | 3 | // |
Ted Kremenek | 8318304 | 2009-01-24 06:11:36 +0000 | [diff] [blame] | 4 | // Just exercise the analyzer on code that has at one point caused issues |
| 5 | // (i.e., no assertions or crashes). |
Ted Kremenek | e866a7c | 2008-04-30 04:40:48 +0000 | [diff] [blame] | 6 | |
| 7 | |
Mike Stump | dff6ba0 | 2009-07-21 18:54:29 +0000 | [diff] [blame] | 8 | static void f1(const char *x, char *y) { |
Ted Kremenek | e866a7c | 2008-04-30 04:40:48 +0000 | [diff] [blame] | 9 | while (*x != 0) { |
| 10 | *y++ = *x++; |
| 11 | } |
| 12 | } |
Ted Kremenek | 8318304 | 2009-01-24 06:11:36 +0000 | [diff] [blame] | 13 | |
| 14 | // This following case checks that we properly handle typedefs when getting |
| 15 | // the RvalueType of an ElementRegion. |
| 16 | typedef struct F12_struct {} F12_typedef; |
| 17 | typedef void* void_typedef; |
| 18 | void_typedef f2_helper(); |
| 19 | static void f2(void *buf) { |
| 20 | F12_typedef* x; |
| 21 | x = f2_helper(); |
Douglas Gregor | 3e41d60 | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 22 | memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, void const *}} \ |
| 23 | // 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] | 24 | } |