1 // RUN: %clang_analyze_cc1 %s -verify \
2 // RUN:   -analyzer-checker=core \
3 // RUN:   -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true
4 //
5 // Just exercise the analyzer on code that has at one point caused issues
6 // (i.e., no assertions or crashes).
7 
f1(const char * x,char * y)8 static void f1(const char *x, char *y) {
9   while (*x != 0) {
10     *y++ = *x++;
11   }
12 }
13 
14 // This following case checks that we properly handle typedefs when getting
15 // the RvalueType of an ElementRegion.
16 typedef struct F12_struct {} F12_typedef;
17 typedef void* void_typedef;
18 void_typedef f2_helper();
f2(void * buf)19 static void f2(void *buf) {
20   F12_typedef* x;
21   x = f2_helper();
22   memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring library function 'memcpy' with type 'void *(void *, const void *}} \
23   // expected-note{{include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
24 }
25 
26 // AllocaRegion is untyped. Void pointer isn't of much help either. Before
27 // realizing that the value is undefined, we need to somehow figure out
28 // what type of value do we expect.
f3(void * dest)29 void f3(void *dest) {
30   void *src = __builtin_alloca(5);
31   memcpy(dest, src, 1); // expected-warning{{2nd function call argument is a pointer to uninitialized value}}
32 }
33