[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,245 +5,252 @@ digraph delegateWithAnonymousObject_kt {
subgraph cluster_0 {
color=red
0 [label="Enter class DelegateProvider" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter function <init>" style="filled" fillcolor=red];
2 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
3 [label="Exit function <init>" style="filled" fillcolor=red];
}
4 [label="Exit class DelegateProvider" style="filled" fillcolor=red];
0 [label="Enter file delegateWithAnonymousObject.kt" style="filled" fillcolor=red];
1 [label="Exit file delegateWithAnonymousObject.kt" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
0 -> {4} [style=dotted];
0 -> {1} [style=dashed];
1 -> {2};
2 -> {3};
3 -> {4} [color=green];
subgraph cluster_2 {
subgraph cluster_1 {
color=red
5 [label="Enter function delegate" style="filled" fillcolor=red];
subgraph cluster_3 {
2 [label="Enter class DelegateProvider" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
6 [label="Enter block"];
7 [label="Const: Null(null)"];
8 [label="Check not null: Null(null)!!" style="filled" fillcolor=yellow];
9 [label="Stub" style="filled" fillcolor=gray];
10 [label="Jump: ^delegate Null(null)!!" style="filled" fillcolor=gray];
3 [label="Enter function <init>" style="filled" fillcolor=red];
4 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
5 [label="Exit function <init>" style="filled" fillcolor=red];
}
6 [label="Exit class DelegateProvider" style="filled" fillcolor=red];
}
2 -> {3} [color=green];
2 -> {6} [style=dotted];
2 -> {3} [style=dashed];
3 -> {4};
4 -> {5};
5 -> {6} [color=green];
subgraph cluster_3 {
color=red
7 [label="Enter function delegate" style="filled" fillcolor=red];
subgraph cluster_4 {
color=blue
8 [label="Enter block"];
9 [label="Const: Null(null)"];
10 [label="Check not null: Null(null)!!" style="filled" fillcolor=yellow];
11 [label="Stub" style="filled" fillcolor=gray];
12 [label="Exit block" style="filled" fillcolor=gray];
12 [label="Jump: ^delegate Null(null)!!" style="filled" fillcolor=gray];
13 [label="Stub" style="filled" fillcolor=gray];
14 [label="Exit block" style="filled" fillcolor=gray];
}
13 [label="Exit function delegate" style="filled" fillcolor=gray];
15 [label="Exit function delegate" style="filled" fillcolor=gray];
}
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {9} [style=dotted];
9 -> {10} [style=dotted];
10 -> {11 13} [style=dotted];
8 -> {9};
9 -> {10};
10 -> {11} [style=dotted];
11 -> {12} [style=dotted];
12 -> {13} [style=dotted];
12 -> {13 15} [style=dotted];
13 -> {14} [style=dotted];
14 -> {15} [style=dotted];
subgraph cluster_4 {
subgraph cluster_5 {
color=red
14 [label="Enter class IssueListView" style="filled" fillcolor=red];
subgraph cluster_5 {
16 [label="Enter class IssueListView" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
15 [label="Enter function <init>" style="filled" fillcolor=red];
16 [label="Delegated constructor call: super<R|DelegateProvider<IssueListView>|>()" style="filled" fillcolor=yellow];
17 [label="Exit function <init>" style="filled" fillcolor=red];
17 [label="Enter function <init>" style="filled" fillcolor=red];
18 [label="Delegated constructor call: super<R|DelegateProvider<IssueListView>|>()" style="filled" fillcolor=yellow];
19 [label="Exit function <init>" style="filled" fillcolor=red];
}
18 [label="Exit class IssueListView" style="filled" fillcolor=red];
20 [label="Exit class IssueListView" style="filled" fillcolor=red];
}
14 -> {15} [color=green];
14 -> {18} [style=dotted];
14 -> {15} [style=dashed];
15 -> {16};
16 -> {17};
17 -> {18} [color=green];
16 -> {17} [color=green];
16 -> {20} [style=dotted];
16 -> {17} [style=dashed];
17 -> {18};
18 -> {19};
19 -> {20} [color=green];
subgraph cluster_6 {
subgraph cluster_7 {
color=red
19 [label="Enter function updateFrom" style="filled" fillcolor=red];
subgraph cluster_7 {
21 [label="Enter function updateFrom" style="filled" fillcolor=red];
subgraph cluster_8 {
color=blue
20 [label="Enter block"];
21 [label="Exit block"];
22 [label="Enter block"];
23 [label="Exit block"];
}
22 [label="Exit function updateFrom" style="filled" fillcolor=red];
24 [label="Exit function updateFrom" style="filled" fillcolor=red];
}
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {24};
subgraph cluster_8 {
subgraph cluster_9 {
color=red
23 [label="Enter class IssuesListUserProfile" style="filled" fillcolor=red];
subgraph cluster_9 {
25 [label="Enter class IssuesListUserProfile" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
24 [label="Enter property" style="filled" fillcolor=red];
25 [label="Postponed enter to lambda"];
subgraph cluster_10 {
26 [label="Enter property" style="filled" fillcolor=red];
27 [label="Postponed enter to lambda"];
subgraph cluster_11 {
color=blue
26 [label="Enter function <anonymous>" style="filled" fillcolor=red];
subgraph cluster_11 {
28 [label="Enter function <anonymous>" style="filled" fillcolor=red];
subgraph cluster_12 {
color=blue
27 [label="Enter block"];
28 [label="Enter anonymous object"];
subgraph cluster_12 {
29 [label="Enter block"];
30 [label="Enter anonymous object"];
subgraph cluster_13 {
color=blue
29 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
subgraph cluster_13 {
31 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
subgraph cluster_14 {
color=blue
30 [label="Enter function <init>" style="filled" fillcolor=red];
31 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
32 [label="Exit function <init>" style="filled" fillcolor=red];
32 [label="Enter function <init>" style="filled" fillcolor=red];
33 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
34 [label="Exit function <init>" style="filled" fillcolor=red];
}
33 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
35 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
}
34 [label="Exit anonymous object expression"];
35 [label="Exit block"];
36 [label="Exit anonymous object expression"];
37 [label="Exit block"];
}
36 [label="Exit function <anonymous>" style="filled" fillcolor=red];
38 [label="Exit function <anonymous>" style="filled" fillcolor=red];
}
subgraph cluster_14 {
subgraph cluster_15 {
color=blue
37 [label="Enter function setValue" style="filled" fillcolor=red];
subgraph cluster_15 {
39 [label="Enter function setValue" style="filled" fillcolor=red];
subgraph cluster_16 {
color=blue
38 [label="Enter block"];
39 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow];
40 [label="Access variable R|<local>/value|"];
41 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)" style="filled" fillcolor=yellow];
42 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"];
43 [label="Stub" style="filled" fillcolor=gray];
44 [label="Exit block" style="filled" fillcolor=gray];
40 [label="Enter block"];
41 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow];
42 [label="Access variable R|<local>/value|"];
43 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)" style="filled" fillcolor=yellow];
44 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"];
45 [label="Stub" style="filled" fillcolor=gray];
46 [label="Exit block" style="filled" fillcolor=gray];
}
45 [label="Exit function setValue" style="filled" fillcolor=red];
47 [label="Exit function setValue" style="filled" fillcolor=red];
}
subgraph cluster_16 {
subgraph cluster_17 {
color=blue
46 [label="Enter function getValue" style="filled" fillcolor=red];
subgraph cluster_17 {
48 [label="Enter function getValue" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
47 [label="Enter block"];
48 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow];
49 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"];
50 [label="Stub" style="filled" fillcolor=gray];
51 [label="Exit block" style="filled" fillcolor=gray];
49 [label="Enter block"];
50 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow];
51 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"];
52 [label="Stub" style="filled" fillcolor=gray];
53 [label="Exit block" style="filled" fillcolor=gray];
}
52 [label="Exit function getValue" style="filled" fillcolor=red];
54 [label="Exit function getValue" style="filled" fillcolor=red];
}
53 [label="Postponed exit from lambda"];
54 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)" style="filled" fillcolor=yellow];
55 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...).<Unresolved name: provideDelegate>#(...)" style="filled" fillcolor=yellow];
56 [label="Exit property delegate" style="filled" fillcolor=yellow];
57 [label="Exit property" style="filled" fillcolor=red];
55 [label="Postponed exit from lambda"];
56 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)" style="filled" fillcolor=yellow];
57 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...).<Unresolved name: provideDelegate>#(...)" style="filled" fillcolor=yellow];
58 [label="Exit property delegate" style="filled" fillcolor=yellow];
59 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_18 {
subgraph cluster_19 {
color=blue
58 [label="Enter function <init>" style="filled" fillcolor=red];
59 [label="Delegated constructor call: super<R|DelegateProvider<IssuesListUserProfile>|>()" style="filled" fillcolor=yellow];
60 [label="Exit function <init>" style="filled" fillcolor=red];
60 [label="Enter function <init>" style="filled" fillcolor=red];
61 [label="Delegated constructor call: super<R|DelegateProvider<IssuesListUserProfile>|>()" style="filled" fillcolor=yellow];
62 [label="Exit function <init>" style="filled" fillcolor=red];
}
61 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red];
63 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red];
}
23 -> {24} [color=green];
23 -> {61} [style=dotted];
23 -> {24 58} [style=dashed];
24 -> {25};
25 -> {26 53 54};
25 -> {26} [style=dashed];
25 -> {26} [color=green];
25 -> {63} [style=dotted];
25 -> {26 60} [style=dashed];
26 -> {27};
27 -> {28};
27 -> {28 55 56};
27 -> {28} [style=dashed];
28 -> {29};
28 -> {34} [style=dotted];
28 -> {29} [style=dashed];
29 -> {30};
29 -> {37 46} [color=red];
29 -> {33} [style=dotted];
29 -> {30} [style=dashed];
30 -> {31};
30 -> {36} [style=dotted];
30 -> {31} [style=dashed];
31 -> {32};
31 -> {39 48} [color=red];
31 -> {35} [style=dotted];
31 -> {32} [style=dashed];
32 -> {33};
33 -> {34};
33 -> {37 46} [color=green];
33 -> {37 46} [style=dashed];
34 -> {35};
35 -> {36};
35 -> {39 48} [color=green];
35 -> {39 48} [style=dashed];
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {45};
42 -> {43} [style=dotted];
43 -> {44} [style=dotted];
42 -> {43};
43 -> {44};
44 -> {47};
44 -> {45} [style=dotted];
46 -> {47};
47 -> {48};
45 -> {46} [style=dotted];
46 -> {47} [style=dotted];
48 -> {49};
49 -> {52};
49 -> {50} [style=dotted];
50 -> {51} [style=dotted];
49 -> {50};
50 -> {51};
51 -> {54};
51 -> {52} [style=dotted];
53 -> {54} [color=green];
53 -> {56} [color=red];
54 -> {55};
55 -> {56};
52 -> {53} [style=dotted];
53 -> {54} [style=dotted];
55 -> {56} [color=green];
55 -> {58} [color=red];
56 -> {57};
57 -> {58} [color=green];
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61} [color=green];
59 -> {60} [color=green];
60 -> {61};
61 -> {62};
62 -> {63} [color=green];
subgraph cluster_19 {
subgraph cluster_20 {
color=red
62 [label="Enter function <getter>" style="filled" fillcolor=red];
subgraph cluster_20 {
64 [label="Enter function <getter>" style="filled" fillcolor=red];
subgraph cluster_21 {
color=blue
63 [label="Enter block"];
64 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
65 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|Stub (chain inference): TypeVariable(+Target)|>|(...)" style="filled" fillcolor=yellow];
66 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|Stub (chain inference): TypeVariable(+Target)|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"];
67 [label="Stub" style="filled" fillcolor=gray];
68 [label="Exit block" style="filled" fillcolor=gray];
65 [label="Enter block"];
66 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
67 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|Stub (chain inference): TypeVariable(+Target)|>|(...)" style="filled" fillcolor=yellow];
68 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|Stub (chain inference): TypeVariable(+Target)|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"];
69 [label="Stub" style="filled" fillcolor=gray];
70 [label="Exit block" style="filled" fillcolor=gray];
}
69 [label="Exit function <getter>" style="filled" fillcolor=red];
71 [label="Exit function <getter>" style="filled" fillcolor=red];
}
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {69};
66 -> {67} [style=dotted];
67 -> {68} [style=dotted];
66 -> {67};
67 -> {68};
68 -> {71};
68 -> {69} [style=dotted];
69 -> {70} [style=dotted];
70 -> {71} [style=dotted];
subgraph cluster_21 {
subgraph cluster_22 {
color=red
70 [label="Enter function <setter>" style="filled" fillcolor=red];
subgraph cluster_22 {
72 [label="Enter function <setter>" style="filled" fillcolor=red];
subgraph cluster_23 {
color=blue
71 [label="Enter block"];
72 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
73 [label="Access variable R|<local>/issueListView|"];
74 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(...)" style="filled" fillcolor=yellow];
75 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|, R|<local>/issueListView|)"];
76 [label="Stub" style="filled" fillcolor=gray];
77 [label="Exit block" style="filled" fillcolor=gray];
73 [label="Enter block"];
74 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
75 [label="Access variable R|<local>/issueListView|"];
76 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(...)" style="filled" fillcolor=yellow];
77 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|, R|<local>/issueListView|)"];
78 [label="Stub" style="filled" fillcolor=gray];
79 [label="Exit block" style="filled" fillcolor=gray];
}
78 [label="Exit function <setter>" style="filled" fillcolor=red];
80 [label="Exit function <setter>" style="filled" fillcolor=red];
}
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {78};
75 -> {76} [style=dotted];
76 -> {77} [style=dotted];
75 -> {76};
76 -> {77};
77 -> {80};
77 -> {78} [style=dotted];
78 -> {79} [style=dotted];
79 -> {80} [style=dotted];
}