Skip to content

Commit e08c734

Browse files
committed
C#: Refactoring to allow override of the flow summaries reported by a test.
1 parent 55c17f4 commit e08c734

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,13 @@ module Private {
10041004
abstract class RelevantSummarizedCallable extends SummarizedCallable {
10051005
/** Gets the string representation of this callable used by `summary/1`. */
10061006
abstract string getCallableCsv();
1007+
1008+
/** Holds if flow is progated between `input` and `output` */
1009+
predicate relevantSummary(
1010+
SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
1011+
) {
1012+
this.propagatesFlow(input, output, preservesValue)
1013+
}
10071014
}
10081015

10091016
/** Render the kind in the format used in flow summaries. */
@@ -1023,7 +1030,7 @@ module Private {
10231030
RelevantSummarizedCallable c, SummaryComponentStack input, SummaryComponentStack output,
10241031
boolean preservesValue
10251032
|
1026-
c.propagatesFlow(input, output, preservesValue) and
1033+
c.relevantSummary(input, output, preservesValue) and
10271034
csv =
10281035
c.getCallableCsv() + ";;" + getComponentStackCsv(input) + ";" +
10291036
getComponentStackCsv(output) + ";" + renderKind(preservesValue)

csharp/ql/test/shared/FlowSummaries.qll

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ abstract class IncludeSummarizedCallable extends RelevantSummarizedCallable {
1616
)
1717
}
1818

19-
/* Gets a string representing, whether the declaring type is an interface. */
19+
predicate isAbstractOrInterface() {
20+
this.getDeclaringType() instanceof Interface or
21+
this.(Modifiable).isAbstract()
22+
}
23+
24+
/** Gets a string representing, whether the declaring type is an interface. */
2025
private string getCallableOverride() {
21-
if
22-
this.getDeclaringType() instanceof Interface or
23-
this.(Modifiable).isAbstract()
24-
then result = "true"
25-
else result = "false"
26+
if this.isAbstractOrInterface() then result = "true" else result = "false"
2627
}
2728

2829
/** Gets a string representing the callable in semi-colon separated format for use in flow summaries. */

0 commit comments

Comments
 (0)