-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathTest.cs
More file actions
194 lines (154 loc) · 3 KB
/
Test.cs
File metadata and controls
194 lines (154 loc) · 3 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
public class TestClass
{
public void ifs(long w)
{
int x = 0;
long y = 50;
use(y);
use(w);
if (x > 0)
{
y = 20;
use(y);
}
else
{
y = 30;
w = 10;
use(w);
}
use(y);
use(w);
if (x < 0)
{
y = 40;
w = 20;
}
else
return;
use(y);
use(w);
if (x == 0)
{
y = 60;
}
use(y);
var z = x;
use(z);
outMethod(out z);
use(z);
refMethod(ref z);
use(z);
Field = w;
use(Field);
Prop = x;
use(Prop); // no def-use for properties
int i = 0;
System.Action act = () => { i = 1; };
use(i);
Field2 = 0;
use(Field2);
Field3 = 0;
TestClass tc = null;
tc.Field3 = 1;
use(Field3);
i = 0;
i++;
use(i);
i = 0;
i--;
use(i);
var x1 = 0;
while (refMethod(ref x1) && Field2 > 0) { }
use(x1);
var x2 = 0;
refOutMethod(
ref x2,
out x2);
use(x2);
var x3 = 0;
int x4;
refOutMethod(
ref x3,
out x4);
use(x3);
use(x4);
var x5 = 0;
while (x5 > 10)
{
use(x5);
x5 = x5 + 1;
}
x5 += 1;
use(x5);
return;
}
void M() { Field2 = 0; }
public static void use<T>(T u) { return; }
public static void outMethod(out int i) { i = 42; return; }
public static bool refMethod(ref int i) { i = 1; return false; }
public static void refOutMethod(ref int i, out int j) { j = i; i = 1; }
public long Field;
public int Field2;
public int Field3;
public int Prop { get; set; }
TestClass(int i)
: this("" + i)
{
i = 0;
}
TestClass(double d)
: this(d.ToString())
{
d = 0.0;
}
TestClass(string s) { }
void Enumerable(System.Collections.Generic.IEnumerable<string> ie)
{
foreach (var x in ie)
{
use(x);
use(x);
}
return;
}
int Field4;
void FieldM1()
{
Field4 = 0;
use(Field4);
use(Field4);
}
void FieldM2()
{
use(Field4);
use(Field4);
}
int Field5;
void Captured(int i)
{
use(i);
i = 0;
System.Action a = () =>
{
i = 1;
use(i);
System.Action a1 = () =>
{
use(i);
use(i);
};
};
a();
use(i); // incorrect def-use pair with definition on line 155
Field5 = 0;
use(Field5);
a = () =>
{
Field5 = 1;
use(Field5);
};
a();
use(Field5);
}
}