[FIR] Create CFG for files to track top-level property initialization

In order to properly analyze top-level property initialization, a
control-flow graph must be created for FirFiles. This change adds the
foundation for the file CFG and updates body resolve to create the CFG.
Checking the CFG for proper initialization is separated into a following
change to ease code review.

KT-56683
This commit is contained in:
Brian Norman
2023-07-25 10:23:22 -05:00
committed by Space Team
parent 0b7eb32064
commit b55fda0c55
127 changed files with 19565 additions and 18746 deletions
@@ -5,102 +5,109 @@ digraph nestedClass_kt {
subgraph cluster_0 {
color=red
0 [label="Enter class OuterClass" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter property" style="filled" fillcolor=red];
2 [label="Const: Int(1)"];
3 [label="Exit property" style="filled" fillcolor=red];
}
0 [label="Enter file nestedClass.kt" style="filled" fillcolor=red];
1 [label="Exit file nestedClass.kt" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
subgraph cluster_1 {
color=red
2 [label="Enter class OuterClass" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
4 [label="Enter property" style="filled" fillcolor=red];
5 [label="Access variable R|/OuterClass.outerProperty|"];
6 [label="Exit property" style="filled" fillcolor=red];
3 [label="Enter property" style="filled" fillcolor=red];
4 [label="Const: Int(1)"];
5 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_3 {
color=blue
7 [label="Enter function <init>" style="filled" fillcolor=red];
8 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
9 [label="Exit function <init>" style="filled" fillcolor=red];
6 [label="Enter property" style="filled" fillcolor=red];
7 [label="Access variable R|/OuterClass.outerProperty|"];
8 [label="Exit property" style="filled" fillcolor=red];
}
10 [label="Exit class OuterClass" style="filled" fillcolor=red];
subgraph cluster_4 {
color=blue
9 [label="Enter function <init>" style="filled" fillcolor=red];
10 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
11 [label="Exit function <init>" style="filled" fillcolor=red];
}
12 [label="Exit class OuterClass" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
0 -> {10} [style=dotted];
0 -> {1 4 7} [style=dashed];
1 -> {2};
2 -> {3};
3 -> {4} [color=green];
2 -> {3} [color=green];
2 -> {12} [style=dotted];
2 -> {3 6 9} [style=dashed];
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {7} [color=green];
5 -> {6} [color=green];
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10} [color=green];
8 -> {9} [color=green];
9 -> {10};
10 -> {11};
11 -> {12} [color=green];
subgraph cluster_4 {
subgraph cluster_5 {
color=red
11 [label="Enter function outerFunction" style="filled" fillcolor=red];
subgraph cluster_5 {
13 [label="Enter function outerFunction" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
12 [label="Enter block"];
13 [label="Exit block"];
14 [label="Enter block"];
15 [label="Exit block"];
}
14 [label="Exit function outerFunction" style="filled" fillcolor=red];
16 [label="Exit function outerFunction" style="filled" fillcolor=red];
}
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
subgraph cluster_6 {
subgraph cluster_7 {
color=red
15 [label="Enter class NestedClass" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
16 [label="Enter property" style="filled" fillcolor=red];
17 [label="Const: Int(1)"];
18 [label="Exit property" style="filled" fillcolor=red];
}
17 [label="Enter class NestedClass" style="filled" fillcolor=red];
subgraph cluster_8 {
color=blue
19 [label="Enter property" style="filled" fillcolor=red];
20 [label="Access variable R|/OuterClass.NestedClass.nestedProperty|"];
21 [label="Exit property" style="filled" fillcolor=red];
18 [label="Enter property" style="filled" fillcolor=red];
19 [label="Const: Int(1)"];
20 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_9 {
color=blue
22 [label="Enter function <init>" style="filled" fillcolor=red];
23 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
24 [label="Exit function <init>" style="filled" fillcolor=red];
21 [label="Enter property" style="filled" fillcolor=red];
22 [label="Access variable R|/OuterClass.NestedClass.nestedProperty|"];
23 [label="Exit property" style="filled" fillcolor=red];
}
25 [label="Exit class NestedClass" style="filled" fillcolor=red];
}
15 -> {16} [color=green];
15 -> {25} [style=dotted];
15 -> {16 19 22} [style=dashed];
16 -> {17};
17 -> {18};
18 -> {19} [color=green];
19 -> {20};
20 -> {21};
21 -> {22} [color=green];
22 -> {23};
23 -> {24};
24 -> {25} [color=green];
subgraph cluster_10 {
color=red
26 [label="Enter function nestedFUnction" style="filled" fillcolor=red];
subgraph cluster_11 {
subgraph cluster_10 {
color=blue
27 [label="Enter block"];
28 [label="Exit block"];
24 [label="Enter function <init>" style="filled" fillcolor=red];
25 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
26 [label="Exit function <init>" style="filled" fillcolor=red];
}
29 [label="Exit function nestedFUnction" style="filled" fillcolor=red];
27 [label="Exit class NestedClass" style="filled" fillcolor=red];
}
17 -> {18} [color=green];
17 -> {27} [style=dotted];
17 -> {18 21 24} [style=dashed];
18 -> {19};
19 -> {20};
20 -> {21} [color=green];
21 -> {22};
22 -> {23};
23 -> {24} [color=green];
24 -> {25};
25 -> {26};
26 -> {27} [color=green];
subgraph cluster_11 {
color=red
28 [label="Enter function nestedFUnction" style="filled" fillcolor=red];
subgraph cluster_12 {
color=blue
29 [label="Enter block"];
30 [label="Exit block"];
}
31 [label="Exit function nestedFUnction" style="filled" fillcolor=red];
}
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
}