FIR CFA: keep UncaughtExceptionPath separated
This commit is contained in:
committed by
TeamCityServer
parent
06a80c0b34
commit
d27ecca0e9
+17
-7
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.fir.analysis.cfa
|
|||||||
|
|
||||||
import kotlinx.collections.immutable.PersistentMap
|
import kotlinx.collections.immutable.PersistentMap
|
||||||
import kotlinx.collections.immutable.persistentMapOf
|
import kotlinx.collections.immutable.persistentMapOf
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode
|
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.EdgeLabel
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.NormalPath
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.TryExpressionExitNode
|
|
||||||
|
|
||||||
abstract class PathAwareControlFlowInfo<P : PathAwareControlFlowInfo<P, S>, S : ControlFlowInfo<S, *, *>>(
|
abstract class PathAwareControlFlowInfo<P : PathAwareControlFlowInfo<P, S>, S : ControlFlowInfo<S, *, *>>(
|
||||||
map: PersistentMap<EdgeLabel, S>,
|
map: PersistentMap<EdgeLabel, S>,
|
||||||
@@ -43,11 +40,24 @@ abstract class PathAwareControlFlowInfo<P : PathAwareControlFlowInfo<P, S>, S :
|
|||||||
|
|
||||||
val hasAbnormalLabels = map.keys.any { !it.isNormal }
|
val hasAbnormalLabels = map.keys.any { !it.isNormal }
|
||||||
return if (hasAbnormalLabels) {
|
return if (hasAbnormalLabels) {
|
||||||
// { |-> ... l1 |-> I1, l2 |-> I2, ... }
|
// { |-> ..., l1 |-> I1, l2 |-> I2, ... }
|
||||||
// | l1 // path exit: if the given info has non-null labels, this acts like a filtering
|
// | l1 // path exit: if the given info has non-null labels, this acts like a filtering
|
||||||
// { |-> I1 } // NB: remove the path info
|
// { |-> I1 } // NB: remove the path label, except for uncaught exception path
|
||||||
if (map.keys.contains(label)) {
|
if (map.keys.contains(label)) {
|
||||||
constructor(persistentMapOf(NormalPath to map[label]!!))
|
if (label == UncaughtExceptionPath) {
|
||||||
|
// Special case: uncaught exception path, which still represents an uncaught exception path
|
||||||
|
// Target node is most likely fun/init exit, and we should keep info separated.
|
||||||
|
constructor(persistentMapOf(label to map[label]!!))
|
||||||
|
} else {
|
||||||
|
// { |-> I }
|
||||||
|
// | l1 // e.g., enter to proxy1 with l1
|
||||||
|
// { l1 -> I }
|
||||||
|
// ...
|
||||||
|
// { |-> ..., l1 -> I', ... }
|
||||||
|
// | l1 // e.g., exit proxy1 with l1
|
||||||
|
// { l1 -> I' }
|
||||||
|
constructor(persistentMapOf(NormalPath to map[label]!!))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* This means no info for the specific label. */
|
/* This means no info for the specific label. */
|
||||||
empty()
|
empty()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ object ThrowInTryWithCatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object ThrowInTryWithCatchAndFinally {
|
object ThrowInTryWithCatchAndFinally {
|
||||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
private val p: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
try {
|
try {
|
||||||
@@ -53,7 +53,7 @@ object RethrowInCatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object RethrowInCatchWithFinally {
|
object RethrowInCatchWithFinally {
|
||||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
private val p: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
try {
|
try {
|
||||||
@@ -134,7 +134,7 @@ object InnerCatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object InnerCatchWithFinally {
|
object InnerCatchWithFinally {
|
||||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
private val p: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
try {
|
try {
|
||||||
@@ -169,7 +169,7 @@ object InnerCatchOuterRethrow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object InnerCatchOuterRethrowWithFinally {
|
object InnerCatchOuterRethrowWithFinally {
|
||||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val p: String<!>
|
private val p: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user