exercise-ps.c revision a4c7a4314ffbe402091695874e93d9b0a79c8099
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,core.experimental -analyzer-store=region -verify %s
2//
3// Just exercise the analyzer on code that has at one point caused issues
4// (i.e., no assertions or crashes).
5
6
7static void f1(const char *x, char *y) {
8  while (*x != 0) {
9    *y++ = *x++;
10  }
11}
12
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();
21  memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, const void *}} \
22  // expected-note{{please include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
23}
24