diff options
Diffstat (limited to 'clang/test/Analysis/cstring-plist.c')
-rw-r--r-- | clang/test/Analysis/cstring-plist.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/Analysis/cstring-plist.c b/clang/test/Analysis/cstring-plist.c new file mode 100644 index 00000000000..19d0e46fd36 --- /dev/null +++ b/clang/test/Analysis/cstring-plist.c @@ -0,0 +1,22 @@ +// RUN: rm -f %t +// 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 +// 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> +// CHECK-NEXT: </dict> +// CHECK-NEXT: </plist> |