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