Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions shared/typeflow/codeql/typeflow/internal/TypeFlowImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ module TypeFlow<LocationSig Location, TypeFlowInput<Location> I> {
pragma[nomagic]
private predicate typeBound(Type t) { typeFlow(_, t) }

private predicate hasSupertype(Type sub, Type ancestor) { sub.getASupertype() = ancestor }

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

/**
* Holds if we have a bound for `n` that is better than `t`.
*/
pragma[nomagic]
private predicate irrelevantBound(TypeFlowNode n, Type t) {
exists(Type bound |
typeFlow(n, bound) and
t = getAStrictAncestor(bound) and
typeBound(t) and
typeFlow(n, pragma[only_bind_into](t)) and
typeFlow(n, pragma[only_bind_into](bound)) and
hasAncestorBound(bound, t) and
typeFlow(n, t) and
not getAnAncestor(t) = bound
or
n.getType() = pragma[only_bind_into](bound) and
Expand Down