Skip to content

Commit 11c113b

Browse files
committed
C#: Use new format for generics when parsing MaD rows
1 parent 84773fc commit 11c113b

File tree

1 file changed

+12
-53
lines changed

1 file changed

+12
-53
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/ExternalFlow.qll

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private predicate elementSpec(
269269
UnboundValueOrRefType t
270270
) {
271271
elementSpec(namespace, type, subtypes, name, signature, ext) and
272-
t.hasQualifiedName(namespace, type)
272+
QN::hasQualifiedName(t, namespace, type)
273273
}
274274

275275
private class UnboundValueOrRefType extends ValueOrRefType {
@@ -299,19 +299,6 @@ class UnboundCallable extends Callable {
299299
}
300300
}
301301

302-
private predicate hasName(Declaration d, string name) {
303-
d.(Operator).getFunctionName() = name
304-
or
305-
not d instanceof Operator and
306-
d.hasName(name)
307-
}
308-
309-
pragma[nomagic]
310-
private predicate callableSpecInfo(Callable c, string namespace, string type, string name) {
311-
c.getDeclaringType().hasQualifiedName(namespace, type) and
312-
hasName(c, name)
313-
}
314-
315302
pragma[nomagic]
316303
private predicate subtypeSpecCandidate(string name, UnboundValueOrRefType t) {
317304
exists(UnboundValueOrRefType t0 |
@@ -322,14 +309,19 @@ private predicate subtypeSpecCandidate(string name, UnboundValueOrRefType t) {
322309

323310
pragma[nomagic]
324311
private predicate callableInfo(Callable c, string name, UnboundValueOrRefType decl) {
325-
hasName(c, name) and
326-
decl = c.getDeclaringType()
312+
decl = c.getDeclaringType() and
313+
(
314+
c.(Operator).getFunctionName() = name
315+
or
316+
not c instanceof Operator and
317+
c.hasName(name)
318+
)
327319
}
328320

329321
private class InterpretedCallable extends Callable {
330322
InterpretedCallable() {
331323
exists(string namespace, string type, string name |
332-
callableSpecInfo(this, namespace, type, name) and
324+
partialModel(this, namespace, type, name, _) and
333325
elementSpec(namespace, type, _, name, _, _)
334326
)
335327
or
@@ -340,49 +332,16 @@ private class InterpretedCallable extends Callable {
340332
}
341333
}
342334

343-
private string paramsStringPartA(InterpretedCallable c, int i) {
344-
i = -1 and result = "("
345-
or
346-
exists(int n |
347-
exists(c.getParameter(n)) and
348-
i = 2 * n - 1 and
349-
result = "," and
350-
n != 0
351-
)
352-
or
353-
i = 2 * c.getNumberOfParameters() and result = ")"
354-
}
355-
356-
private string paramsStringPartB(InterpretedCallable c, int i) {
357-
exists(int n, string p, Type t |
358-
t = c.getParameter(n).getType() and
359-
i = 2 * n and
360-
result = p and
361-
p = t.getQualifiedName()
362-
)
363-
}
364-
365-
private string paramsString(InterpretedCallable c) {
366-
result =
367-
strictconcat(int i, string s |
368-
s in [paramsStringPartA(c, i), paramsStringPartB(c, i)]
369-
|
370-
s order by i
371-
)
372-
}
373-
374-
/** Gets the source/sink/summary/neutral base declaration corresponding to the supplied parameters. */
375335
pragma[nomagic]
376336
Declaration interpretBaseDeclaration(string namespace, string type, string name, string signature) {
377337
exists(UnboundValueOrRefType t | elementSpec(namespace, type, _, name, signature, _, t) |
378338
result =
379339
any(Declaration d |
380-
d.getDeclaringType() = t and
381-
hasName(d, name) and
340+
QN::hasQualifiedName(d, namespace, type, name) and
382341
(
383342
signature = ""
384343
or
385-
paramsString(d) = signature
344+
signature = "(" + parameterQualifiedTypeNamesToString(d) + ")"
386345
)
387346
)
388347
or
@@ -394,7 +353,7 @@ Declaration interpretBaseDeclaration(string namespace, string type, string name,
394353

395354
/** Gets the source/sink/summary/neutral element corresponding to the supplied parameters. */
396355
pragma[nomagic]
397-
Element interpretElement(
356+
Declaration interpretElement(
398357
string namespace, string type, boolean subtypes, string name, string signature, string ext
399358
) {
400359
elementSpec(namespace, type, subtypes, name, signature, ext) and

0 commit comments

Comments
 (0)