blob: 5dd1f3f12bd234b1c8d5072e4a9767bfb1fd2d9a [file] [log] [blame]
Ted Kremenek033a07e2011-08-03 23:14:55 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
Ted Kremeneke866a7c2008-04-30 04:40:48 +00002//
Ted Kremenek83183042009-01-24 06:11:36 +00003// Just exercise the analyzer on code that has at one point caused issues
4// (i.e., no assertions or crashes).
Ted Kremeneke866a7c2008-04-30 04:40:48 +00005
6
Mike Stumpdff6ba02009-07-21 18:54:29 +00007static void f1(const char *x, char *y) {
Ted Kremeneke866a7c2008-04-30 04:40:48 +00008 while (*x != 0) {
9 *y++ = *x++;
10 }
11}
Ted Kremenek83183042009-01-24 06:11:36 +000012
13// This following case checks that we properly handle typedefs when getting
14// the RvalueType of an ElementRegion.
15typedef struct F12_struct {} F12_typedef;
16typedef void* void_typedef;
17void_typedef f2_helper();
18static void f2(void *buf) {
19 F12_typedef* x;
20 x = f2_helper();
Chris Lattner58f9e132010-09-05 00:04:01 +000021 memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, const void *}} \
Douglas Gregor3e41d602009-02-13 23:20:09 +000022 // expected-note{{please include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
Ted Kremenek83183042009-01-24 06:11:36 +000023}