Skip to content

Commit e578827

Browse files
committed
Java: Add more field-flow tests
1 parent a1d5591 commit e578827

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
public class F {
2+
Object Field1;
3+
Object Field2;
4+
public F() {
5+
Field1 = new Object();
6+
Field2 = new Object();
7+
}
8+
9+
private void m() {
10+
Object o = new Object();
11+
F f = new F();
12+
f.Field1 = o;
13+
f.Field2 = o;
14+
f.Field2 = null;
15+
sink(f.Field1); // flow
16+
sink(f.Field2); // no flow [FALSE POSITIVE]
17+
18+
f = new F();
19+
f.Field2 = null;
20+
sink(f.Field1); // flow
21+
sink(f.Field2); // no flow [FALSE POSITIVE]
22+
23+
f = new F();
24+
o = new Object();
25+
f.Field1 = o;
26+
f.Field2 = o;
27+
m2(f);
28+
}
29+
30+
private void m2(F f)
31+
{
32+
f.Field2 = null;
33+
sink(f.Field1); // flow
34+
sink(f.Field2); // no flow [FALSE POSITIVE]
35+
}
36+
37+
public static void sink(Object o) { }
38+
}

java/ql/test/library-tests/dataflow/fields/flow.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@
2626
| E.java:2:32:2:43 | new Object(...) | E.java:21:10:21:24 | bh2.buf.content |
2727
| E.java:2:32:2:43 | new Object(...) | E.java:24:10:24:28 | p2.data.buf.content |
2828
| E.java:2:32:2:43 | new Object(...) | E.java:30:10:30:27 | p.data.buf.content |
29+
| F.java:5:14:5:25 | new Object(...) | F.java:15:10:15:17 | f.Field1 |
30+
| F.java:5:14:5:25 | new Object(...) | F.java:20:10:20:17 | f.Field1 |
31+
| F.java:5:14:5:25 | new Object(...) | F.java:33:10:33:17 | f.Field1 |
32+
| F.java:6:14:6:25 | new Object(...) | F.java:16:10:16:17 | f.Field2 |
33+
| F.java:6:14:6:25 | new Object(...) | F.java:21:10:21:17 | f.Field2 |
34+
| F.java:6:14:6:25 | new Object(...) | F.java:34:10:34:17 | f.Field2 |
35+
| F.java:10:16:10:27 | new Object(...) | F.java:15:10:15:17 | f.Field1 |
36+
| F.java:10:16:10:27 | new Object(...) | F.java:16:10:16:17 | f.Field2 |
37+
| F.java:24:9:24:20 | new Object(...) | F.java:33:10:33:17 | f.Field1 |
38+
| F.java:24:9:24:20 | new Object(...) | F.java:34:10:34:17 | f.Field2 |

0 commit comments

Comments
 (0)