Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / suppressions-library.cpp
blobd11802a20ad3f3ab26cb94519d5364b350f05a31
1 // RUN: %clangxx_asan -O0 -DSHARED_LIB %s %fPIC -shared -o %dynamiclib %ld_flags_rpath_so
2 // RUN: %clangxx_asan -O0 %s -o %t %ld_flags_rpath_exe
4 // Check that without suppressions, we catch the issue.
5 // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
7 // REQUIRES: shell
9 // RUN: echo "interceptor_via_lib:"%xdynamiclib_filename > %t.supp
10 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
12 // XFAIL: android
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
18 #if !defined(SHARED_LIB)
20 void crash_function();
22 int main(int argc, char *argv[]) {
23 crash_function();
24 return 0;
27 #else // SHARED_LIB
29 void crash_function() {
30 char *a = (char *)malloc(6);
31 free(a);
32 size_t len = strlen(a); // BOOM
33 fprintf(stderr, "strlen ignored, %zu\n", len);
36 #endif // SHARED_LIB
38 // CHECK-CRASH: AddressSanitizer: heap-use-after-free
39 // CHECK-CRASH-NOT: strlen ignored
40 // CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free
41 // CHECK-IGNORE: strlen ignored