xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/exercise-ps.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc // Just exercise the analyzer on code that has at one point caused issues
4f4a2713aSLionel Sambuc // (i.e., no assertions or crashes).
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc 
f1(const char * x,char * y)7f4a2713aSLionel Sambuc static void f1(const char *x, char *y) {
8f4a2713aSLionel Sambuc   while (*x != 0) {
9f4a2713aSLionel Sambuc     *y++ = *x++;
10f4a2713aSLionel Sambuc   }
11f4a2713aSLionel Sambuc }
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc // This following case checks that we properly handle typedefs when getting
14f4a2713aSLionel Sambuc // the RvalueType of an ElementRegion.
15f4a2713aSLionel Sambuc typedef struct F12_struct {} F12_typedef;
16f4a2713aSLionel Sambuc typedef void* void_typedef;
17f4a2713aSLionel Sambuc void_typedef f2_helper();
f2(void * buf)18f4a2713aSLionel Sambuc static void f2(void *buf) {
19f4a2713aSLionel Sambuc   F12_typedef* x;
20f4a2713aSLionel Sambuc   x = f2_helper();
21f4a2713aSLionel Sambuc   memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring library function 'memcpy' with type 'void *(void *, const void *}} \
22*0a6a1f1dSLionel Sambuc   // expected-note{{include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
23f4a2713aSLionel Sambuc }
24