brintos

brintos / llvm-project-archived public Read only

0
0
Text · 858 B · 3851a54 Raw
31 lines · c
1// RUN: rm -f %t2// 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 %s8// RUN: FileCheck -input-file %t %s9 10typedef __typeof(sizeof(int)) size_t;11void *malloc(size_t);12void free(void *);13char *strncpy(char *restrict s1, const char *restrict s2, size_t n);14 15 16 17void cstringchecker_bounds_nocrash(void) {18  char *p = malloc(2);19  strncpy(p, "AAA", sizeof("AAA")); // we don't expect warning as the checker is disabled20  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