Skip to content

Commit f598a0b

Browse files
committed
Dataflow: Add test highlighting bug.
1 parent ff8bb2b commit f598a0b

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

java/ql/test/library-tests/dataflow/flowfeature/A.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,50 @@ static void test6() {
4646
Object x = source("6");
4747
test6sink(x);
4848
}
49+
50+
Object getSrc() {
51+
return source("get");
52+
}
53+
54+
void srcField() {
55+
foo = source("field");
56+
}
57+
58+
static Object foo = null;
59+
60+
void srcCall(int i) {
61+
test7(source("call"), i);
62+
}
63+
64+
Object test7(Object x, int i) {
65+
Object src = null;
66+
if (i == 0) {
67+
src = getSrc();
68+
} else if (i == 1) {
69+
src = foo;
70+
} else if (i == 2) {
71+
src = x;
72+
} else if (i == 3) {
73+
src = source("direct");
74+
}
75+
76+
sinkPut(src);
77+
foo2 = src;
78+
sink(src); // $ EqCc="direct" SrcCc="field" SrcCc="call" SrcCc="direct" SinkCc="get" SinkCc="field" SinkCc="direct"
79+
return src;
80+
}
81+
82+
static Object foo2 = null;
83+
84+
void sinkPut(Object x) {
85+
sink(x); // $ SrcCc="field" SrcCc="call" SrcCc="direct"
86+
}
87+
88+
void sinkField() {
89+
sink(foo2); // $ SrcCc="field" SrcCc="call" SrcCc="direct" SinkCc="get" SinkCc="field" SinkCc="call" SinkCc="direct"
90+
}
91+
92+
void sinkReturn(int i) {
93+
sink(test7(null, i)); // $ SrcCc="field" SinkCc="get" SinkCc="field" SinkCc="direct"
94+
}
4995
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
testFailures
2+
| A.java:78:10:78:12 | src | Unexpected result: SinkCc="call" |
23
failures

0 commit comments

Comments
 (0)