1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.PthreadLock,debug.ExprInspection 2>&1 %s | FileCheck %s
3 #include "Inputs/system-header-simulator-for-pthread-lock.h"
7 void clang_analyzer_printState(void);
12 clang_analyzer_printState();
13 // CHECK: "checker_messages": null
15 pthread_mutex_init(&mtx
, NULL
);
16 clang_analyzer_printState();
17 // CHECK: { "checker": "alpha.core.PthreadLockBase", "messages": [
18 // CHECK-NEXT: "Mutex states:",
19 // CHECK-NEXT: "mtx: unlocked",
23 pthread_mutex_lock(&mtx
);
24 clang_analyzer_printState();
25 // CHECK: { "checker": "alpha.core.PthreadLockBase", "messages": [
26 // CHECK-NEXT: "Mutex states:",
27 // CHECK-NEXT: "mtx: locked",
28 // CHECK-NEXT: "Mutex lock order:",
33 pthread_mutex_unlock(&mtx
);
34 clang_analyzer_printState();
35 // CHECK: { "checker": "alpha.core.PthreadLockBase", "messages": [
36 // CHECK-NEXT: "Mutex states:",
37 // CHECK-NEXT: "mtx: unlocked",
41 int ret
= pthread_mutex_destroy(&mtx
);
42 clang_analyzer_printState();
43 // CHECK: { "checker": "alpha.core.PthreadLockBase", "messages": [
44 // CHECK-NEXT: "Mutex states:",
45 // CHECK-NEXT: "mtx: unlocked, possibly destroyed",
46 // CHECK-NEXT: "Mutexes in unresolved possibly destroyed state:",
47 // CHECK-NEXT: "mtx: conj_$
54 clang_analyzer_printState();
55 // CHECK: { "checker": "alpha.core.PthreadLockBase", "messages": [
56 // CHECK-NEXT: "Mutex states:",
57 // CHECK-NEXT: "mtx: destroyed",