[FIR-TEST] Move analysis tests to separate module

This commit is contained in:
Dmitriy Novozhilov
2020-03-18 15:10:46 +03:00
parent 3a479d5d16
commit cc07ae96b3
1477 changed files with 1001 additions and 980 deletions
@@ -0,0 +1,77 @@
digraph dataFlowInfoFromWhileCondition_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function foo" style="filled" fillcolor=red];
1 [label="Exit function foo" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter function test" style="filled" fillcolor=red];
3 [label="Const: Null(null)"];
4 [label="Variable declaration: lvar a: R|A?|"];
subgraph cluster_2 {
color=blue
5 [label="Enter while loop"];
subgraph cluster_3 {
color=blue
6 [label="Enter loop condition"];
subgraph cluster_4 {
color=blue
7 [label="Enter ||"];
8 [label="Access variable R|<local>/a|"];
9 [label="Type operator: (R|<local>/a| is R|B|)"];
10 [label="Exit left part of ||"];
11 [label="Enter right part of ||"];
12 [label="Access variable R|<local>/a|"];
13 [label="Type operator: (R|<local>/a| is R|C|)"];
14 [label="Exit ||"];
}
15 [label="Exit loop condition"];
}
subgraph cluster_5 {
color=blue
16 [label="Enter loop block"];
subgraph cluster_6 {
color=blue
17 [label="Enter block"];
18 [label="Access variable R|<local>/a|"];
19 [label="Function call: R|<local>/a|.R|/A.foo|()"];
20 [label="Exit block"];
}
21 [label="Exit loop block"];
}
22 [label="Exit whileloop"];
}
23 [label="Exit function test" style="filled" fillcolor=red];
}
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {14 11};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {22 16};
16 -> {17};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {6};
22 -> {23};
}
@@ -0,0 +1,13 @@
// !DUMP_CFG
interface A {
fun foo(): Boolean
}
interface B : A
interface C : A
fun test() {
var a: A? = null
while (a is B || a is C) {
a.foo()
}
}
@@ -0,0 +1,16 @@
FILE: dataFlowInfoFromWhileCondition.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Boolean|
}
public abstract interface B : R|A| {
}
public abstract interface C : R|A| {
}
public final fun test(): R|kotlin/Unit| {
lvar a: R|A?| = Null(null)
while((R|<local>/a| is R|B|) || (R|<local>/a| is R|C|)) {
R|<local>/a|.R|/A.foo|()
}
}
@@ -0,0 +1,586 @@
digraph endlessLoops_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function foo" style="filled" fillcolor=red];
1 [label="Exit function foo" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
3 [label="Enter while loop"];
subgraph cluster_3 {
color=blue
4 [label="Enter loop condition"];
5 [label="Const: Boolean(true)"];
6 [label="Exit loop condition"];
}
subgraph cluster_4 {
color=blue
7 [label="Enter loop block"];
subgraph cluster_5 {
color=blue
8 [label="Enter block"];
9 [label="Access variable R|<local>/x|"];
10 [label="Type operator: (R|<local>/x| as R|A|)"];
subgraph cluster_6 {
color=blue
11 [label="Enter when"];
subgraph cluster_7 {
color=blue
12 [label="Enter when branch condition "];
13 [label="Access variable R|<local>/b|"];
14 [label="Exit when branch condition"];
}
15 [label="Synthetic else branch"];
16 [label="Enter when branch result"];
subgraph cluster_8 {
color=blue
17 [label="Enter block"];
18 [label="Jump: break@@@[Boolean(true)] "];
19 [label="Stub" style="filled" fillcolor=gray];
20 [label="Exit block" style="filled" fillcolor=gray];
}
21 [label="Exit when branch result" style="filled" fillcolor=gray];
22 [label="Exit when"];
}
23 [label="Exit block"];
}
24 [label="Exit loop block"];
}
25 [label="Exit whileloop"];
}
26 [label="Access variable R|<local>/x|"];
27 [label="Function call: R|<local>/x|.R|/A.foo|()"];
28 [label="Exit function test_1" style="filled" fillcolor=red];
}
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {7};
6 -> {25} [style=dotted];
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {16 15};
15 -> {22};
16 -> {17};
17 -> {18};
18 -> {25};
18 -> {19} [style=dotted];
19 -> {20} [style=dotted];
20 -> {21} [style=dotted];
21 -> {22} [style=dotted];
22 -> {23};
23 -> {24};
24 -> {4};
25 -> {26};
26 -> {27};
27 -> {28};
subgraph cluster_9 {
color=red
29 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
30 [label="Enter while loop"];
subgraph cluster_11 {
color=blue
31 [label="Enter loop condition"];
32 [label="Const: Boolean(true)"];
33 [label="Exit loop condition"];
}
subgraph cluster_12 {
color=blue
34 [label="Enter loop block"];
subgraph cluster_13 {
color=blue
35 [label="Enter block"];
subgraph cluster_14 {
color=blue
36 [label="Enter when"];
subgraph cluster_15 {
color=blue
37 [label="Enter when branch condition "];
38 [label="Access variable R|<local>/b|"];
39 [label="Exit when branch condition"];
}
40 [label="Synthetic else branch"];
41 [label="Enter when branch result"];
subgraph cluster_16 {
color=blue
42 [label="Enter block"];
43 [label="Access variable R|<local>/x|"];
44 [label="Type operator: (R|<local>/x| as R|A|)"];
45 [label="Jump: break@@@[Boolean(true)] "];
46 [label="Stub" style="filled" fillcolor=gray];
47 [label="Exit block" style="filled" fillcolor=gray];
}
48 [label="Exit when branch result" style="filled" fillcolor=gray];
49 [label="Exit when"];
}
50 [label="Exit block"];
}
51 [label="Exit loop block"];
}
52 [label="Exit whileloop"];
}
53 [label="Access variable R|<local>/x|"];
54 [label="Function call: R|<local>/x|.R|/A.foo|()"];
55 [label="Exit function test_2" style="filled" fillcolor=red];
}
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
33 -> {52} [style=dotted];
34 -> {35};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {41 40};
40 -> {49};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {52};
45 -> {46} [style=dotted];
46 -> {47} [style=dotted];
47 -> {48} [style=dotted];
48 -> {49} [style=dotted];
49 -> {50};
50 -> {51};
51 -> {31};
52 -> {53};
53 -> {54};
54 -> {55};
subgraph cluster_17 {
color=red
56 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
57 [label="Enter while loop"];
subgraph cluster_19 {
color=blue
58 [label="Enter loop condition"];
59 [label="Const: Boolean(true)"];
60 [label="Exit loop condition"];
}
subgraph cluster_20 {
color=blue
61 [label="Enter loop block"];
subgraph cluster_21 {
color=blue
62 [label="Enter block"];
63 [label="Access variable R|<local>/x|"];
64 [label="Type operator: (R|<local>/x| as R|A|)"];
subgraph cluster_22 {
color=blue
65 [label="Enter when"];
subgraph cluster_23 {
color=blue
66 [label="Enter when branch condition "];
67 [label="Access variable R|<local>/b|"];
68 [label="Exit when branch condition"];
}
69 [label="Synthetic else branch"];
70 [label="Enter when branch result"];
subgraph cluster_24 {
color=blue
71 [label="Enter block"];
72 [label="Jump: break@@@[Boolean(true)] "];
73 [label="Stub" style="filled" fillcolor=gray];
74 [label="Exit block" style="filled" fillcolor=gray];
}
75 [label="Exit when branch result" style="filled" fillcolor=gray];
76 [label="Exit when"];
}
subgraph cluster_25 {
color=blue
77 [label="Enter when"];
subgraph cluster_26 {
color=blue
78 [label="Enter when branch condition "];
79 [label="Access variable R|<local>/b|"];
80 [label="Exit when branch condition"];
}
81 [label="Synthetic else branch"];
82 [label="Enter when branch result"];
subgraph cluster_27 {
color=blue
83 [label="Enter block"];
84 [label="Jump: break@@@[Boolean(true)] "];
85 [label="Stub" style="filled" fillcolor=gray];
86 [label="Exit block" style="filled" fillcolor=gray];
}
87 [label="Exit when branch result" style="filled" fillcolor=gray];
88 [label="Exit when"];
}
89 [label="Exit block"];
}
90 [label="Exit loop block"];
}
91 [label="Exit whileloop"];
}
92 [label="Access variable R|<local>/x|"];
93 [label="Function call: R|<local>/x|.R|/A.foo|()"];
94 [label="Exit function test_3" style="filled" fillcolor=red];
}
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
60 -> {91} [style=dotted];
61 -> {62};
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {70 69};
69 -> {76};
70 -> {71};
71 -> {72};
72 -> {91};
72 -> {73} [style=dotted];
73 -> {74} [style=dotted];
74 -> {75} [style=dotted];
75 -> {76} [style=dotted];
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {82 81};
81 -> {88};
82 -> {83};
83 -> {84};
84 -> {91};
84 -> {85} [style=dotted];
85 -> {86} [style=dotted];
86 -> {87} [style=dotted];
87 -> {88} [style=dotted];
88 -> {89};
89 -> {90};
90 -> {58};
91 -> {92};
92 -> {93};
93 -> {94};
subgraph cluster_28 {
color=red
95 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_29 {
color=blue
96 [label="Enter while loop"];
subgraph cluster_30 {
color=blue
97 [label="Enter loop condition"];
98 [label="Const: Boolean(true)"];
99 [label="Exit loop condition"];
}
subgraph cluster_31 {
color=blue
100 [label="Enter loop block"];
subgraph cluster_32 {
color=blue
101 [label="Enter block"];
subgraph cluster_33 {
color=blue
102 [label="Enter when"];
subgraph cluster_34 {
color=blue
103 [label="Enter when branch condition "];
104 [label="Access variable R|<local>/b|"];
105 [label="Exit when branch condition"];
}
106 [label="Synthetic else branch"];
107 [label="Enter when branch result"];
subgraph cluster_35 {
color=blue
108 [label="Enter block"];
109 [label="Access variable R|<local>/x|"];
110 [label="Type operator: (R|<local>/x| as R|A|)"];
111 [label="Jump: break@@@[Boolean(true)] "];
112 [label="Stub" style="filled" fillcolor=gray];
113 [label="Exit block" style="filled" fillcolor=gray];
}
114 [label="Exit when branch result" style="filled" fillcolor=gray];
115 [label="Exit when"];
}
116 [label="Jump: break@@@[Boolean(true)] "];
117 [label="Stub" style="filled" fillcolor=gray];
118 [label="Exit block" style="filled" fillcolor=gray];
}
119 [label="Exit loop block" style="filled" fillcolor=gray];
}
120 [label="Exit whileloop"];
}
121 [label="Access variable R|<local>/x|"];
122 [label="Function call: R|<local>/x|.<Unresolved name: foo>#()"];
123 [label="Exit function test_4" style="filled" fillcolor=red];
}
95 -> {96};
96 -> {97};
97 -> {98};
98 -> {99};
99 -> {100};
99 -> {120} [style=dotted];
100 -> {101};
101 -> {102};
102 -> {103};
103 -> {104};
104 -> {105};
105 -> {107 106};
106 -> {115};
107 -> {108};
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {120};
111 -> {112} [style=dotted];
112 -> {113} [style=dotted];
113 -> {114} [style=dotted];
114 -> {115} [style=dotted];
115 -> {116};
116 -> {120};
116 -> {117} [style=dotted];
117 -> {118} [style=dotted];
118 -> {119} [style=dotted];
119 -> {97} [style=dotted];
120 -> {121};
121 -> {122};
122 -> {123};
subgraph cluster_36 {
color=red
124 [label="Enter function test_5" style="filled" fillcolor=red];
subgraph cluster_37 {
color=blue
125 [label="Enter do-while loop"];
subgraph cluster_38 {
color=blue
126 [label="Enter loop block"];
subgraph cluster_39 {
color=blue
127 [label="Enter block"];
subgraph cluster_40 {
color=blue
128 [label="Enter when"];
subgraph cluster_41 {
color=blue
129 [label="Enter when branch condition "];
130 [label="Access variable R|<local>/b|"];
131 [label="Exit when branch condition"];
}
132 [label="Synthetic else branch"];
133 [label="Enter when branch result"];
subgraph cluster_42 {
color=blue
134 [label="Enter block"];
135 [label="Access variable R|<local>/x|"];
136 [label="Type operator: (R|<local>/x| as R|A|)"];
137 [label="Jump: break@@@[Boolean(true)] "];
138 [label="Stub" style="filled" fillcolor=gray];
139 [label="Exit block" style="filled" fillcolor=gray];
}
140 [label="Exit when branch result" style="filled" fillcolor=gray];
141 [label="Exit when"];
}
142 [label="Exit block"];
}
143 [label="Exit loop block"];
}
subgraph cluster_43 {
color=blue
144 [label="Enter loop condition"];
145 [label="Const: Boolean(true)"];
146 [label="Exit loop condition"];
}
147 [label="Exit do-whileloop"];
}
148 [label="Access variable R|<local>/x|"];
149 [label="Function call: R|<local>/x|.R|/A.foo|()"];
150 [label="Exit function test_5" style="filled" fillcolor=red];
}
124 -> {125};
125 -> {126};
126 -> {127};
127 -> {128};
128 -> {129};
129 -> {130};
130 -> {131};
131 -> {133 132};
132 -> {141};
133 -> {134};
134 -> {135};
135 -> {136};
136 -> {137};
137 -> {147};
137 -> {138} [style=dotted];
138 -> {139} [style=dotted];
139 -> {140} [style=dotted];
140 -> {141} [style=dotted];
141 -> {142};
142 -> {143};
143 -> {144};
144 -> {145};
145 -> {146};
146 -> {126};
146 -> {147} [style=dotted];
147 -> {148};
148 -> {149};
149 -> {150};
subgraph cluster_44 {
color=red
151 [label="Enter function test_6" style="filled" fillcolor=red];
subgraph cluster_45 {
color=blue
152 [label="Enter do-while loop"];
subgraph cluster_46 {
color=blue
153 [label="Enter loop block"];
subgraph cluster_47 {
color=blue
154 [label="Enter block"];
155 [label="Access variable R|<local>/x|"];
156 [label="Type operator: (R|<local>/x| as R|A|)"];
subgraph cluster_48 {
color=blue
157 [label="Enter when"];
subgraph cluster_49 {
color=blue
158 [label="Enter when branch condition "];
159 [label="Access variable R|<local>/b|"];
160 [label="Exit when branch condition"];
}
161 [label="Synthetic else branch"];
162 [label="Enter when branch result"];
subgraph cluster_50 {
color=blue
163 [label="Enter block"];
164 [label="Jump: break@@@[Boolean(true)] "];
165 [label="Stub" style="filled" fillcolor=gray];
166 [label="Exit block" style="filled" fillcolor=gray];
}
167 [label="Exit when branch result" style="filled" fillcolor=gray];
168 [label="Exit when"];
}
169 [label="Exit block"];
}
170 [label="Exit loop block"];
}
subgraph cluster_51 {
color=blue
171 [label="Enter loop condition"];
172 [label="Const: Boolean(true)"];
173 [label="Exit loop condition"];
}
174 [label="Exit do-whileloop"];
}
175 [label="Access variable R|<local>/x|"];
176 [label="Function call: R|<local>/x|.R|/A.foo|()"];
177 [label="Exit function test_6" style="filled" fillcolor=red];
}
151 -> {152};
152 -> {153};
153 -> {154};
154 -> {155};
155 -> {156};
156 -> {157};
157 -> {158};
158 -> {159};
159 -> {160};
160 -> {162 161};
161 -> {168};
162 -> {163};
163 -> {164};
164 -> {174};
164 -> {165} [style=dotted];
165 -> {166} [style=dotted];
166 -> {167} [style=dotted];
167 -> {168} [style=dotted];
168 -> {169};
169 -> {170};
170 -> {171};
171 -> {172};
172 -> {173};
173 -> {153};
173 -> {174} [style=dotted];
174 -> {175};
175 -> {176};
176 -> {177};
subgraph cluster_52 {
color=red
178 [label="Enter function test_7" style="filled" fillcolor=red];
subgraph cluster_53 {
color=blue
179 [label="Enter do-while loop"];
subgraph cluster_54 {
color=blue
180 [label="Enter loop block"];
subgraph cluster_55 {
color=blue
181 [label="Enter block"];
182 [label="Access variable R|<local>/x|"];
183 [label="Type operator: (R|<local>/x| as R|A|)"];
184 [label="Exit block"];
}
185 [label="Exit loop block"];
}
subgraph cluster_56 {
color=blue
186 [label="Enter loop condition"];
187 [label="Const: Boolean(true)"];
188 [label="Exit loop condition"];
}
189 [label="Exit do-whileloop" style="filled" fillcolor=gray];
}
190 [label="Access variable R|<local>/x|" style="filled" fillcolor=gray];
191 [label="Function call: R|<local>/x|.R|/A.foo|()" style="filled" fillcolor=gray];
192 [label="Exit function test_7" style="filled" fillcolor=red style="filled" fillcolor=gray];
}
178 -> {179};
179 -> {180};
180 -> {181};
181 -> {182};
182 -> {183};
183 -> {184};
184 -> {185};
185 -> {186};
186 -> {187};
187 -> {188};
188 -> {180};
188 -> {189} [style=dotted];
189 -> {190} [style=dotted];
190 -> {191} [style=dotted];
191 -> {192} [style=dotted];
}
@@ -0,0 +1,75 @@
// !DUMP_CFG
interface A {
fun foo()
}
fun test_1(x: Any, b: Boolean) {
while (true) {
x as A
if (b) {
break
}
}
x.foo()
}
fun test_2(x: Any, b: Boolean) {
while (true) {
if (b) {
x as A
break
}
}
x.foo()
}
fun test_3(x: Any, b: Boolean) {
while (true) {
x as A
if (b) {
break
}
if (b) {
break
}
}
x.foo()
}
fun test_4(x: Any, b: Boolean) {
while (true) {
if (b) {
x as A
break
}
break
}
x.<!UNRESOLVED_REFERENCE!>foo<!>() // No smartcast
}
fun test_5(x: Any, b: Boolean) {
do {
if (b) {
x as A
break
}
} while (true)
x.foo()
}
fun test_6(x: Any, b: Boolean) {
do {
x as A
if (b) {
break
}
} while (true)
x.foo()
}
fun test_7(x: Any) {
do {
x as A
} while (true)
x.foo()
}
@@ -0,0 +1,97 @@
FILE: endlessLoops.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public final fun test_1(x: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
while(Boolean(true)) {
(R|<local>/x| as R|A|)
when () {
R|<local>/b| -> {
break@@@[Boolean(true)]
}
}
}
R|<local>/x|.R|/A.foo|()
}
public final fun test_2(x: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
while(Boolean(true)) {
when () {
R|<local>/b| -> {
(R|<local>/x| as R|A|)
break@@@[Boolean(true)]
}
}
}
R|<local>/x|.R|/A.foo|()
}
public final fun test_3(x: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
while(Boolean(true)) {
(R|<local>/x| as R|A|)
when () {
R|<local>/b| -> {
break@@@[Boolean(true)]
}
}
when () {
R|<local>/b| -> {
break@@@[Boolean(true)]
}
}
}
R|<local>/x|.R|/A.foo|()
}
public final fun test_4(x: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
while(Boolean(true)) {
when () {
R|<local>/b| -> {
(R|<local>/x| as R|A|)
break@@@[Boolean(true)]
}
}
break@@@[Boolean(true)]
}
R|<local>/x|.<Unresolved name: foo>#()
}
public final fun test_5(x: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
do {
when () {
R|<local>/b| -> {
(R|<local>/x| as R|A|)
break@@@[Boolean(true)]
}
}
}
while(Boolean(true))
R|<local>/x|.R|/A.foo|()
}
public final fun test_6(x: R|kotlin/Any|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
do {
(R|<local>/x| as R|A|)
when () {
R|<local>/b| -> {
break@@@[Boolean(true)]
}
}
}
while(Boolean(true))
R|<local>/x|.R|/A.foo|()
}
public final fun test_7(x: R|kotlin/Any|): R|kotlin/Unit| {
do {
(R|<local>/x| as R|A|)
}
while(Boolean(true))
R|<local>/x|.R|/A.foo|()
}