Skip to content

Commit 4a68b74

Browse files
committed
C#: Re-use the asPartialModel for DataFlowPrivate in tests.
1 parent 115cef2 commit 4a68b74

File tree

6 files changed

+8
-39
lines changed

6 files changed

+8
-39
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,7 @@ module Csv {
20462046
}
20472047

20482048
/** Holds if the summary should apply for all overrides of this. */
2049-
private predicate isBaseCallableOrPrototype(DataFlowCallable c) {
2049+
predicate isBaseCallableOrPrototype(DataFlowCallable c) {
20502050
c.getDeclaringType() instanceof Interface
20512051
or
20522052
exists(Modifiable m | m = [c.(Modifiable), c.(Accessor).getDeclaration()] |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ module Private {
10561056
|
10571057
c.relevantSummary(input, output, preservesValue) and
10581058
csv =
1059-
c.getCallableCsv() + ";;" + getComponentStackCsv(input) + ";" +
1059+
c.getCallableCsv() + ";" + getComponentStackCsv(input) + ";" +
10601060
getComponentStackCsv(output) + ";" + renderKind(preservesValue)
10611061
)
10621062
}

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

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

45
class IncludeFilteredSummarizedCallable extends IncludeSummarizedCallable {
@@ -14,7 +15,7 @@ class IncludeFilteredSummarizedCallable extends IncludeSummarizedCallable {
1415
) {
1516
this.propagatesFlow(input, output, preservesValue) and
1617
not exists(IncludeSummarizedCallable rsc |
17-
rsc.isBaseCallableOrPrototype() and
18+
isBaseCallableOrPrototype(rsc) and
1819
rsc.propagatesFlow(input, output, preservesValue) and
1920
this.(UnboundCallable).overridesOrImplementsUnbound(rsc)
2021
)
Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,12 @@
11
import semmle.code.csharp.dataflow.FlowSummary
22
import semmle.code.csharp.dataflow.internal.FlowSummaryImpl::Private::TestOutput
3+
private import semmle.code.csharp.dataflow.internal.DataFlowPrivate
34

45
abstract class IncludeSummarizedCallable extends RelevantSummarizedCallable {
56
IncludeSummarizedCallable() {
67
[this.(Modifiable), this.(Accessor).getDeclaration()].isEffectivelyPublic()
78
}
89

9-
/** Gets the qualified parameter types of this callable as a comma-separated string. */
10-
private string parameterQualifiedTypeNamesToString() {
11-
result =
12-
concat(Parameter p, int i |
13-
p = this.getParameter(i)
14-
|
15-
p.getType().getQualifiedName(), "," order by i
16-
)
17-
}
18-
19-
/** Holds if the summary should apply for all overrides of this. */
20-
predicate isBaseCallableOrPrototype() {
21-
this.getDeclaringType() instanceof Interface
22-
or
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-
)
28-
}
29-
30-
/** Gets a string representing whether the summary should apply for all overrides of this. */
31-
private string getCallableOverride() {
32-
if this.isBaseCallableOrPrototype() then result = "true" else result = "false"
33-
}
34-
3510
/** Gets a string representing the callable in semi-colon separated format for use in flow summaries. */
36-
final override string getCallableCsv() {
37-
exists(string namespace, string type |
38-
this.getDeclaringType().hasQualifiedName(namespace, type) and
39-
result =
40-
namespace + ";" + type + ";" + this.getCallableOverride() + ";" + this.getName() + ";" + "("
41-
+ this.parameterQualifiedTypeNamesToString() + ")"
42-
)
43-
}
11+
final override string getCallableCsv() { result = Csv::asPartialModel(this) }
4412
}

java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ module Private {
10561056
|
10571057
c.relevantSummary(input, output, preservesValue) and
10581058
csv =
1059-
c.getCallableCsv() + ";;" + getComponentStackCsv(input) + ";" +
1059+
c.getCallableCsv() + ";" + getComponentStackCsv(input) + ";" +
10601060
getComponentStackCsv(output) + ";" + renderKind(preservesValue)
10611061
)
10621062
}

ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ module Private {
10561056
|
10571057
c.relevantSummary(input, output, preservesValue) and
10581058
csv =
1059-
c.getCallableCsv() + ";;" + getComponentStackCsv(input) + ";" +
1059+
c.getCallableCsv() + ";" + getComponentStackCsv(input) + ";" +
10601060
getComponentStackCsv(output) + ";" + renderKind(preservesValue)
10611061
)
10621062
}

0 commit comments

Comments
 (0)