Files
Brian Norman 17a1871b83 [FIR] Make sure the primary constructor is first in class CFG
The primary constructor of a class needs to be the first subgraph of the
class control-flow graph. Based on the Kotlin specification, class
initialization order goes first primary constructor, in-place
declarations (properties and init blocks), and then secondary
constructors. If the class doesn't have a primary constructor, then it
is just skipped in the order.

Unfortunately, the class control-flow graph had in-place declarations
first and then all constructors. Instead, we should treat the primary
constructor as the first in-place declaration, and then continue with
the existing processing as secondary constructors. This will guarantee
that super constructor calls have the correct property initialization
information.

^KT-65093 Fixed
2024-01-23 23:16:00 +00:00

505 lines
16 KiB
Plaintext
Vendored

digraph assignSafeCall_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter file assignSafeCall.kt" style="filled" fillcolor=red];
1 [label="Exit file assignSafeCall.kt" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
subgraph cluster_1 {
color=red
2 [label="Enter class A" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
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];
}
subgraph cluster_3 {
color=blue
6 [label="Enter property" style="filled" fillcolor=red];
7 [label="Const: Int(1)"];
8 [label="Exit property" style="filled" fillcolor=red];
}
9 [label="Exit class A" style="filled" fillcolor=red];
}
2 -> {3} [color=green];
2 -> {9} [style=dotted];
2 -> {3 6} [style=dashed];
3 -> {4};
4 -> {5};
5 -> {6} [color=green];
6 -> {7};
7 -> {8};
8 -> {9} [color=green];
subgraph cluster_4 {
color=red
10 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
11 [label="Enter block"];
12 [label="Const: Int(1)"];
13 [label="Jump: ^foo Int(1)"];
14 [label="Stub" style="filled" fillcolor=gray];
15 [label="Exit block" style="filled" fillcolor=gray];
}
16 [label="Exit function foo" style="filled" fillcolor=red];
}
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {16};
13 -> {14} [style=dotted];
14 -> {15} [style=dotted];
15 -> {16} [style=dotted];
subgraph cluster_6 {
color=red
17 [label="Enter function bar" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
18 [label="Enter block"];
19 [label="Exit block"];
}
20 [label="Exit function bar" style="filled" fillcolor=red];
}
17 -> {18};
18 -> {19};
19 -> {20};
subgraph cluster_8 {
color=red
21 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_9 {
color=blue
22 [label="Enter block"];
23 [label="Access variable R|<local>/a|"];
24 [label="Enter safe call"];
25 [label="Access variable R|/A.x|"];
26 [label="Exit safe call"];
27 [label="Variable declaration: lval x: R|kotlin/Int?|"];
subgraph cluster_10 {
color=blue
28 [label="Enter when"];
subgraph cluster_11 {
color=blue
29 [label="Enter when branch condition "];
30 [label="Access variable R|<local>/x|"];
31 [label="Const: Null(null)"];
32 [label="Equality operator !="];
33 [label="Exit when branch condition"];
}
34 [label="Synthetic else branch"];
35 [label="Enter when branch result"];
subgraph cluster_12 {
color=blue
36 [label="Enter block"];
subgraph cluster_13 {
color=blue
37 [label="Function call arguments enter"];
38 [label="Access variable R|<local>/a|"];
39 [label="Smart cast: R|<local>/a|"];
40 [label="Function call arguments exit"];
}
41 [label="Function call: R|<local>/a|.R|/A.bar|()" style="filled" fillcolor=yellow];
42 [label="Exit block"];
}
43 [label="Exit when branch result"];
44 [label="Exit when"];
}
45 [label="Exit block"];
}
46 [label="Exit function test_1" style="filled" fillcolor=red];
}
21 -> {22};
22 -> {23};
23 -> {24 26};
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34 35};
34 -> {44};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {46};
subgraph cluster_14 {
color=red
47 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_15 {
color=blue
48 [label="Enter block"];
49 [label="Access variable R|<local>/a|"];
50 [label="Enter safe call"];
subgraph cluster_16 {
color=blue
51 [label="Function call arguments enter"];
52 [label="Function call arguments exit"];
}
53 [label="Function call: $subj$.R|/A.foo|()" style="filled" fillcolor=yellow];
54 [label="Exit safe call"];
55 [label="Variable declaration: lval x: R|kotlin/Int?|"];
subgraph cluster_17 {
color=blue
56 [label="Enter when"];
subgraph cluster_18 {
color=blue
57 [label="Enter when branch condition "];
58 [label="Access variable R|<local>/x|"];
59 [label="Const: Null(null)"];
60 [label="Equality operator !="];
61 [label="Exit when branch condition"];
}
62 [label="Synthetic else branch"];
63 [label="Enter when branch result"];
subgraph cluster_19 {
color=blue
64 [label="Enter block"];
subgraph cluster_20 {
color=blue
65 [label="Function call arguments enter"];
66 [label="Access variable R|<local>/a|"];
67 [label="Smart cast: R|<local>/a|"];
68 [label="Function call arguments exit"];
}
69 [label="Function call: R|<local>/a|.R|/A.bar|()" style="filled" fillcolor=yellow];
70 [label="Exit block"];
}
71 [label="Exit when branch result"];
72 [label="Exit when"];
}
73 [label="Exit block"];
}
74 [label="Exit function test_2" style="filled" fillcolor=red];
}
47 -> {48};
48 -> {49};
49 -> {50 54};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {62 63};
62 -> {72};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
subgraph cluster_21 {
color=red
75 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_22 {
color=blue
76 [label="Enter block"];
77 [label="Access variable R|<local>/x|"];
78 [label="Type operator: (R|<local>/x| as? R|A|)"];
79 [label="Exit lhs of ?:"];
80 [label="Enter rhs of ?:"];
81 [label="Jump: ^test_3 Unit"];
82 [label="Stub" style="filled" fillcolor=gray];
83 [label="Lhs of ?: is not null"];
84 [label="Exit ?:"];
85 [label="Variable declaration: lval a: R|A|"];
subgraph cluster_23 {
color=blue
86 [label="Function call arguments enter"];
87 [label="Access variable R|<local>/a|"];
88 [label="Function call arguments exit"];
}
89 [label="Function call: R|<local>/a|.R|/A.foo|()" style="filled" fillcolor=yellow];
subgraph cluster_24 {
color=blue
90 [label="Function call arguments enter"];
91 [label="Access variable R|<local>/x|"];
92 [label="Smart cast: R|<local>/x|"];
93 [label="Function call arguments exit"];
}
94 [label="Function call: R|<local>/x|.R|/A.foo|()" style="filled" fillcolor=yellow];
95 [label="Exit block"];
}
96 [label="Exit function test_3" style="filled" fillcolor=red];
}
75 -> {76};
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80 83};
80 -> {81};
81 -> {96};
81 -> {82} [style=dotted];
82 -> {84} [style=dotted];
83 -> {84};
84 -> {85};
85 -> {86};
86 -> {87};
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {91};
91 -> {92};
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {96};
subgraph cluster_25 {
color=red
97 [label="Enter class B" style="filled" fillcolor=red];
98 [label="Exit class B" style="filled" fillcolor=red];
}
97 -> {98} [color=green];
subgraph cluster_26 {
color=red
99 [label="Enter function foo" style="filled" fillcolor=red];
100 [label="Exit function foo" style="filled" fillcolor=red];
}
99 -> {100};
subgraph cluster_27 {
color=red
101 [label="Enter function bar" style="filled" fillcolor=red];
102 [label="Exit function bar" style="filled" fillcolor=red];
}
101 -> {102};
subgraph cluster_28 {
color=red
103 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_29 {
color=blue
104 [label="Enter block"];
105 [label="Access variable R|<local>/a|"];
106 [label="Enter safe call"];
107 [label="Access variable R|/B.x|"];
108 [label="Exit safe call"];
109 [label="Variable declaration: lval x: R|kotlin/Int?|"];
subgraph cluster_30 {
color=blue
110 [label="Enter when"];
subgraph cluster_31 {
color=blue
111 [label="Enter when branch condition "];
112 [label="Access variable R|<local>/x|"];
113 [label="Const: Null(null)"];
114 [label="Equality operator !="];
115 [label="Exit when branch condition"];
}
116 [label="Synthetic else branch"];
117 [label="Enter when branch result"];
subgraph cluster_32 {
color=blue
118 [label="Enter block"];
subgraph cluster_33 {
color=blue
119 [label="Function call arguments enter"];
120 [label="Access variable R|<local>/a|"];
121 [label="Smart cast: R|<local>/a|"];
122 [label="Function call arguments exit"];
}
123 [label="Function call: R|<local>/a|.R|/B.bar|()" style="filled" fillcolor=yellow];
124 [label="Exit block"];
}
125 [label="Exit when branch result"];
126 [label="Exit when"];
}
127 [label="Exit block"];
}
128 [label="Exit function test_1" style="filled" fillcolor=red];
}
103 -> {104};
104 -> {105};
105 -> {106 108};
106 -> {107};
107 -> {108};
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {112};
112 -> {113};
113 -> {114};
114 -> {115};
115 -> {116 117};
116 -> {126};
117 -> {118};
118 -> {119};
119 -> {120};
120 -> {121};
121 -> {122};
122 -> {123};
123 -> {124};
124 -> {125};
125 -> {126};
126 -> {127};
127 -> {128};
subgraph cluster_34 {
color=red
129 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_35 {
color=blue
130 [label="Enter block"];
131 [label="Access variable R|<local>/a|"];
132 [label="Enter safe call"];
subgraph cluster_36 {
color=blue
133 [label="Function call arguments enter"];
134 [label="Function call arguments exit"];
}
135 [label="Function call: $subj$.R|/B.foo|()" style="filled" fillcolor=yellow];
136 [label="Exit safe call"];
137 [label="Variable declaration: lval x: R|kotlin/Int?|"];
subgraph cluster_37 {
color=blue
138 [label="Enter when"];
subgraph cluster_38 {
color=blue
139 [label="Enter when branch condition "];
140 [label="Access variable R|<local>/x|"];
141 [label="Const: Null(null)"];
142 [label="Equality operator !="];
143 [label="Exit when branch condition"];
}
144 [label="Synthetic else branch"];
145 [label="Enter when branch result"];
subgraph cluster_39 {
color=blue
146 [label="Enter block"];
subgraph cluster_40 {
color=blue
147 [label="Function call arguments enter"];
148 [label="Access variable R|<local>/a|"];
149 [label="Smart cast: R|<local>/a|"];
150 [label="Function call arguments exit"];
}
151 [label="Function call: R|<local>/a|.R|/B.bar|()" style="filled" fillcolor=yellow];
152 [label="Exit block"];
}
153 [label="Exit when branch result"];
154 [label="Exit when"];
}
155 [label="Exit block"];
}
156 [label="Exit function test_2" style="filled" fillcolor=red];
}
129 -> {130};
130 -> {131};
131 -> {132 136};
132 -> {133};
133 -> {134};
134 -> {135};
135 -> {136};
136 -> {137};
137 -> {138};
138 -> {139};
139 -> {140};
140 -> {141};
141 -> {142};
142 -> {143};
143 -> {144 145};
144 -> {154};
145 -> {146};
146 -> {147};
147 -> {148};
148 -> {149};
149 -> {150};
150 -> {151};
151 -> {152};
152 -> {153};
153 -> {154};
154 -> {155};
155 -> {156};
subgraph cluster_41 {
color=red
157 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_42 {
color=blue
158 [label="Enter block"];
159 [label="Access variable R|<local>/x|"];
160 [label="Type operator: (R|<local>/x| as? R|B|)"];
161 [label="Exit lhs of ?:"];
162 [label="Enter rhs of ?:"];
163 [label="Jump: ^test_3 Unit"];
164 [label="Stub" style="filled" fillcolor=gray];
165 [label="Lhs of ?: is not null"];
166 [label="Exit ?:"];
167 [label="Variable declaration: lval a: R|B|"];
subgraph cluster_43 {
color=blue
168 [label="Function call arguments enter"];
169 [label="Access variable R|<local>/a|"];
170 [label="Function call arguments exit"];
}
171 [label="Function call: R|<local>/a|.R|/B.foo|()" style="filled" fillcolor=yellow];
subgraph cluster_44 {
color=blue
172 [label="Function call arguments enter"];
173 [label="Access variable R|<local>/x|"];
174 [label="Smart cast: R|<local>/x|"];
175 [label="Function call arguments exit"];
}
176 [label="Function call: R|<local>/x|.R|/B.foo|()" style="filled" fillcolor=yellow];
177 [label="Exit block"];
}
178 [label="Exit function test_3" style="filled" fillcolor=red];
}
157 -> {158};
158 -> {159};
159 -> {160};
160 -> {161};
161 -> {162 165};
162 -> {163};
163 -> {178};
163 -> {164} [style=dotted];
164 -> {166} [style=dotted];
165 -> {166};
166 -> {167};
167 -> {168};
168 -> {169};
169 -> {170};
170 -> {171};
171 -> {172};
172 -> {173};
173 -> {174};
174 -> {175};
175 -> {176};
176 -> {177};
177 -> {178};
}