2018-07-13 21:44:44 +08:00
|
|
|
// RUN: rm -f %t
|
2018-11-02 23:48:10 +08:00
|
|
|
// RUN: %clang_analyze_cc1 -fblocks \
|
2019-05-23 23:49:04 +08:00
|
|
|
// RUN: -analyzer-checker=core \
|
|
|
|
// RUN: -analyzer-checker=unix.Malloc \
|
|
|
|
// RUN: -analyzer-checker=unix.cstring.NullArg \
|
2018-11-02 23:48:10 +08:00
|
|
|
// RUN: -analyzer-disable-checker=alpha.unix.cstring.OutOfBounds \
|
|
|
|
// RUN: -analyzer-output=plist -o %t %s
|
2018-07-13 21:44:44 +08:00
|
|
|
// RUN: FileCheck -input-file %t %s
|
|
|
|
|
|
|
|
typedef __typeof(sizeof(int)) size_t;
|
|
|
|
void *malloc(size_t);
|
|
|
|
void free(void *);
|
|
|
|
char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cstringchecker_bounds_nocrash() {
|
|
|
|
char *p = malloc(2);
|
|
|
|
strncpy(p, "AAA", sizeof("AAA")); // we don't expect warning as the checker is disabled
|
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: <key>diagnostics</key>
|
|
|
|
// CHECK-NEXT: <array>
|
|
|
|
// CHECK-NEXT: </array>
|
2018-09-08 05:58:24 +08:00
|
|
|
// CHECK-NEXT: <key>files</key>
|
|
|
|
// CHECK-NEXT: <array>
|
|
|
|
// CHECK-NEXT: </array>
|
2018-07-13 21:44:44 +08:00
|
|
|
// CHECK-NEXT: </dict>
|
|
|
|
// CHECK-NEXT: </plist>
|