[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / pthreadlock_state.c
blobffbb33f6beaf7a586bd8e3f69cc2c31e63bb4e56
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"
5 #define NULL 0
7 void clang_analyzer_printState(void);
9 pthread_mutex_t mtx;
11 void test(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",
20 // CHECK-NEXT: ""
21 // CHECK-NEXT: ]}
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:",
29 // CHECK-NEXT: "mtx",
30 // CHECK-NEXT: ""
31 // CHECK-NEXT: ]}
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",
38 // CHECK-NEXT: ""
39 // CHECK-NEXT: ]}
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_$
48 // CHECK-NEXT: ""
49 // CHECK-NEXT: ]}
51 if (ret)
52 return;
54 clang_analyzer_printState();
55 // CHECK: { "checker": "alpha.core.PthreadLockBase", "messages": [
56 // CHECK-NEXT: "Mutex states:",
57 // CHECK-NEXT: "mtx: destroyed",
58 // CHECK-NEXT: ""
59 // CHECK-NEXT: ]}