File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
clang/test/Analysis/SD-tests Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %clang_analyze_cc1 -Wno-strict-prototypes -Wno-error=implicit-int -verify %s \
2+ // RUN: -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include \
3+ // RUN: -analyzer-checker=debug.ExprInspection
4+
5+ #define NULL ((void*) 0)
6+ #include <stdbool.h>
7+
8+ typedef unsigned long int pthread_t ;
9+ typedef struct __pthread_attr pthread_attr_t ;
10+
11+ int pthread_create (pthread_t * restrict thread ,
12+
13+ const pthread_attr_t * restrict attr ,
14+
15+ void * (* start_routine )(void * ), void * restrict arg );
16+
17+
18+
19+ int pthread_join (pthread_t thread , void * * retval );
20+
21+
22+
23+ void clang_analyzer_checkInlined (bool );
24+
25+ void * thread_function (void * arg ){
26+ // should expect to fail the test at this line if you set the checkInlined to true
27+ clang_analyzer_checkInlined (false); // no-warning
28+ return NULL ;
29+ }
30+
31+ int foo_no_pthread (void )
32+ {
33+ // should expect to pass at this line
34+ clang_analyzer_checkInlined (true); // expected-warning{{TRUE}}
35+ return 0 ;
36+ }
37+
38+ int main (){
39+ pthread_t p1 ;
40+ pthread_create (& p1 , NULL , & thread_function , NULL );
41+ pthread_join (p1 , NULL );
42+ foo_no_pthread ();
43+ return 1 ;
44+ }
45+
You can’t perform that action at this time.
0 commit comments