Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Darwin / suppressions-function.cpp
blobf58796fb878d4183ef9a73ede834c11bb291dbb9
1 // Check that without suppressions, we catch the issue.
2 // RUN: %clangxx_asan -O0 %s -o %t
3 // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
5 // RUN: echo "interceptor_via_fun:crash_function" > %t.supp
6 // RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
8 // UNSUPPORTED: ios
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
14 void crash_function() {
15 char *a = (char *)malloc(6);
16 free(a);
17 size_t len = strlen(a); // BOOM
18 fprintf(stderr, "strlen ignored, len = %zu\n", len);
21 int main() {
22 crash_function();
25 // CHECK-CRASH: AddressSanitizer: heap-use-after-free
26 // CHECK-CRASH-NOT: strlen ignored
27 // CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free
28 // CHECK-IGNORE: strlen ignored