1// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2
3#include <sanitizer/tsan_interface.h>
4#include <stdio.h>
5
6namespace __tsan {
7
8#if (__APPLE__)
9__attribute__((weak))
10#endif
11void OnPotentiallyBlockingRegionBegin() {
12 printf(format: "Enter __cxa_guard_acquire\n");
13}
14
15#if (__APPLE__)
16__attribute__((weak))
17#endif
18void OnPotentiallyBlockingRegionEnd() { printf(format: "Exit __cxa_guard_acquire\n"); }
19
20} // namespace __tsan
21
22int main(int argc, char **argv) {
23 // CHECK: Enter main
24 printf(format: "Enter main\n");
25 // CHECK-NEXT: Enter __cxa_guard_acquire
26 // CHECK-NEXT: Exit __cxa_guard_acquire
27 static int s = argc;
28 (void)s;
29 // CHECK-NEXT: Exit main
30 printf(format: "Exit main\n");
31 return 0;
32}
33

source code of compiler-rt/test/tsan/cxa_guard_acquire.cpp