correctly resolve super calls in char preds

This commit is contained in:
Erik Krogh Kristensen
2021-10-15 21:28:19 +02:00
parent 145efa4a1a
commit 3b1c04b71c
3 changed files with 13 additions and 1 deletions

View File

@@ -81,7 +81,7 @@ private module Cached {
// super calls
exists(Super sup, ClassType type, Type supertype |
mc.getBase() = sup and
sup.getEnclosingPredicate().(ClassPredicate).getParent().getType() = type and
sup.getEnclosingPredicate().getParent().(Class).getType() = type and
supertype in [type.getASuperType(), type.getAnInstanceofType()] and
p = supertype.getClassPredicate(mc.getMemberName(), mc.getNumberOfArguments())
)

11
ql/test/callgraph/Baz.qll Normal file
View File

@@ -0,0 +1,11 @@
class Foo extends string {
Foo() { this = "Foo" }
string getImportedPath() { none() }
}
class Bar extends string, Foo {
Bar() { exists(Foo.super.getImportedPath()) }
override string getImportedPath() { none() }
}

View File

@@ -1,5 +1,6 @@
getTarget
| Bar.qll:5:38:5:47 | PredicateCall | Bar.qll:8:3:8:31 | ClasslessPredicate snapshot |
| Baz.qll:8:18:8:44 | MemberCall | Baz.qll:4:3:4:37 | ClassPredicate getImportedPath |
| Foo.qll:5:26:5:30 | PredicateCall | Foo.qll:3:1:3:26 | ClasslessPredicate foo |
| Foo.qll:10:21:10:25 | PredicateCall | Foo.qll:8:3:8:28 | ClassPredicate bar |
| Foo.qll:14:30:14:40 | MemberCall | Foo.qll:10:3:10:27 | ClassPredicate baz |