1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.PthreadLock,debug.ExprInspection 2>&1 %s | FileCheck %s
2 
3 #include "Inputs/system-header-simulator-for-pthread-lock.h"
4 
5 #define NULL 0
6 
7 void clang_analyzer_printState();
8 
test(pthread_mutex_t * mtx)9 void test(pthread_mutex_t *mtx) {
10   int ret = pthread_mutex_destroy(mtx);
11   clang_analyzer_printState();
12   // CHECK:    { "checker": "alpha.core.PthreadLockBase", "messages": [
13   // CHECK-NEXT:      "Mutex states:",
14   // CHECK-NEXT:      "SymRegion{reg_$[[REG:[0-9]+]]<pthread_mutex_t * mtx>}: not tracked, possibly destroyed",
15   // CHECK-NEXT:      "Mutexes in unresolved possibly destroyed state:",
16   // CHECK-NEXT:      "SymRegion{reg_$[[REG]]<pthread_mutex_t * mtx>}: conj_$
17   // CHECK-NEXT:      ""
18   // CHECK-NEXT:    ]}
19   if (ret)
20     return;
21   pthread_mutex_init(mtx, NULL);
22 }
23