C#: Fix join-order in UselessUpcast.ql

This commit is contained in:
Tom Hvitved
2020-12-02 10:12:57 +01:00
parent 9dbcb7c642
commit 9c516bf62c

View File

@@ -86,16 +86,21 @@ class ExplicitUpcast extends ExplicitCast {
src != dest // Handled by `cs/useless-cast-to-self` src != dest // Handled by `cs/useless-cast-to-self`
} }
/** Holds if this upcast is the argument of a call to `target`. */ pragma[nomagic]
private predicate isArgument(Call c, Callable target) { private predicate isArgument(Type t) {
exists(Parameter p | exists(Parameter p |
this = p.getAnAssignedArgument() and this = p.getAnAssignedArgument() and
p.getType() = this.getType() and t = p.getType()
c.getAnArgument() = this and
target = c.getTarget()
) )
} }
/** Holds if this upcast is the argument of a call to `target`. */
private predicate isArgument(Call c, Callable target) {
this.isArgument(this.getType()) and
c.getAnArgument() = this and
target = c.getTarget()
}
/** Holds if this upcast may be used to disambiguate the target of an instance call. */ /** Holds if this upcast may be used to disambiguate the target of an instance call. */
pragma[nomagic] pragma[nomagic]
private predicate isDisambiguatingInstanceCall(InstanceCallable other, int args) { private predicate isDisambiguatingInstanceCall(InstanceCallable other, int args) {