C#: Refactoring to allow override of the flow summaries reported by a test.

This commit is contained in:
Michael Nebel
2021-12-01 15:15:30 +01:00
parent 55c17f453f
commit e08c734c40
2 changed files with 15 additions and 7 deletions

View File

@@ -1004,6 +1004,13 @@ module Private {
abstract class RelevantSummarizedCallable extends SummarizedCallable {
/** Gets the string representation of this callable used by `summary/1`. */
abstract string getCallableCsv();
/** Holds if flow is progated between `input` and `output` */
predicate relevantSummary(
SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
) {
this.propagatesFlow(input, output, preservesValue)
}
}
/** Render the kind in the format used in flow summaries. */
@@ -1023,7 +1030,7 @@ module Private {
RelevantSummarizedCallable c, SummaryComponentStack input, SummaryComponentStack output,
boolean preservesValue
|
c.propagatesFlow(input, output, preservesValue) and
c.relevantSummary(input, output, preservesValue) and
csv =
c.getCallableCsv() + ";;" + getComponentStackCsv(input) + ";" +
getComponentStackCsv(output) + ";" + renderKind(preservesValue)

View File

@@ -16,13 +16,14 @@ abstract class IncludeSummarizedCallable extends RelevantSummarizedCallable {
)
}
/* Gets a string representing, whether the declaring type is an interface. */
predicate isAbstractOrInterface() {
this.getDeclaringType() instanceof Interface or
this.(Modifiable).isAbstract()
}
/** Gets a string representing, whether the declaring type is an interface. */
private string getCallableOverride() {
if
this.getDeclaringType() instanceof Interface or
this.(Modifiable).isAbstract()
then result = "true"
else result = "false"
if this.isAbstractOrInterface() then result = "true" else result = "false"
}
/** Gets a string representing the callable in semi-colon separated format for use in flow summaries. */