Adam Balogh | bf966f5 | 2018-07-13 13:44:44 +0000 | [diff] [blame^] | 1 | // 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 | |
| 5 | typedef __typeof(sizeof(int)) size_t; |
| 6 | void *malloc(size_t); |
| 7 | void free(void *); |
| 8 | char *strncpy(char *restrict s1, const char *restrict s2, size_t n); |
| 9 | |
| 10 | |
| 11 | |
| 12 | void 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> |