1 // RUN: %clangxx -fsanitize=realtime %s -o %t
2 // RUN: not %run %t 2>&1 | FileCheck %s
3 // RUN: %clangxx %s -fsanitize=realtime -o - -S -emit-llvm | FileCheck %s --check-prefix=CHECK-ENABLED-IR
4 // RUN: %clangxx %s -o - -S -emit-llvm | FileCheck %s --check-prefix=CHECK-DISABLED-IR
10 #include "sanitizer/rtsan_interface.h"
12 void violation() [[clang::nonblocking
]] {
15 __rtsan::ScopedDisabler disabler
{};
17 fprintf(stderr
, "Allocated pointer %p in disabled context\n", ptr
);
20 // ensure nested disablers don't interfere with one another
23 __rtsan::ScopedDisabler disabler
{};
25 __rtsan::ScopedDisabler disabler2
{};
27 fprintf(stderr
, "Allocated second pointer %p in disabled context\n",
32 fprintf(stderr
, "Free'd second pointer in disabled context\n");
41 // CHECK: Allocated pointer {{.*}} in disabled context
42 // CHECK: Allocated second pointer {{.*}} in disabled context
43 // CHECK: Free'd second pointer in disabled context
44 // CHECK: ==ERROR: RealtimeSanitizer: unsafe-library-call
45 // CHECK-NOT: {{.*malloc*}}
46 // CHECK-NEXT: {{.*free.*}}
49 // CHECK-ENABLED-IR: {{.*@__rtsan_disable.*}}
50 // CHECK-ENABLED-IR: {{.*@__rtsan_enable.*}}
52 // CHECK-DISABLED-IR-NOT: {{.*__rtsan_disable.*}}
53 // CHECK-DISABLED-IR-NOT: {{.*__rtsan_enable.*}}