[FIR] Fix CFG building for secondary constructor with delegation
This commit is contained in:
+32
-38
@@ -17,81 +17,75 @@ digraph secondaryConstructorCfg_kt {
|
|||||||
20 [label="Enter function <init>" style="filled" fillcolor=red];
|
20 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||||
22 [label="Access variable R|<local>/p0|"];
|
22 [label="Access variable R|<local>/p0|"];
|
||||||
23 [label="Delegated constructor call: this<R|B|>(...)"];
|
23 [label="Delegated constructor call: this<R|B|>(...)"];
|
||||||
subgraph cluster_2 {
|
24 [label="Access variable R|<local>/p1|"];
|
||||||
color=blue
|
25 [label="Assignment: R|/B.p3|"];
|
||||||
24 [label="Enter block"];
|
21 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||||
25 [label="Access variable R|<local>/p1|"];
|
|
||||||
26 [label="Assignment: R|/B.p3|"];
|
|
||||||
27 [label="Exit block"];
|
|
||||||
}
|
|
||||||
21 [label="Exit function <init>" style="filled" fillcolor=red style="filled" fillcolor=gray];
|
|
||||||
}
|
}
|
||||||
20 -> {22};
|
20 -> {22};
|
||||||
22 -> {23};
|
22 -> {23};
|
||||||
23 -> {24};
|
23 -> {24};
|
||||||
24 -> {25};
|
24 -> {25};
|
||||||
25 -> {26};
|
25 -> {21};
|
||||||
26 -> {27};
|
|
||||||
|
|
||||||
subgraph cluster_3 {
|
subgraph cluster_2 {
|
||||||
color=red
|
color=red
|
||||||
37 [label="Enter class B" style="filled" fillcolor=red];
|
35 [label="Enter class B" style="filled" fillcolor=red];
|
||||||
subgraph cluster_4 {
|
subgraph cluster_3 {
|
||||||
color=blue
|
color=blue
|
||||||
16 [label="Enter function setter" style="filled" fillcolor=red];
|
16 [label="Enter function setter" style="filled" fillcolor=red];
|
||||||
17 [label="Exit function setter" style="filled" fillcolor=red];
|
17 [label="Exit function setter" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
subgraph cluster_5 {
|
subgraph cluster_4 {
|
||||||
color=blue
|
color=blue
|
||||||
14 [label="Enter function getter" style="filled" fillcolor=red];
|
14 [label="Enter function getter" style="filled" fillcolor=red];
|
||||||
15 [label="Exit function getter" style="filled" fillcolor=red];
|
15 [label="Exit function getter" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
subgraph cluster_6 {
|
subgraph cluster_5 {
|
||||||
color=blue
|
color=blue
|
||||||
8 [label="Enter function getter" style="filled" fillcolor=red];
|
8 [label="Enter function getter" style="filled" fillcolor=red];
|
||||||
9 [label="Exit function getter" style="filled" fillcolor=red];
|
9 [label="Exit function getter" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
subgraph cluster_7 {
|
subgraph cluster_6 {
|
||||||
color=blue
|
color=blue
|
||||||
3 [label="Enter function getter" style="filled" fillcolor=red];
|
3 [label="Enter function getter" style="filled" fillcolor=red];
|
||||||
4 [label="Exit function getter" style="filled" fillcolor=red];
|
4 [label="Exit function getter" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
subgraph cluster_8 {
|
subgraph cluster_7 {
|
||||||
color=blue
|
color=blue
|
||||||
5 [label="Enter property" style="filled" fillcolor=red];
|
5 [label="Enter property" style="filled" fillcolor=red];
|
||||||
7 [label="Access variable R|<local>/p0|"];
|
7 [label="Access variable R|<local>/p0|"];
|
||||||
6 [label="Exit property" style="filled" fillcolor=red];
|
6 [label="Exit property" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
subgraph cluster_9 {
|
subgraph cluster_8 {
|
||||||
color=blue
|
color=blue
|
||||||
10 [label="Enter property" style="filled" fillcolor=red];
|
10 [label="Enter property" style="filled" fillcolor=red];
|
||||||
12 [label="Access variable R|<local>/p0|"];
|
12 [label="Access variable R|<local>/p0|"];
|
||||||
13 [label="Access variable R|kotlin/String.length|"];
|
13 [label="Access variable R|kotlin/String.length|"];
|
||||||
11 [label="Exit property" style="filled" fillcolor=red];
|
11 [label="Exit property" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
subgraph cluster_10 {
|
subgraph cluster_9 {
|
||||||
color=blue
|
color=blue
|
||||||
18 [label="Enter property" style="filled" fillcolor=red];
|
18 [label="Enter property" style="filled" fillcolor=red];
|
||||||
19 [label="Exit property" style="filled" fillcolor=red];
|
19 [label="Exit property" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
subgraph cluster_11 {
|
subgraph cluster_10 {
|
||||||
color=blue
|
color=blue
|
||||||
28 [label="Enter init block" style="filled" fillcolor=red];
|
26 [label="Enter init block" style="filled" fillcolor=red];
|
||||||
subgraph cluster_12 {
|
subgraph cluster_11 {
|
||||||
color=blue
|
color=blue
|
||||||
30 [label="Enter block"];
|
28 [label="Enter block"];
|
||||||
31 [label="Access variable R|<local>/p0|"];
|
29 [label="Access variable R|<local>/p0|"];
|
||||||
32 [label="Access variable R|kotlin/String.length|"];
|
30 [label="Access variable R|kotlin/String.length|"];
|
||||||
33 [label="Assignment: R|/B.p1|"];
|
31 [label="Assignment: R|/B.p1|"];
|
||||||
34 [label="Const: String()"];
|
32 [label="Const: String()"];
|
||||||
35 [label="Assignment: R|/B.p3|"];
|
33 [label="Assignment: R|/B.p3|"];
|
||||||
36 [label="Exit block"];
|
34 [label="Exit block"];
|
||||||
}
|
}
|
||||||
29 [label="Exit init block" style="filled" fillcolor=red];
|
27 [label="Exit init block" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
38 [label="Exit class B" style="filled" fillcolor=red];
|
36 [label="Exit class B" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
37 -> {5} [color=green];
|
35 -> {5} [color=green];
|
||||||
5 -> {7};
|
5 -> {7};
|
||||||
6 -> {10} [color=green];
|
6 -> {10} [color=green];
|
||||||
7 -> {6};
|
7 -> {6};
|
||||||
@@ -102,17 +96,17 @@ digraph secondaryConstructorCfg_kt {
|
|||||||
13 -> {11};
|
13 -> {11};
|
||||||
8 -> {9};
|
8 -> {9};
|
||||||
18 -> {19};
|
18 -> {19};
|
||||||
19 -> {28} [color=green];
|
19 -> {26} [color=green];
|
||||||
14 -> {15};
|
14 -> {15};
|
||||||
16 -> {17};
|
16 -> {17};
|
||||||
28 -> {30};
|
26 -> {28};
|
||||||
29 -> {38} [color=green];
|
27 -> {36} [color=green];
|
||||||
|
28 -> {29};
|
||||||
|
29 -> {30};
|
||||||
30 -> {31};
|
30 -> {31};
|
||||||
31 -> {32};
|
31 -> {32};
|
||||||
32 -> {33};
|
32 -> {33};
|
||||||
33 -> {34};
|
33 -> {34};
|
||||||
34 -> {35};
|
34 -> {27};
|
||||||
35 -> {36};
|
|
||||||
36 -> {29};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-6
@@ -305,13 +305,20 @@ class ControlFlowGraphBuilder {
|
|||||||
// ----------------------------------- Block -----------------------------------
|
// ----------------------------------- Block -----------------------------------
|
||||||
|
|
||||||
fun enterBlock(block: FirBlock): BlockEnterNode? {
|
fun enterBlock(block: FirBlock): BlockEnterNode? {
|
||||||
val lastNode = lastNode
|
when (val lastNode = lastNode) {
|
||||||
return if (lastNode is FunctionEnterNode) {
|
is FunctionEnterNode -> {
|
||||||
blocksOfFunctions[block] = lastNode.fir
|
blocksOfFunctions[block] = lastNode.fir
|
||||||
null
|
return null
|
||||||
} else {
|
}
|
||||||
createBlockEnterNode(block).also { addNewSimpleNode(it) }.also { levelCounter++ }
|
is DelegatedConstructorCallNode -> {
|
||||||
|
val ownerEnterNode = lastNode.owner.enterNode
|
||||||
|
if (ownerEnterNode is FunctionEnterNode) {
|
||||||
|
blocksOfFunctions[block] = ownerEnterNode.fir
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return createBlockEnterNode(block).also { addNewSimpleNode(it) }.also { levelCounter++ }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitBlock(block: FirBlock): CFGNode<*> {
|
fun exitBlock(block: FirBlock): CFGNode<*> {
|
||||||
|
|||||||
Reference in New Issue
Block a user