Skip to content

Commit

Permalink
test coverage++
Browse files Browse the repository at this point in the history
  • Loading branch information
KuechA committed Mar 18, 2024
1 parent 8d1b686 commit 43ffd46
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,24 +391,32 @@ open class ControlFlowSensitiveDFGPass(ctx: TranslationContext) : EOGStarterPass
PowersetLattice(identitySetOf(currentNode))
)
} else if (currentNode is CallExpression) {
for (invoked in
val functionsWithSummaries =
currentNode.invokes.filter {
it in ctx.config.functionSummaries.functionToChangedParameters
}) {
val changedParams =
ctx.config.functionSummaries.functionToChangedParameters[invoked] ?: mapOf()
for ((param, _) in changedParams) {
if (param == (invoked as? MethodDeclaration)?.receiver) {
doubleState.declarationsState[
((currentNode as? MemberCallExpression)?.base as? Reference)
?.refersTo] = PowersetLattice(identitySetOf(param))
} else if (param is ParameterDeclaration) {
val arg = currentNode.arguments[param.argumentIndex]
doubleState.declarationsState[(arg as? Reference)?.refersTo] =
PowersetLattice(identitySetOf(param))
}
if (functionsWithSummaries.isNotEmpty()) {
for (invoked in functionsWithSummaries) {
val changedParams =
ctx.config.functionSummaries.functionToChangedParameters[invoked] ?: mapOf()
for ((param, _) in changedParams) {
if (param == (invoked as? MethodDeclaration)?.receiver) {
doubleState.declarationsState[
((currentNode as? MemberCallExpression)?.base as? Reference)
?.refersTo] = PowersetLattice(identitySetOf(param))
} else if (param is ParameterDeclaration) {
val arg = currentNode.arguments[param.argumentIndex]
doubleState.declarationsState[(arg as? Reference)?.refersTo] =
PowersetLattice(identitySetOf(param))
}
edgePropertiesMap[param] = CallingContextOut(currentNode)
}
edgePropertiesMap[param] = CallingContextOut(currentNode)
}
} else {
doubleState.declarationsState.push(
currentNode,
doubleState.declarationsState[currentEdge.start]
)
}
} else {
doubleState.declarationsState.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,15 @@ class DFGFunctionSummariesTest {
construct("test.Object")
}

memberCall("addAll", construct("test.List")) {
declare {
variable("a", t("test.List")) { construct("test.List") }
}

memberCall("addAll", ref("a", t("test.List"))) {
literal(1, t("int"))
construct("test.Object")
}
call("print") { ref("a", t("test.List")) }

memberCall("addAll", construct("random.Type")) {
literal(1, t("int"))
Expand Down

0 comments on commit 43ffd46

Please sign in to comment.