blob: 19d0e46fd3668ea6722d248a1b2e192ecaa41992 [file] [log] [blame]
Adam Baloghbf966f52018-07-13 13:44:44 +00001// RUN: rm -f %t
2// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,unix.Malloc,unix.cstring.NullArg -analyzer-disable-checker=alpha.unix.cstring.OutOfBounds -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s
3// RUN: FileCheck -input-file %t %s
4
5typedef __typeof(sizeof(int)) size_t;
6void *malloc(size_t);
7void free(void *);
8char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
9
10
11
12void cstringchecker_bounds_nocrash() {
13 char *p = malloc(2);
14 strncpy(p, "AAA", sizeof("AAA")); // we don't expect warning as the checker is disabled
15 free(p);
16}
17
18// CHECK: <key>diagnostics</key>
19// CHECK-NEXT: <array>
20// CHECK-NEXT: </array>
21// CHECK-NEXT: </dict>
22// CHECK-NEXT: </plist>