blob: c527564d49e37d583279fd2d3a495522a87df932 [file] [log] [blame]
Adam Baloghbf966f52018-07-13 13:44:44 +00001// RUN: rm -f %t
Kristof Umannc83b0dd2018-11-02 15:48:10 +00002// RUN: %clang_analyze_cc1 -fblocks \
3// RUN: -analyzer-checker=core,unix.Malloc,unix.cstring.NullArg \
4// RUN: -analyzer-disable-checker=alpha.unix.cstring.OutOfBounds \
5// RUN: -analyzer-output=plist -o %t %s
Adam Baloghbf966f52018-07-13 13:44:44 +00006// RUN: FileCheck -input-file %t %s
7
8typedef __typeof(sizeof(int)) size_t;
9void *malloc(size_t);
10void free(void *);
11char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
12
13
14
15void cstringchecker_bounds_nocrash() {
16 char *p = malloc(2);
17 strncpy(p, "AAA", sizeof("AAA")); // we don't expect warning as the checker is disabled
18 free(p);
19}
20
21// CHECK: <key>diagnostics</key>
22// CHECK-NEXT: <array>
23// CHECK-NEXT: </array>
George Karpenkov8a88c832018-09-07 21:58:24 +000024// CHECK-NEXT: <key>files</key>
25// CHECK-NEXT: <array>
26// CHECK-NEXT: </array>
Adam Baloghbf966f52018-07-13 13:44:44 +000027// CHECK-NEXT: </dict>
28// CHECK-NEXT: </plist>