blob: 395937f340d37ad80ab92779e76fa007687bb4f8 [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>
George Karpenkov8a88c832018-09-07 21:58:24 +000021// CHECK-NEXT: <key>files</key>
22// CHECK-NEXT: <array>
23// CHECK-NEXT: </array>
Adam Baloghbf966f52018-07-13 13:44:44 +000024// CHECK-NEXT: </dict>
25// CHECK-NEXT: </plist>