blob: 1b001ec3cbe218bcd7775b803605a89f3e923e4c [file] [log] [blame]
Ted Kremenek62bca242009-01-22 22:42:16 +00001// RUN: clang -analyze -checker-simple -verify %s &&
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +00002// RUN: clang -analyze -checker-cfref -analyzer-store=basic -verify %s &&
3// RUN: clang -analyze -checker-cfref -analyzer-store=region -verify %s
Ted Kremeneke866a7c2008-04-30 04:40:48 +00004//
Ted Kremenek83183042009-01-24 06:11:36 +00005// Just exercise the analyzer on code that has at one point caused issues
6// (i.e., no assertions or crashes).
Ted Kremeneke866a7c2008-04-30 04:40:48 +00007
8
9static const char * f1(const char *x, char *y) {
10 while (*x != 0) {
11 *y++ = *x++;
12 }
13}
Ted Kremenek83183042009-01-24 06:11:36 +000014
15// This following case checks that we properly handle typedefs when getting
16// the RvalueType of an ElementRegion.
17typedef struct F12_struct {} F12_typedef;
18typedef void* void_typedef;
19void_typedef f2_helper();
20static void f2(void *buf) {
21 F12_typedef* x;
22 x = f2_helper();
Douglas Gregor3e41d602009-02-13 23:20:09 +000023 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 Kremenek83183042009-01-24 06:11:36 +000025}