1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
6 __attribute__((noinline
)) void Func1() {
7 pthread_mutex_lock(&mtx
);
8 __tsan_check_no_mutexes_held();
9 pthread_mutex_unlock(&mtx
);
12 __attribute__((noinline
)) void Func2() {
13 pthread_mutex_lock(&mtx
);
14 pthread_mutex_unlock(&mtx
);
15 __tsan_check_no_mutexes_held();
19 pthread_mutex_init(&mtx
, NULL
);
25 // CHECK: WARNING: ThreadSanitizer: mutex held in the wrong context
26 // CHECK: {{.*}}__tsan_check_no_mutexes_held{{.*}}
27 // CHECK: {{.*}}Func1{{.*}}
28 // CHECK: {{.*}}main{{.*}}
29 // CHECK: Mutex {{.*}} created at:
30 // CHECK: {{.*}}pthread_mutex_init{{.*}}
31 // CHECK: {{.*}}main{{.*}}
32 // CHECK: SUMMARY: ThreadSanitizer: mutex held in the wrong context {{.*}}mutex_held_wrong_context.cpp{{.*}}Func1
34 // CHECK-NOT: SUMMARY: ThreadSanitizer: mutex held in the wrong context {{.*}}mutex_held_wrong_context.cpp{{.*}}Func2