FIR CFG: correct edge label from a node that returns Nothing
If it's not within a try/catch/finally, that should be an uncaught exception path. ^KT-45327 Fixed
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
d8fb54c6bd
commit
6427117a35
@@ -84,7 +84,7 @@ digraph initBlock_kt {
|
||||
20 -> {21};
|
||||
21 -> {22};
|
||||
22 -> {23};
|
||||
23 -> {28};
|
||||
23 -> {28} [label=onUncaughtException];
|
||||
23 -> {24} [style=dotted];
|
||||
24 -> {25} [style=dotted];
|
||||
25 -> {26} [style=dotted];
|
||||
|
||||
@@ -72,7 +72,7 @@ digraph jumps_kt {
|
||||
15 -> {16};
|
||||
16 -> {17};
|
||||
17 -> {18};
|
||||
18 -> {29};
|
||||
18 -> {29} [label=onUncaughtException];
|
||||
18 -> {19} [style=dotted];
|
||||
19 -> {20} [style=dotted];
|
||||
20 -> {21} [style=dotted];
|
||||
|
||||
@@ -63,7 +63,7 @@ digraph lambdaReturningObject_kt {
|
||||
}
|
||||
13 -> {14};
|
||||
14 -> {15};
|
||||
15 -> {20};
|
||||
15 -> {20} [label=onUncaughtException];
|
||||
15 -> {16} [style=dotted];
|
||||
16 -> {17} [style=dotted];
|
||||
17 -> {20 18} [style=dotted];
|
||||
|
||||
+4
-4
@@ -107,7 +107,7 @@ digraph propertiesAndInitBlocks_kt {
|
||||
41 -> {42};
|
||||
42 -> {43};
|
||||
43 -> {44};
|
||||
44 -> {47};
|
||||
44 -> {47} [label=onUncaughtException];
|
||||
44 -> {45} [style=dotted];
|
||||
45 -> {46} [style=dotted];
|
||||
46 -> {47} [style=dotted];
|
||||
@@ -138,7 +138,7 @@ digraph propertiesAndInitBlocks_kt {
|
||||
51 -> {52};
|
||||
52 -> {53};
|
||||
53 -> {54};
|
||||
54 -> {58};
|
||||
54 -> {58} [label=onUncaughtException];
|
||||
54 -> {55} [style=dotted];
|
||||
55 -> {56} [style=dotted];
|
||||
56 -> {57} [style=dotted];
|
||||
@@ -199,7 +199,7 @@ digraph propertiesAndInitBlocks_kt {
|
||||
70 -> {71};
|
||||
71 -> {72};
|
||||
72 -> {73};
|
||||
73 -> {76};
|
||||
73 -> {76} [label=onUncaughtException];
|
||||
73 -> {74} [style=dotted];
|
||||
74 -> {75} [style=dotted];
|
||||
75 -> {76} [style=dotted];
|
||||
@@ -246,7 +246,7 @@ digraph propertiesAndInitBlocks_kt {
|
||||
28 -> {48 34} [color=green];
|
||||
28 -> {48 34} [style=dashed];
|
||||
29 -> {30};
|
||||
30 -> {81};
|
||||
30 -> {81} [label=onUncaughtException];
|
||||
30 -> {31} [style=dotted];
|
||||
31 -> {32} [style=dotted];
|
||||
32 -> {33} [style=dotted];
|
||||
|
||||
+2
-1
@@ -204,7 +204,8 @@ digraph returnValuesFromLambda_kt {
|
||||
57 -> {65} [style=dashed];
|
||||
58 -> {60} [style=dotted];
|
||||
59 -> {60} [style=dotted];
|
||||
60 -> {64 61} [style=dotted];
|
||||
60 -> {61} [style=dotted];
|
||||
60 -> {64} [style=dotted] [label=onUncaughtException];
|
||||
61 -> {62} [style=dotted];
|
||||
62 -> {63} [style=dotted];
|
||||
63 -> {64} [style=dotted];
|
||||
|
||||
+8
-8
@@ -51,7 +51,7 @@ digraph jumpFromRhsOfOperator_kt {
|
||||
10 -> {15 11};
|
||||
11 -> {12};
|
||||
12 -> {13};
|
||||
13 -> {19};
|
||||
13 -> {19} [label=onUncaughtException];
|
||||
13 -> {14} [style=dotted];
|
||||
14 -> {15} [style=dotted];
|
||||
15 -> {16};
|
||||
@@ -93,7 +93,7 @@ digraph jumpFromRhsOfOperator_kt {
|
||||
26 -> {31 27};
|
||||
27 -> {28};
|
||||
28 -> {29};
|
||||
29 -> {35};
|
||||
29 -> {35} [label=onUncaughtException];
|
||||
29 -> {30} [style=dotted];
|
||||
30 -> {31} [style=dotted];
|
||||
31 -> {32};
|
||||
@@ -157,7 +157,7 @@ digraph jumpFromRhsOfOperator_kt {
|
||||
44 -> {49 45};
|
||||
45 -> {46};
|
||||
46 -> {47};
|
||||
47 -> {62};
|
||||
47 -> {62} [label=onUncaughtException];
|
||||
47 -> {48} [style=dotted];
|
||||
48 -> {49} [style=dotted];
|
||||
49 -> {50};
|
||||
@@ -230,7 +230,7 @@ digraph jumpFromRhsOfOperator_kt {
|
||||
71 -> {76 72};
|
||||
72 -> {73};
|
||||
73 -> {74};
|
||||
74 -> {89};
|
||||
74 -> {89} [label=onUncaughtException];
|
||||
74 -> {75} [style=dotted];
|
||||
75 -> {76} [style=dotted];
|
||||
76 -> {77};
|
||||
@@ -281,7 +281,7 @@ digraph jumpFromRhsOfOperator_kt {
|
||||
96 -> {101 97};
|
||||
97 -> {98};
|
||||
98 -> {99};
|
||||
99 -> {105};
|
||||
99 -> {105} [label=onUncaughtException];
|
||||
99 -> {100} [style=dotted];
|
||||
100 -> {101} [style=dotted];
|
||||
101 -> {102};
|
||||
@@ -323,7 +323,7 @@ digraph jumpFromRhsOfOperator_kt {
|
||||
112 -> {117 113};
|
||||
113 -> {114};
|
||||
114 -> {115};
|
||||
115 -> {121};
|
||||
115 -> {121} [label=onUncaughtException];
|
||||
115 -> {116} [style=dotted];
|
||||
116 -> {117} [style=dotted];
|
||||
117 -> {118};
|
||||
@@ -387,7 +387,7 @@ digraph jumpFromRhsOfOperator_kt {
|
||||
130 -> {135 131};
|
||||
131 -> {132};
|
||||
132 -> {133};
|
||||
133 -> {148};
|
||||
133 -> {148} [label=onUncaughtException];
|
||||
133 -> {134} [style=dotted];
|
||||
134 -> {135} [style=dotted];
|
||||
135 -> {136};
|
||||
@@ -460,7 +460,7 @@ digraph jumpFromRhsOfOperator_kt {
|
||||
157 -> {162 158};
|
||||
158 -> {159};
|
||||
159 -> {160};
|
||||
160 -> {175};
|
||||
160 -> {175} [label=onUncaughtException];
|
||||
160 -> {161} [style=dotted];
|
||||
161 -> {162} [style=dotted];
|
||||
162 -> {163};
|
||||
|
||||
+2
-1
@@ -286,7 +286,8 @@ digraph safeCalls_kt {
|
||||
92 -> {107} [style=dashed];
|
||||
93 -> {95} [style=dotted];
|
||||
94 -> {95} [style=dotted];
|
||||
95 -> {106 96} [style=dotted];
|
||||
95 -> {96} [style=dotted];
|
||||
95 -> {106} [style=dotted] [label=onUncaughtException];
|
||||
96 -> {97} [style=dotted];
|
||||
97 -> {98 102};
|
||||
98 -> {99};
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ digraph smartCastInInit_kt {
|
||||
}
|
||||
6 -> {7};
|
||||
7 -> {8};
|
||||
8 -> {13};
|
||||
8 -> {13} [label=onUncaughtException];
|
||||
8 -> {9} [style=dotted];
|
||||
9 -> {10} [style=dotted];
|
||||
10 -> {13 11} [style=dotted];
|
||||
|
||||
+6
-4
@@ -21,7 +21,7 @@ digraph smartcastToNothing_kt {
|
||||
0 -> {1};
|
||||
1 -> {2};
|
||||
2 -> {3};
|
||||
3 -> {8};
|
||||
3 -> {8} [label=onUncaughtException];
|
||||
3 -> {4} [style=dotted];
|
||||
4 -> {5} [style=dotted];
|
||||
5 -> {8 6} [style=dotted];
|
||||
@@ -273,16 +273,18 @@ digraph smartcastToNothing_kt {
|
||||
67 -> {68};
|
||||
68 -> {69};
|
||||
69 -> {70};
|
||||
70 -> {101};
|
||||
70 -> {101} [label=onUncaughtException];
|
||||
70 -> {71} [style=dotted];
|
||||
71 -> {72} [style=dotted];
|
||||
72 -> {73} [style=dotted];
|
||||
73 -> {101 74} [style=dotted];
|
||||
73 -> {74} [style=dotted];
|
||||
73 -> {101} [style=dotted] [label=onUncaughtException];
|
||||
74 -> {75} [style=dotted];
|
||||
75 -> {76} [style=dotted];
|
||||
76 -> {77} [style=dotted];
|
||||
77 -> {78} [style=dotted];
|
||||
78 -> {101 79} [style=dotted];
|
||||
78 -> {79} [style=dotted];
|
||||
78 -> {101} [style=dotted] [label=onUncaughtException];
|
||||
79 -> {80} [style=dotted];
|
||||
80 -> {81} [style=dotted];
|
||||
81 -> {83 82} [style=dotted];
|
||||
|
||||
+7
-4
@@ -1249,14 +1249,17 @@ class ControlFlowGraphBuilder {
|
||||
|
||||
private fun addNodeThatReturnsNothing(node: CFGNode<*>, preferredKind: EdgeKind = EdgeKind.Forward) {
|
||||
val exitNode: CFGNode<*> = exitTargetsForTry.top()
|
||||
addNodeWithJump(node, exitNode, preferredKind)
|
||||
// If an expression, which returns Nothing, isn't inside a try/catch/finally, that is an uncaught exception path.
|
||||
val label = if (tryExitNodes.isEmpty) UncaughtExceptionPath else NormalPath
|
||||
addNodeWithJump(node, exitNode, preferredKind, label = label)
|
||||
}
|
||||
|
||||
private fun addNodeWithJump(
|
||||
node: CFGNode<*>,
|
||||
targetNode: CFGNode<*>?,
|
||||
preferredKind: EdgeKind = EdgeKind.Forward,
|
||||
isBack: Boolean = false
|
||||
isBack: Boolean = false,
|
||||
label: EdgeLabel = NormalPath,
|
||||
) {
|
||||
popAndAddEdge(node, preferredKind)
|
||||
if (targetNode != null) {
|
||||
@@ -1265,10 +1268,10 @@ class ControlFlowGraphBuilder {
|
||||
// `continue` to the loop header
|
||||
addBackEdge(node, targetNode, label = LoopBackPath)
|
||||
} else {
|
||||
addBackEdge(node, targetNode)
|
||||
addBackEdge(node, targetNode, label = label)
|
||||
}
|
||||
} else {
|
||||
addEdge(node, targetNode, propagateDeadness = false)
|
||||
addEdge(node, targetNode, propagateDeadness = false, label = label)
|
||||
}
|
||||
}
|
||||
val stub = createStubNode()
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import java.io.File
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
object Main {
|
||||
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>private val KOTLIN_HOME: File<!>
|
||||
|
||||
init {
|
||||
val home = System.getProperty("kotlin.home")
|
||||
if (home == null) {
|
||||
exitProcess(1)
|
||||
}
|
||||
KOTLIN_HOME = File(home)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import java.io.File
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
Reference in New Issue
Block a user