Skip to content

Commit 5773538

Browse files
authored
Merge pull request #18655 from aschackmull/java/typeflow-joinorder
TypeFlow: Improve join-order.
2 parents 7f4facc + ce976dc commit 5773538

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

shared/typeflow/codeql/typeflow/internal/TypeFlowImpl.qll

+8-8
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@ module TypeFlow<LocationSig Location, TypeFlowInput<Location> I> {
8585
pragma[nomagic]
8686
private predicate typeBound(Type t) { typeFlow(_, t) }
8787

88+
private predicate hasSupertype(Type sub, Type ancestor) { sub.getASupertype() = ancestor }
89+
8890
/**
89-
* Gets a direct or indirect supertype of this type.
90-
* This does not include itself, unless this type is part of a cycle
91-
* in the type hierarchy.
91+
* Holds if `ancestor` is a direct or indirect supertype of `sub`.
9292
*/
93-
private Type getAStrictAncestor(Type sub) { result = getAnAncestor(sub.getASupertype()) }
93+
private predicate hasAncestorBound(Type sub, Type ancestor) =
94+
doublyBoundedFastTC(hasSupertype/2, typeBound/1, typeBound/1)(sub, ancestor)
9495

9596
/**
9697
* Holds if we have a bound for `n` that is better than `t`.
9798
*/
9899
pragma[nomagic]
99100
private predicate irrelevantBound(TypeFlowNode n, Type t) {
100101
exists(Type bound |
101-
typeFlow(n, bound) and
102-
t = getAStrictAncestor(bound) and
103-
typeBound(t) and
104-
typeFlow(n, pragma[only_bind_into](t)) and
102+
typeFlow(n, pragma[only_bind_into](bound)) and
103+
hasAncestorBound(bound, t) and
104+
typeFlow(n, t) and
105105
not getAnAncestor(t) = bound
106106
or
107107
n.getType() = pragma[only_bind_into](bound) and

0 commit comments

Comments
 (0)