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 6 namespace __tsan { 7 8 #if (__APPLE__) 9 __attribute__((weak)) 10 #endif OnPotentiallyBlockingRegionBegin()11void OnPotentiallyBlockingRegionBegin() { 12 printf("Enter __cxa_guard_acquire\n"); 13 } 14 15 #if (__APPLE__) 16 __attribute__((weak)) 17 #endif OnPotentiallyBlockingRegionEnd()18void OnPotentiallyBlockingRegionEnd() { printf("Exit __cxa_guard_acquire\n"); } 19 20 } // namespace __tsan 21 main(int argc,char ** argv)22int main(int argc, char **argv) { 23 // CHECK: Enter main 24 printf("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("Exit main\n"); 31 return 0; 32 } 33