-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathir.c
106 lines (90 loc) · 1.43 KB
/
ir.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
typedef struct {
int x, y;
} MyCoords;
int getX(MyCoords *coords);
void MyCoordsTest(int pos) {
MyCoords coords = {0};
coords.x = coords.y = pos + 1;
coords.x = getX(&coords);
}
void CStyleCast(void *src)
{
char *dst = (char*)src;
}
void ExRaiseAccessViolation(int);
#define EXCEPTION_EXECUTE_HANDLER 1
int TryExceptTest(int x) {
int *localPtr;
__try {
ExRaiseAccessViolation(x);
} __except(EXCEPTION_EXECUTE_HANDLER) {
return 1;
}
return 0;
}
void unexplained_loop_regression()
{
__try
{
ExRaiseAccessViolation(0);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
ExRaiseAccessViolation(1);
}
}
void try_with_finally()
{
int x = 0;
__try
{
x = 1;
}
__finally
{
x = 2;
}
}
void throw_in_try_with_finally()
{
int x = 0;
__try
{
ExRaiseAccessViolation(0);
}
__finally
{
x = 1;
}
}
void throw_in_try_with_throw_in_finally()
{
__try {
ExRaiseAccessViolation(0);
}
__finally {
ExRaiseAccessViolation(0);
}
}
void raise_access_violation() {
ExRaiseAccessViolation(1);
}
void branch_on_integral_in_c(int x1, int x2) {
if (x1) {}
if(!x1) {}
int y = !x1;
if(y) {}
if(!y) {}
if(x1 && x2) {}
if(!x1 && x2) {}
if(x1 && !x2) {}
if(!x1 && !x2) {}
if(x1 || x2) {}
if(!x1 || x2) {}
if(x1 || !x2) {}
if(!x1 || !x2) {}
int x_1_and_2 = x1 && x2;
if(x_1_and_2) {}
if(!x_1_and_2) {}
}
// semmle-extractor-options: --microsoft