Skip to content

Commit 5ed42b8

Browse files
nuudlmanVictoria Nguyen
andauthored
Basic Inlining Test (#3)
* created simple test to check if worker function is inlined; expected to fail * removed include flag and enumerated bool --------- Co-authored-by: Victoria Nguyen <[email protected]>
1 parent cb6a02d commit 5ed42b8

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %clang_analyze_cc1 -Wno-strict-prototypes -Wno-error=implicit-int -verify %s \
2+
// RUN: -analyzer-checker=debug.ExprInspection
3+
4+
#define NULL ((void*) 0)
5+
enum bool {
6+
false,
7+
true
8+
};
9+
10+
11+
typedef unsigned long int pthread_t;
12+
typedef struct __pthread_attr pthread_attr_t;
13+
14+
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
15+
16+
17+
int pthread_join(pthread_t thread, void **retval);
18+
19+
void clang_analyzer_checkInlined(enum bool);
20+
21+
void* thread_function(void* arg){
22+
// should expect to fail the test at this line if you set the checkInlined to true
23+
clang_analyzer_checkInlined(true); // expected-warning{{TRUE}}
24+
return NULL;
25+
}
26+
27+
int foo_no_pthread(void)
28+
{
29+
// should expect to pass at this line
30+
clang_analyzer_checkInlined(true); // expected-warning{{TRUE}}
31+
return 0;
32+
}
33+
34+
int main(){
35+
pthread_t p1;
36+
pthread_create(&p1, NULL, &thread_function, NULL);
37+
pthread_join(p1, NULL);
38+
foo_no_pthread();
39+
return 1;
40+
}
41+

0 commit comments

Comments
 (0)