Skip to content

Commit

Permalink
Remove useless stuff from ControlflowSensitiveDFGPass
Browse files Browse the repository at this point in the history
  • Loading branch information
KuechA committed Oct 24, 2024
1 parent 467c6f5 commit 6d6af25
Showing 1 changed file with 7 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,18 +363,19 @@ open class ControlFlowSensitiveDFGPass(ctx: TranslationContext) : EOGStarterPass
}
} else if (currentNode is ComprehensionExpression) {
val iterable = currentNode.iterable as? Expression
val (writtenTo, writtenTo2) =
val writtenTo =
when (val variable = currentNode.variable) {
is DeclarationStatement -> {
if (variable.isSingleDeclaration()) {
Pair(variable.singleDeclaration, null)
} else if (variable.declarations.size == 2) {
Pair(variable.declarations.first(), variable.declarations.last())
variable.singleDeclaration

Check warning on line 370 in cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt

View check run for this annotation

Codecov / codecov/patch

cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt#L370

Added line #L370 was not covered by tests
} else {
Pair(null, null)
log.error(
"Cannot handle multiple declarations in the ComprehensionExpresdsion: Node $currentNode"

Check warning on line 373 in cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt

View check run for this annotation

Codecov / codecov/patch

cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt#L372-L373

Added lines #L372 - L373 were not covered by tests
)
null

Check warning on line 375 in cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt

View check run for this annotation

Codecov / codecov/patch

cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/ControlFlowSensitiveDFGPass.kt#L375

Added line #L375 was not covered by tests
}
}
else -> Pair(currentNode.variable, null)
else -> currentNode.variable
}
// We wrote something to this variable declaration
writtenTo?.let {
Expand All @@ -398,27 +399,6 @@ open class ControlFlowSensitiveDFGPass(ctx: TranslationContext) : EOGStarterPass
PowersetLattice(identitySetOf(writtenTo))
}
}
writtenTo2?.let {
val writtenDeclaration2 =
when (writtenTo2) {
is Declaration -> writtenTo2
is Reference -> writtenTo2.refersTo
else -> {
log.error(
"The variable of type ${writtenTo2.javaClass} is not yet supported in the ComprehensionExpression"
)
null
}
}

iterable?.let {
state.push(writtenTo2, PowersetLattice(identitySetOf(iterable)))
// Add the variable declaration (or the reference) to the list of previous
// write nodes in this path
state.declarationsState[writtenDeclaration2] =
PowersetLattice(identitySetOf(writtenTo2))
}
}
} else if (currentNode is ForEachStatement && currentNode.variable != null) {
// The VariableDeclaration in the ForEachStatement doesn't have an initializer, so
// the "normal" case won't work. We handle this case separately here...
Expand Down

0 comments on commit 6d6af25

Please sign in to comment.