[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,99 +5,104 @@ digraph initializationInTry_kt {
subgraph cluster_0 {
color=red
0 [label="Enter function getNullableString" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter block"];
2 [label="Const: Null(null)"];
3 [label="Jump: ^getNullableString Null(null)"];
4 [label="Stub" style="filled" fillcolor=gray];
5 [label="Exit block" style="filled" fillcolor=gray];
}
6 [label="Exit function getNullableString" style="filled" fillcolor=red];
0 [label="Enter file initializationInTry.kt" style="filled" fillcolor=red];
1 [label="Exit file initializationInTry.kt" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
subgraph cluster_1 {
color=red
2 [label="Enter function getNullableString" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
3 [label="Enter block"];
4 [label="Const: Null(null)"];
5 [label="Jump: ^getNullableString Null(null)"];
6 [label="Stub" style="filled" fillcolor=gray];
7 [label="Exit block" style="filled" fillcolor=gray];
}
8 [label="Exit function getNullableString" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {6};
3 -> {4} [style=dotted];
4 -> {5} [style=dotted];
3 -> {4};
4 -> {5};
5 -> {8};
5 -> {6} [style=dotted];
6 -> {7} [style=dotted];
7 -> {8} [style=dotted];
subgraph cluster_2 {
subgraph cluster_3 {
color=red
7 [label="Enter function takeNullableString" style="filled" fillcolor=red];
subgraph cluster_3 {
9 [label="Enter function takeNullableString" style="filled" fillcolor=red];
subgraph cluster_4 {
color=blue
8 [label="Enter block"];
9 [label="Exit block"];
10 [label="Enter block"];
11 [label="Exit block"];
}
10 [label="Exit function takeNullableString" style="filled" fillcolor=red];
12 [label="Exit function takeNullableString" style="filled" fillcolor=red];
}
7 -> {8};
8 -> {9};
9 -> {10};
subgraph cluster_4 {
color=red
11 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
12 [label="Enter block"];
13 [label="Variable declaration: lval x: R|kotlin/String?|"];
subgraph cluster_6 {
color=blue
14 [label="Try expression enter"];
subgraph cluster_7 {
color=blue
15 [label="Try main block enter"];
subgraph cluster_8 {
color=blue
16 [label="Enter block"];
17 [label="Function call: R|/getNullableString|()" style="filled" fillcolor=yellow];
18 [label="Check not null: R|/getNullableString|()!!" style="filled" fillcolor=yellow];
19 [label="Variable declaration: lval y: R|kotlin/String|"];
20 [label="Function call: R|/getNullableString|()" style="filled" fillcolor=yellow];
21 [label="Assignment: R|<local>/x|"];
22 [label="Exit block"];
}
23 [label="Try main block exit"];
}
subgraph cluster_9 {
color=blue
24 [label="Enter finally"];
subgraph cluster_10 {
color=blue
25 [label="Enter block"];
26 [label="Access qualifier kotlin/Unit"];
27 [label="Exit block"];
}
28 [label="Exit finally"];
}
29 [label="Try expression exit"];
}
30 [label="Access variable R|<local>/x|"];
31 [label="Function call: R|/takeNullableString|(...)" style="filled" fillcolor=yellow];
32 [label="Exit block"];
}
33 [label="Exit function test_1" style="filled" fillcolor=red];
}
10 -> {11};
11 -> {12};
12 -> {13};
subgraph cluster_5 {
color=red
13 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
14 [label="Enter block"];
15 [label="Variable declaration: lval x: R|kotlin/String?|"];
subgraph cluster_7 {
color=blue
16 [label="Try expression enter"];
subgraph cluster_8 {
color=blue
17 [label="Try main block enter"];
subgraph cluster_9 {
color=blue
18 [label="Enter block"];
19 [label="Function call: R|/getNullableString|()" style="filled" fillcolor=yellow];
20 [label="Check not null: R|/getNullableString|()!!" style="filled" fillcolor=yellow];
21 [label="Variable declaration: lval y: R|kotlin/String|"];
22 [label="Function call: R|/getNullableString|()" style="filled" fillcolor=yellow];
23 [label="Assignment: R|<local>/x|"];
24 [label="Exit block"];
}
25 [label="Try main block exit"];
}
subgraph cluster_10 {
color=blue
26 [label="Enter finally"];
subgraph cluster_11 {
color=blue
27 [label="Enter block"];
28 [label="Access qualifier kotlin/Unit"];
29 [label="Exit block"];
}
30 [label="Exit finally"];
}
31 [label="Try expression exit"];
}
32 [label="Access variable R|<local>/x|"];
33 [label="Function call: R|/takeNullableString|(...)" style="filled" fillcolor=yellow];
34 [label="Exit block"];
}
35 [label="Exit function test_1" style="filled" fillcolor=red];
}
13 -> {14};
14 -> {15};
14 -> {24} [label="onUncaughtException"];
15 -> {16};
16 -> {17};
16 -> {26} [label="onUncaughtException"];
17 -> {18};
17 -> {24} [label="onUncaughtException"];
18 -> {19};
18 -> {24} [label="onUncaughtException"];
19 -> {20};
19 -> {26} [label="onUncaughtException"];
20 -> {21};
20 -> {24} [label="onUncaughtException"];
20 -> {26} [label="onUncaughtException"];
21 -> {22};
22 -> {23};
22 -> {26} [label="onUncaughtException"];
23 -> {24};
24 -> {25};
25 -> {26};
@@ -108,64 +113,64 @@ digraph initializationInTry_kt {
30 -> {31};
31 -> {32};
32 -> {33};
subgraph cluster_11 {
color=red
34 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_12 {
color=blue
35 [label="Enter block"];
36 [label="Variable declaration: lval x: R|kotlin/String?|"];
subgraph cluster_13 {
color=blue
37 [label="Try expression enter"];
subgraph cluster_14 {
color=blue
38 [label="Try main block enter"];
subgraph cluster_15 {
color=blue
39 [label="Enter block"];
40 [label="Function call: R|/getNullableString|()" style="filled" fillcolor=yellow];
41 [label="Variable declaration: lval y: R|kotlin/String?|"];
42 [label="Function call: R|/getNullableString|()" style="filled" fillcolor=yellow];
43 [label="Assignment: R|<local>/x|"];
44 [label="Exit block"];
}
45 [label="Try main block exit"];
}
subgraph cluster_16 {
color=blue
46 [label="Enter finally"];
subgraph cluster_17 {
color=blue
47 [label="Enter block"];
48 [label="Access qualifier kotlin/Unit"];
49 [label="Exit block"];
}
50 [label="Exit finally"];
}
51 [label="Try expression exit"];
}
52 [label="Access variable R|<local>/x|"];
53 [label="Function call: R|/takeNullableString|(...)" style="filled" fillcolor=yellow];
54 [label="Exit block"];
}
55 [label="Exit function test_2" style="filled" fillcolor=red];
}
33 -> {34};
34 -> {35};
35 -> {36};
subgraph cluster_12 {
color=red
36 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_13 {
color=blue
37 [label="Enter block"];
38 [label="Variable declaration: lval x: R|kotlin/String?|"];
subgraph cluster_14 {
color=blue
39 [label="Try expression enter"];
subgraph cluster_15 {
color=blue
40 [label="Try main block enter"];
subgraph cluster_16 {
color=blue
41 [label="Enter block"];
42 [label="Function call: R|/getNullableString|()" style="filled" fillcolor=yellow];
43 [label="Variable declaration: lval y: R|kotlin/String?|"];
44 [label="Function call: R|/getNullableString|()" style="filled" fillcolor=yellow];
45 [label="Assignment: R|<local>/x|"];
46 [label="Exit block"];
}
47 [label="Try main block exit"];
}
subgraph cluster_17 {
color=blue
48 [label="Enter finally"];
subgraph cluster_18 {
color=blue
49 [label="Enter block"];
50 [label="Access qualifier kotlin/Unit"];
51 [label="Exit block"];
}
52 [label="Exit finally"];
}
53 [label="Try expression exit"];
}
54 [label="Access variable R|<local>/x|"];
55 [label="Function call: R|/takeNullableString|(...)" style="filled" fillcolor=yellow];
56 [label="Exit block"];
}
57 [label="Exit function test_2" style="filled" fillcolor=red];
}
36 -> {37};
37 -> {38};
37 -> {46} [label="onUncaughtException"];
38 -> {39};
39 -> {40};
39 -> {48} [label="onUncaughtException"];
40 -> {41};
40 -> {46} [label="onUncaughtException"];
41 -> {42};
42 -> {43};
42 -> {46} [label="onUncaughtException"];
42 -> {48} [label="onUncaughtException"];
43 -> {44};
44 -> {45};
44 -> {48} [label="onUncaughtException"];
45 -> {46};
46 -> {47};
47 -> {48};
@@ -176,5 +181,7 @@ digraph initializationInTry_kt {
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
}