From faf33efeb832e382ef7cba4ca76f1d10e08292df Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Thu, 22 Sep 2022 19:10:14 +0200 Subject: [PATCH] C#: Improve join ordering further for InterpretedCallable. --- .../code/csharp/dataflow/ExternalFlow.qll | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll index 98e02c32d2f..ae3db5461b3 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll @@ -511,8 +511,17 @@ private predicate callableSpecInfo(Callable c, string namespace, string type, st } pragma[nomagic] -private predicate subtypeSpecCandidate(Callable c, UnboundValueOrRefType t) { - elementSpec(_, _, true, c.getName(), _, _, t) +private predicate subtypeSpecCandidate(string name, UnboundValueOrRefType t) { + exists(UnboundValueOrRefType t0 | + elementSpec(_, _, true, name, _, _, t0) and + t = t0.getASubTypeUnbound+() + ) +} + +pragma[nomagic] +private predicate callableInfo(Callable c, string name, UnboundValueOrRefType decl) { + name = c.getName() and + decl = c.getDeclaringType() } private class InterpretedCallable extends Callable { @@ -522,9 +531,9 @@ private class InterpretedCallable extends Callable { elementSpec(namespace, type, _, name, _, _) ) or - exists(UnboundValueOrRefType t | - subtypeSpecCandidate(this, t) and - this.getDeclaringType() = t.getASubTypeUnbound+() + exists(string name, UnboundValueOrRefType t | + callableInfo(this, name, t) and + subtypeSpecCandidate(name, t) ) } }