mirror of
https://github.com/github/codeql.git
synced 2026-02-09 03:31:06 +01:00
Add test for override
This test demonstrates that our handling of `override` is incorrect. Quick-eval'ing the `test` predicate produces the following output: | f | i | j | +---+-----+-----+ | 1 | 10 | 10 | | 1 | 10 | 100 | | 1 | 100 | 10 | | 1 | 100 | 100 | | 2 | 20 | 20 | | 3 | 3 | 3 | this demonstrates that `f.bar` and `f.baz` can resolve to all predicates of that name in the file. However, at present we only capture the calls to members on `Foo`.
This commit is contained in:
30
ql/test/callgraph/Overrides.qll
Normal file
30
ql/test/callgraph/Overrides.qll
Normal file
@@ -0,0 +1,30 @@
|
||||
import ql
|
||||
|
||||
class Foo extends int {
|
||||
Foo() { this in [1, 2, 3] }
|
||||
|
||||
int bar() { result = this }
|
||||
|
||||
predicate baz(int i) { i = this.bar() }
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
Bar() { this = [1, 2] }
|
||||
|
||||
override int bar() { result = 10 * this }
|
||||
|
||||
override predicate baz(int i) { i = this.bar() }
|
||||
}
|
||||
|
||||
class Baz extends Foo {
|
||||
Baz() { this = 1 }
|
||||
|
||||
override int bar() { result = 100 * this }
|
||||
|
||||
override predicate baz(int i) { i = this.bar() }
|
||||
}
|
||||
|
||||
query predicate test(Foo f, int i, int j) {
|
||||
f.bar() = i and
|
||||
f.baz(j)
|
||||
}
|
||||
@@ -6,3 +6,10 @@
|
||||
| Foo.qll:29:5:29:16 | PredicateCall | Foo.qll:26:3:26:32 | ClasslessPredicate alias2 |
|
||||
| Foo.qll:31:5:31:12 | PredicateCall | Foo.qll:22:3:22:32 | ClasslessPredicate myThing0 |
|
||||
| Foo.qll:31:5:31:12 | PredicateCall | Foo.qll:24:3:24:32 | ClasslessPredicate alias0 |
|
||||
| Overrides.qll:8:30:8:39 | MemberCall | Overrides.qll:6:3:6:29 | ClassPredicate bar |
|
||||
| Overrides.qll:16:39:16:48 | MemberCall | Overrides.qll:6:3:6:29 | ClassPredicate bar |
|
||||
| Overrides.qll:16:39:16:48 | MemberCall | Overrides.qll:14:12:14:43 | ClassPredicate bar |
|
||||
| Overrides.qll:24:39:24:48 | MemberCall | Overrides.qll:6:3:6:29 | ClassPredicate bar |
|
||||
| Overrides.qll:24:39:24:48 | MemberCall | Overrides.qll:22:12:22:44 | ClassPredicate bar |
|
||||
| Overrides.qll:28:3:28:9 | MemberCall | Overrides.qll:6:3:6:29 | ClassPredicate bar |
|
||||
| Overrides.qll:29:3:29:10 | MemberCall | Overrides.qll:8:3:8:41 | ClassPredicate baz |
|
||||
|
||||
Reference in New Issue
Block a user