Skip to content

Commit 12c810c

Browse files
committed
QL: Add tests for FieldOnlyUsedInCharPred.ql
1 parent 2253761 commit 12c810c

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| FieldOnlyUsedInCharPred.qll:2:3:2:12 | FieldDecl | Field is only used in CharPred. |
2+
| FieldOnlyUsedInCharPred.qll:22:3:22:11 | FieldDecl | Field is only used in CharPred. |
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class C1 extends int {
2+
int field; // BAD
3+
4+
C1() {
5+
this = field and
6+
this = 0
7+
}
8+
}
9+
10+
class C2 extends C1 {
11+
int field2; // GOOD
12+
13+
C2() {
14+
this = field2 and
15+
this = 0
16+
}
17+
18+
int getField() { result = field2 }
19+
}
20+
21+
class C3 extends int {
22+
C1 field; // GOOD (overridden)
23+
24+
C3() { this = field }
25+
}
26+
27+
class C4 extends C3 {
28+
override C2 field; // GOOD (overriding)
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
queries/style/FieldOnlyUsedInCharPred.ql

0 commit comments

Comments
 (0)