blob: 0a95b7055601c502393108fa1fc3c0ec207fdcfa [file] [log] [blame]
Ted Kremenek565e4652010-02-05 02:06:54 +00001// 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 Kremeneke866a7c2008-04-30 04:40:48 +00003//
Ted Kremenek83183042009-01-24 06:11:36 +00004// Just exercise the analyzer on code that has at one point caused issues
5// (i.e., no assertions or crashes).
Ted Kremeneke866a7c2008-04-30 04:40:48 +00006
7
Mike Stumpdff6ba02009-07-21 18:54:29 +00008static void f1(const char *x, char *y) {
Ted Kremeneke866a7c2008-04-30 04:40:48 +00009 while (*x != 0) {
10 *y++ = *x++;
11 }
12}
Ted Kremenek83183042009-01-24 06:11:36 +000013
14// This following case checks that we properly handle typedefs when getting
15// the RvalueType of an ElementRegion.
16typedef struct F12_struct {} F12_typedef;
17typedef void* void_typedef;
18void_typedef f2_helper();
19static void f2(void *buf) {
20 F12_typedef* x;
21 x = f2_helper();
Douglas Gregor3e41d602009-02-13 23:20:09 +000022 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 Kremenek83183042009-01-24 06:11:36 +000024}