[FIR] Fix collectDataForNode backward traverse
This commit is contained in:
committed by
Mikhail Glukhikh
parent
f9c7cce11d
commit
acbb67f851
@@ -55,6 +55,9 @@ private fun <I : ControlFlowInfo<I, K, V>, K : Any, V : Any> ControlFlowGraph.co
|
||||
) {
|
||||
val nodes = getNodesInOrder(direction)
|
||||
for (node in nodes) {
|
||||
if (direction == TraverseDirection.Backward && node is CFGNodeWithCfgOwner<*>) {
|
||||
node.subGraphs.forEach { it.collectDataForNodeInternal(direction, initialInfo, visitor, nodeMap, changed) }
|
||||
}
|
||||
if (!(node.isEnterNode(direction) && node.owner.owner == null)) {
|
||||
val previousNodes = when (direction) {
|
||||
TraverseDirection.Forward -> node.previousCfgNodes
|
||||
@@ -69,7 +72,7 @@ private fun <I : ControlFlowInfo<I, K, V>, K : Any, V : Any> ControlFlowGraph.co
|
||||
nodeMap[node] = newData
|
||||
}
|
||||
}
|
||||
if (node is CFGNodeWithCfgOwner<*>) {
|
||||
if (direction == TraverseDirection.Forward && node is CFGNodeWithCfgOwner<*>) {
|
||||
node.subGraphs.forEach { it.collectDataForNodeInternal(direction, initialInfo, visitor, nodeMap, changed) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.analysis.cfa
|
||||
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNodeWithCfgOwner
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ControlFlowGraph
|
||||
|
||||
fun ControlFlowGraph.getEnterNode(direction: TraverseDirection): CFGNode<*> = when (direction) {
|
||||
@@ -34,7 +35,14 @@ val CFGNode<*>.previousCfgNodes: List<CFGNode<*>>
|
||||
}
|
||||
|
||||
val CFGNode<*>.followingCfgNodes: List<CFGNode<*>>
|
||||
get() = followingNodes.filter {
|
||||
val kind = outgoingEdges.getValue(it)
|
||||
kind.usedInCfa && !kind.isDead
|
||||
get() {
|
||||
val nodes = mutableListOf<CFGNode<*>>()
|
||||
|
||||
followingNodes.filterTo(nodes) {
|
||||
val kind = outgoingEdges.getValue(it)
|
||||
kind.usedInCfa && !kind.isDead
|
||||
}
|
||||
(this as? CFGNodeWithCfgOwner<*>)?.subGraphs?.mapTo(nodes) { it.enterNode }
|
||||
|
||||
return nodes
|
||||
}
|
||||
Reference in New Issue
Block a user