Skip to content

Commit fc32998

Browse files
committed
C#: Fix issue with summary tests, such that the output is compatiable with flow summary interpreter.
1 parent 2cac729 commit fc32998

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,14 @@ private class UnboundValueOrRefType extends ValueOrRefType {
357357
}
358358
}
359359

360-
private class UnboundCallable extends Callable {
360+
/** An unbound callable. */
361+
class UnboundCallable extends Callable {
361362
UnboundCallable() { this.isUnboundDeclaration() }
362363

364+
/**
365+
* Holds if this unbound callable overrides or implements (transitively)
366+
* `that` unbound callable.
367+
*/
363368
predicate overridesOrImplementsUnbound(UnboundCallable that) {
364369
exists(Callable c |
365370
this.(Virtualizable).overridesOrImplementsOrEquals(c) or

csharp/ql/test/library-tests/dataflow/library/FlowSummariesFiltered.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import shared.FlowSummaries
2+
private import semmle.code.csharp.dataflow.ExternalFlow
23

34
class IncludeFilteredSummarizedCallable extends IncludeSummarizedCallable {
45
IncludeFilteredSummarizedCallable() { this instanceof SummarizedCallable }
@@ -14,8 +15,8 @@ class IncludeFilteredSummarizedCallable extends IncludeSummarizedCallable {
1415
this.propagatesFlow(input, output, preservesValue) and
1516
not exists(IncludeSummarizedCallable rsc |
1617
rsc.isBaseCallableOrPrototype() and
17-
this.(Virtualizable).overridesOrImplements(rsc) and
18-
rsc.propagatesFlow(input, output, preservesValue)
18+
rsc.propagatesFlow(input, output, preservesValue) and
19+
this.(UnboundCallable).overridesOrImplementsUnbound(rsc)
1920
)
2021
}
2122
}

csharp/ql/test/shared/FlowSummaries.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ abstract class IncludeSummarizedCallable extends RelevantSummarizedCallable {
2020
predicate isBaseCallableOrPrototype() {
2121
this.getDeclaringType() instanceof Interface
2222
or
23-
this.(Modifiable).isAbstract()
24-
or
25-
this.getDeclaringType().(Modifiable).isAbstract() and this.(Virtualizable).isVirtual()
23+
exists(Modifiable m | m = [this.(Modifiable), this.(Accessor).getDeclaration()] |
24+
m.isAbstract()
25+
or
26+
this.getDeclaringType().(Modifiable).isAbstract() and m.(Virtualizable).isVirtual()
27+
)
2628
}
2729

2830
/** Gets a string representing, whether the summary should apply for all overrides of this. */

0 commit comments

Comments
 (0)