1 // RUN: rm -f %t
2 // RUN: %clang_analyze_cc1 -fblocks \
3 // RUN: -analyzer-checker=core \
4 // RUN: -analyzer-checker=unix.Malloc \
5 // RUN: -analyzer-checker=unix.cstring.NullArg \
6 // RUN: -analyzer-disable-checker=alpha.unix.cstring.OutOfBounds \
7 // RUN: -analyzer-output=plist -o %t %s
8 // RUN: FileCheck -input-file %t %s
9
10 typedef __typeof(sizeof(int)) size_t;
11 void *malloc(size_t);
12 void free(void *);
13 char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
14
15
16
cstringchecker_bounds_nocrash()17 void cstringchecker_bounds_nocrash() {
18 char *p = malloc(2);
19 strncpy(p, "AAA", sizeof("AAA")); // we don't expect warning as the checker is disabled
20 free(p);
21 }
22
23 // CHECK: <key>diagnostics</key>
24 // CHECK-NEXT: <array>
25 // CHECK-NEXT: </array>
26 // CHECK-NEXT: <key>files</key>
27 // CHECK-NEXT: <array>
28 // CHECK-NEXT: </array>
29 // CHECK-NEXT: </dict>
30 // CHECK-NEXT: </plist>
31