[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,155 +5,160 @@ digraph delegatedConstructorArguments_kt {
subgraph cluster_0 {
color=red
0 [label="Enter class Test" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter function <init>" style="filled" fillcolor=red];
2 [label="Access variable R|<local>/set|"];
3 [label="Postponed enter to lambda"];
subgraph cluster_2 {
color=blue
4 [label="Enter function <anonymous>" style="filled" fillcolor=red];
subgraph cluster_3 {
color=blue
5 [label="Enter block"];
6 [label="Access variable R|<local>/it|"];
7 [label="Exit block"];
}
8 [label="Exit function <anonymous>" style="filled" fillcolor=red];
}
9 [label="Postponed exit from lambda"];
10 [label="Function call: R|<local>/set|.R|kotlin/collections/map|<R|kotlin/String|, R|kotlin/String|>(...)" style="filled" fillcolor=yellow];
11 [label="Delegated constructor call: this<R|Test|>(...)" style="filled" fillcolor=yellow];
subgraph cluster_4 {
color=blue
12 [label="Enter function <init>" style="filled" fillcolor=red];
13 [label="Access variable R|<local>/map|"];
14 [label="Access variable R|SubstitutionOverride<kotlin/collections/Map.values: R|kotlin/collections/Collection<kotlin/String>|>|"];
15 [label="Postponed enter to lambda"];
subgraph cluster_5 {
color=blue
16 [label="Enter function <anonymous>" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
17 [label="Enter block"];
18 [label="Access variable R|<local>/it|"];
19 [label="Exit block"];
}
20 [label="Exit function <anonymous>" style="filled" fillcolor=red];
}
21 [label="Postponed exit from lambda"];
22 [label="Function call: R|<local>/map|.R|SubstitutionOverride<kotlin/collections/Map.values: R|kotlin/collections/Collection<kotlin/String>|>|.R|kotlin/collections/map|<R|kotlin/String|, R|kotlin/String|>(...)" style="filled" fillcolor=yellow];
23 [label="Delegated constructor call: this<R|Test|>(...)" style="filled" fillcolor=yellow];
subgraph cluster_7 {
color=blue
24 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_8 {
color=blue
25 [label="Enter block"];
26 [label="Access variable this@R|/Test|"];
27 [label="Const: Int(0)"];
28 [label="Assignment: R|/Test.size|"];
29 [label="Exit block"];
}
30 [label="Exit init block" style="filled" fillcolor=red];
}
subgraph cluster_9 {
color=blue
31 [label="Enter function <init>" style="filled" fillcolor=red];
32 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
subgraph cluster_10 {
color=blue
33 [label="Enter block"];
34 [label="Access variable this@R|/Test|"];
35 [label="Access variable R|<local>/list|"];
36 [label="Assignment: R|/Test.values|"];
37 [label="Exit block"];
}
38 [label="Exit function <init>" style="filled" fillcolor=red];
}
subgraph cluster_11 {
color=blue
39 [label="Enter block"];
40 [label="Access variable this@R|/Test|"];
41 [label="Access variable R|/Test.size|"];
42 [label="Access variable this@R|/Test|"];
43 [label="Access variable R|/Test.values|"];
44 [label="Access variable R|SubstitutionOverride<kotlin/collections/List.size: R|kotlin/Int|>|"];
45 [label="Function call: this@R|/Test|.R|/Test.size|.R|kotlin/Int.plus|(...)" style="filled" fillcolor=yellow];
46 [label="Assignment: R|/Test.size|"];
47 [label="Exit block"];
}
48 [label="Exit function <init>" style="filled" fillcolor=red];
}
subgraph cluster_12 {
color=blue
49 [label="Enter block"];
50 [label="Access variable this@R|/Test|"];
51 [label="Access variable R|/Test.size|"];
52 [label="Access variable this@R|/Test|"];
53 [label="Access variable R|/Test.values|"];
54 [label="Access variable R|SubstitutionOverride<kotlin/collections/List.size: R|kotlin/Int|>|"];
55 [label="Function call: this@R|/Test|.R|/Test.size|.R|kotlin/Int.plus|(...)" style="filled" fillcolor=yellow];
56 [label="Assignment: R|/Test.size|"];
57 [label="Exit block"];
}
58 [label="Exit function <init>" style="filled" fillcolor=red];
}
59 [label="Exit class Test" style="filled" fillcolor=red];
0 [label="Enter file delegatedConstructorArguments.kt" style="filled" fillcolor=red];
1 [label="Exit file delegatedConstructorArguments.kt" style="filled" fillcolor=red];
}
0 -> {1 12 24} [color=green];
0 -> {59} [style=dotted];
0 -> {1 12 24 31} [style=dashed];
1 -> {2};
2 -> {3};
3 -> {4 9 10};
3 -> {4} [style=dashed];
0 -> {1} [color=green];
subgraph cluster_1 {
color=red
2 [label="Enter class Test" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
3 [label="Enter function <init>" style="filled" fillcolor=red];
4 [label="Access variable R|<local>/set|"];
5 [label="Postponed enter to lambda"];
subgraph cluster_3 {
color=blue
6 [label="Enter function <anonymous>" style="filled" fillcolor=red];
subgraph cluster_4 {
color=blue
7 [label="Enter block"];
8 [label="Access variable R|<local>/it|"];
9 [label="Exit block"];
}
10 [label="Exit function <anonymous>" style="filled" fillcolor=red];
}
11 [label="Postponed exit from lambda"];
12 [label="Function call: R|<local>/set|.R|kotlin/collections/map|<R|kotlin/String|, R|kotlin/String|>(...)" style="filled" fillcolor=yellow];
13 [label="Delegated constructor call: this<R|Test|>(...)" style="filled" fillcolor=yellow];
subgraph cluster_5 {
color=blue
14 [label="Enter function <init>" style="filled" fillcolor=red];
15 [label="Access variable R|<local>/map|"];
16 [label="Access variable R|SubstitutionOverride<kotlin/collections/Map.values: R|kotlin/collections/Collection<kotlin/String>|>|"];
17 [label="Postponed enter to lambda"];
subgraph cluster_6 {
color=blue
18 [label="Enter function <anonymous>" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
19 [label="Enter block"];
20 [label="Access variable R|<local>/it|"];
21 [label="Exit block"];
}
22 [label="Exit function <anonymous>" style="filled" fillcolor=red];
}
23 [label="Postponed exit from lambda"];
24 [label="Function call: R|<local>/map|.R|SubstitutionOverride<kotlin/collections/Map.values: R|kotlin/collections/Collection<kotlin/String>|>|.R|kotlin/collections/map|<R|kotlin/String|, R|kotlin/String|>(...)" style="filled" fillcolor=yellow];
25 [label="Delegated constructor call: this<R|Test|>(...)" style="filled" fillcolor=yellow];
subgraph cluster_8 {
color=blue
26 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_9 {
color=blue
27 [label="Enter block"];
28 [label="Access variable this@R|/Test|"];
29 [label="Const: Int(0)"];
30 [label="Assignment: R|/Test.size|"];
31 [label="Exit block"];
}
32 [label="Exit init block" style="filled" fillcolor=red];
}
subgraph cluster_10 {
color=blue
33 [label="Enter function <init>" style="filled" fillcolor=red];
34 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
subgraph cluster_11 {
color=blue
35 [label="Enter block"];
36 [label="Access variable this@R|/Test|"];
37 [label="Access variable R|<local>/list|"];
38 [label="Assignment: R|/Test.values|"];
39 [label="Exit block"];
}
40 [label="Exit function <init>" style="filled" fillcolor=red];
}
subgraph cluster_12 {
color=blue
41 [label="Enter block"];
42 [label="Access variable this@R|/Test|"];
43 [label="Access variable R|/Test.size|"];
44 [label="Access variable this@R|/Test|"];
45 [label="Access variable R|/Test.values|"];
46 [label="Access variable R|SubstitutionOverride<kotlin/collections/List.size: R|kotlin/Int|>|"];
47 [label="Function call: this@R|/Test|.R|/Test.size|.R|kotlin/Int.plus|(...)" style="filled" fillcolor=yellow];
48 [label="Assignment: R|/Test.size|"];
49 [label="Exit block"];
}
50 [label="Exit function <init>" style="filled" fillcolor=red];
}
subgraph cluster_13 {
color=blue
51 [label="Enter block"];
52 [label="Access variable this@R|/Test|"];
53 [label="Access variable R|/Test.size|"];
54 [label="Access variable this@R|/Test|"];
55 [label="Access variable R|/Test.values|"];
56 [label="Access variable R|SubstitutionOverride<kotlin/collections/List.size: R|kotlin/Int|>|"];
57 [label="Function call: this@R|/Test|.R|/Test.size|.R|kotlin/Int.plus|(...)" style="filled" fillcolor=yellow];
58 [label="Assignment: R|/Test.size|"];
59 [label="Exit block"];
}
60 [label="Exit function <init>" style="filled" fillcolor=red];
}
61 [label="Exit class Test" style="filled" fillcolor=red];
}
2 -> {3 14 26} [color=green];
2 -> {61} [style=dotted];
2 -> {3 14 26 33} [style=dashed];
3 -> {4};
4 -> {5};
5 -> {6};
5 -> {6 11 12};
5 -> {6} [style=dashed];
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {3} [color=green style=dashed];
9 -> {10} [color=green];
9 -> {11} [color=red];
9 -> {10};
10 -> {11};
11 -> {24} [color=green label="return@/Test.Test"];
11 -> {39} [color=red];
11 -> {5} [color=green style=dashed];
11 -> {12} [color=green];
11 -> {13} [color=red];
12 -> {13};
13 -> {14};
13 -> {26} [color=green label="return@/Test.Test"];
13 -> {41} [color=red];
14 -> {15};
15 -> {16 21 22};
15 -> {16} [style=dashed];
15 -> {16};
16 -> {17};
17 -> {18};
17 -> {18 23 24};
17 -> {18} [style=dashed];
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {15} [color=green style=dashed];
21 -> {22} [color=green];
21 -> {23} [color=red];
21 -> {22};
22 -> {23};
23 -> {24} [color=green label="return@/Test.Test"];
23 -> {49} [color=red];
23 -> {17} [color=green style=dashed];
23 -> {24} [color=green];
23 -> {25} [color=red];
24 -> {25};
25 -> {26};
25 -> {26} [color=green label="return@/Test.Test"];
25 -> {51} [color=red];
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31} [color=green];
30 -> {31};
31 -> {32};
32 -> {33};
32 -> {33} [color=green];
33 -> {34};
34 -> {35};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39 49} [color=green label="return@/Test.Test"];
38 -> {59} [color=green];
38 -> {39};
39 -> {40};
40 -> {41};
40 -> {41 51} [color=green label="return@/Test.Test"];
40 -> {61} [color=green];
41 -> {42};
42 -> {43};
43 -> {44};
@@ -161,9 +166,9 @@ digraph delegatedConstructorArguments_kt {
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {59} [color=green];
48 -> {49};
49 -> {50};
50 -> {51};
50 -> {61} [color=green];
51 -> {52};
52 -> {53};
53 -> {54};
@@ -171,6 +176,8 @@ digraph delegatedConstructorArguments_kt {
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59} [color=green];
58 -> {59};
59 -> {60};
60 -> {61} [color=green];
}