exercise-ps.c revision dff6ba0025356dfb4f82a48afd89bcdd631566ef
1// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -verify %s &&
2// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -verify %s &&
3// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
4//
5// Just exercise the analyzer on code that has at one point caused issues
6// (i.e., no assertions or crashes).
7
8
9static void f1(const char *x, char *y) {
10  while (*x != 0) {
11    *y++ = *x++;
12  }
13}
14
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();
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'}}
25}
26