do...while (true) is now considered infinite loop in CFA #KT-3896 Fixed
Also #KT-3883 Fixed Also #KT-4986 Fixed
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
== unreachable ==
|
||||
fun unreachable() {}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({})
|
||||
read (Unit)
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
== a ==
|
||||
fun a() {
|
||||
do {
|
||||
} while (true)
|
||||
unreachable()
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({ do { } while (true) unreachable() })
|
||||
3 mark(do { } while (true))
|
||||
L2 [loop entry point]:
|
||||
L4 [body entry point]:
|
||||
mark({ }) PREV:[mark(do { } while (true)), jmp(L2)]
|
||||
read (Unit)
|
||||
L5 [body exit point]:
|
||||
L6 [condition entry point]:
|
||||
r(true) -> <v0>
|
||||
magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
jmp(L2) NEXT:[mark({ })]
|
||||
L3 [loop exit point]:
|
||||
- read (Unit) PREV:[]
|
||||
- 2 mark(unreachable()) PREV:[]
|
||||
- call(unreachable(), unreachable) -> <v2> PREV:[]
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>] PREV:[]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
== b ==
|
||||
fun b() {
|
||||
while (true) {
|
||||
}
|
||||
unreachable()
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
2 mark({ while (true) { } unreachable() })
|
||||
L2 [loop entry point]:
|
||||
L6 [condition entry point]:
|
||||
r(true) -> <v0> PREV:[mark({ while (true) { } unreachable() }), jmp(L2)]
|
||||
mark(while (true) { })
|
||||
magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
L4 [body entry point]:
|
||||
3 mark({ })
|
||||
read (Unit)
|
||||
2 jmp(L2) NEXT:[r(true) -> <v0>]
|
||||
L3 [loop exit point]:
|
||||
L5 [body exit point]:
|
||||
- read (Unit) PREV:[]
|
||||
- mark(unreachable()) PREV:[]
|
||||
- call(unreachable(), unreachable) -> <v2> PREV:[]
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>] PREV:[]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
@@ -0,0 +1,13 @@
|
||||
fun unreachable() {}
|
||||
|
||||
fun a() {
|
||||
do {
|
||||
} while (true)
|
||||
unreachable()
|
||||
}
|
||||
|
||||
fun b() {
|
||||
while (true) {
|
||||
}
|
||||
unreachable()
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
== unreachable ==
|
||||
fun unreachable() {}
|
||||
---------------------
|
||||
=====================
|
||||
== a ==
|
||||
fun a() {
|
||||
do {
|
||||
} while (true)
|
||||
unreachable()
|
||||
}
|
||||
---------------------
|
||||
<v1>: * NEW: magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
true <v0>: * NEW: r(true) -> <v0>
|
||||
unreachable() <v2>: * NEW: call(unreachable(), unreachable) -> <v2>
|
||||
{ do { } while (true) unreachable() } <v2>: * COPY
|
||||
=====================
|
||||
== b ==
|
||||
fun b() {
|
||||
while (true) {
|
||||
}
|
||||
unreachable()
|
||||
}
|
||||
---------------------
|
||||
<v1>: * NEW: magic[VALUE_CONSUMER](true|<v0>) -> <v1>
|
||||
true <v0>: Boolean NEW: r(true) -> <v0>
|
||||
unreachable() <v2>: * NEW: call(unreachable(), unreachable) -> <v2>
|
||||
{ while (true) { } unreachable() } <v2>: * COPY
|
||||
=====================
|
||||
@@ -15,7 +15,7 @@ L0:
|
||||
3 mark(do { if (b) break; continue; } while (true))
|
||||
L2 [loop entry point]:
|
||||
L4 [body entry point]:
|
||||
mark({ if (b) break; continue; }) PREV:[mark(do { if (b) break; continue; } while (true)), jt(L2|<v5>)]
|
||||
mark({ if (b) break; continue; }) PREV:[mark(do { if (b) break; continue; } while (true)), jmp(L2)]
|
||||
mark(if (b) break)
|
||||
r(b) -> <v1>
|
||||
jf(L7|<v1>) NEXT:[read (Unit), jmp(L3)]
|
||||
@@ -29,13 +29,14 @@ L8 ['if' expression result]:
|
||||
L5 [body exit point]:
|
||||
L6 [condition entry point]:
|
||||
r(true) -> <v5>
|
||||
jt(L2|<v5>) NEXT:[read (Unit), mark({ if (b) break; continue; })]
|
||||
magic[VALUE_CONSUMER](true|<v5>) -> <v6>
|
||||
jmp(L2) NEXT:[mark({ if (b) break; continue; })]
|
||||
L3 [loop exit point]:
|
||||
read (Unit) PREV:[jmp(L3), jt(L2|<v5>)]
|
||||
read (Unit) PREV:[jmp(L3)]
|
||||
L1:
|
||||
1 <END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
=====================
|
||||
|
||||
@@ -7,12 +7,13 @@ fun test(b: Boolean) {
|
||||
}
|
||||
---------------------
|
||||
<v0>: Boolean NEW: magic[FAKE_INITIALIZER](b: Boolean) -> <v0>
|
||||
<v6>: * NEW: magic[VALUE_CONSUMER](true|<v5>) -> <v6>
|
||||
b <v1>: Boolean NEW: r(b) -> <v1>
|
||||
break !<v2>: *
|
||||
if (b) break <v3>: * NEW: merge(if (b) break|!<v2>) -> <v3>
|
||||
continue !<v4>: *
|
||||
{ if (b) break; continue; } !<v4>: * COPY
|
||||
true <v5>: Boolean NEW: r(true) -> <v5>
|
||||
do { if (b) break; continue; } while (true) !<v6>: *
|
||||
{ do { if (b) break; continue; } while (true); } !<v6>: * COPY
|
||||
=====================
|
||||
true <v5>: * NEW: r(true) -> <v5>
|
||||
do { if (b) break; continue; } while (true) !<v7>: *
|
||||
{ do { if (b) break; continue; } while (true); } !<v7>: * COPY
|
||||
=====================
|
||||
|
||||
Reference in New Issue
Block a user