Report 'break or continue outside a loop'

for break/continue outside a loop body (e.g. in loop condition)

 #KT-5724 Fixed
This commit is contained in:
Svetlana Isakova
2014-09-01 19:01:47 +04:00
parent 0b4f313b6d
commit 61dc110cc7
22 changed files with 355 additions and 275 deletions
@@ -19,19 +19,24 @@ package org.jetbrains.jet.lang.cfg;
import com.google.common.collect.Sets;
import org.jetbrains.jet.lang.psi.JetElement;
import java.util.Collections;
import java.util.Set;
public class BreakableBlockInfo extends BlockInfo {
private final JetElement element;
private final Label entryPoint;
private final Label exitPoint;
protected final Set<Label> referablePoints;
private final Set<Label> referablePoints = Sets.newHashSet();
public BreakableBlockInfo(JetElement element, Label entryPoint, Label exitPoint) {
this.element = element;
this.entryPoint = entryPoint;
this.exitPoint = exitPoint;
referablePoints = Sets.newHashSet(entryPoint, exitPoint);
markReferablePoints(entryPoint, exitPoint);
}
protected void markReferablePoints(Label... labels) {
Collections.addAll(referablePoints, labels);
}
public JetElement getElement() {
@@ -82,11 +82,12 @@ public interface JetControlFlowBuilder {
void throwException(@NotNull JetThrowExpression throwExpression, @NotNull PseudoValue thrownValue);
// Loops
LoopInfo enterLoop(@NotNull JetExpression expression, @Nullable Label loopExitPoint, @Nullable Label conditionEntryPoint);
void exitLoop(@NotNull JetExpression expression);
@NotNull
LoopInfo enterLoop(@NotNull JetLoopExpression expression);
void enterLoopBody(@NotNull JetLoopExpression expression);
void exitLoopBody(@NotNull JetLoopExpression expression);
@Nullable
JetElement getCurrentLoop();
JetLoopExpression getCurrentLoop();
// Try-Finally
void enterTryFinally(@NotNull GenerationTrigger trigger);
@@ -189,19 +189,25 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
return getDelegateBuilder().getConditionEntryPoint(labelElement);
}
@NotNull
@Override
public LoopInfo enterLoop(@NotNull JetExpression expression, @Nullable Label loopExitPoint, Label conditionEntryPoint) {
return getDelegateBuilder().enterLoop(expression, loopExitPoint, conditionEntryPoint);
public LoopInfo enterLoop(@NotNull JetLoopExpression expression) {
return getDelegateBuilder().enterLoop(expression);
}
@Override
public void exitLoop(@NotNull JetExpression expression) {
getDelegateBuilder().exitLoop(expression);
public void enterLoopBody(@NotNull JetLoopExpression expression) {
getDelegateBuilder().enterLoopBody(expression);
}
@Override
public void exitLoopBody(@NotNull JetLoopExpression expression) {
getDelegateBuilder().exitLoopBody(expression);
}
@Override
@Nullable
public JetElement getCurrentLoop() {
public JetLoopExpression getCurrentLoop() {
return getDelegateBuilder().getCurrentLoop();
}
@@ -39,7 +39,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils;
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
import org.jetbrains.jet.lang.resolve.calls.model.*;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.resolve.name.Name;
@@ -801,7 +800,7 @@ public class JetControlFlowProcessor {
@Override
public void visitWhileExpression(@NotNull JetWhileExpression expression) {
LoopInfo loopInfo = builder.enterLoop(expression, null, null);
LoopInfo loopInfo = builder.enterLoop(expression);
builder.bindLabel(loopInfo.getConditionEntryPoint());
JetExpression condition = expression.getCondition();
@@ -821,13 +820,14 @@ public class JetControlFlowProcessor {
builder.magic(condition, null, values, typePredicates, MagicKind.VALUE_CONSUMER);
}
builder.bindLabel(loopInfo.getBodyEntryPoint());
builder.enterLoopBody(expression);
JetExpression body = expression.getBody();
if (body != null) {
generateInstructions(body);
}
builder.jump(loopInfo.getEntryPoint(), expression);
builder.exitLoop(expression);
builder.exitLoopBody(expression);
builder.bindLabel(loopInfo.getExitPoint());
builder.loadUnit(expression);
}
@@ -835,20 +835,21 @@ public class JetControlFlowProcessor {
public void visitDoWhileExpression(@NotNull JetDoWhileExpression expression) {
builder.enterLexicalScope(expression);
mark(expression);
LoopInfo loopInfo = builder.enterLoop(expression, null, null);
LoopInfo loopInfo = builder.enterLoop(expression);
builder.bindLabel(loopInfo.getBodyEntryPoint());
builder.enterLoopBody(expression);
JetExpression body = expression.getBody();
if (body != null) {
generateInstructions(body);
}
builder.exitLoopBody(expression);
builder.bindLabel(loopInfo.getConditionEntryPoint());
JetExpression condition = expression.getCondition();
if (condition != null) {
generateInstructions(condition);
}
builder.jumpOnTrue(loopInfo.getEntryPoint(), expression, builder.getBoundValue(condition));
builder.exitLoop(expression);
builder.bindLabel(loopInfo.getExitPoint());
builder.loadUnit(expression);
builder.exitLexicalScope(expression);
}
@@ -864,26 +865,24 @@ public class JetControlFlowProcessor {
declareLoopParameter(expression);
// TODO : primitive cases
Label loopExitPoint = builder.createUnboundLabel("'for' loop exit point");
Label conditionEntryPoint = builder.createUnboundLabel("'for' loop condition entry point");
LoopInfo loopInfo = builder.enterLoop(expression);
builder.bindLabel(conditionEntryPoint);
builder.nondeterministicJump(loopExitPoint, expression, null);
builder.bindLabel(loopInfo.getConditionEntryPoint());
builder.nondeterministicJump(loopInfo.getExitPoint(), expression, null);
LoopInfo loopInfo = builder.enterLoop(expression, loopExitPoint, conditionEntryPoint);
builder.bindLabel(loopInfo.getBodyEntryPoint());
writeLoopParameterAssignment(expression);
mark(expression);
builder.enterLoopBody(expression);
JetExpression body = expression.getBody();
if (body != null) {
generateInstructions(body);
}
builder.jump(loopInfo.getEntryPoint(), expression);
builder.nondeterministicJump(loopInfo.getEntryPoint(), expression, null);
builder.exitLoop(expression);
builder.exitLoopBody(expression);
builder.bindLabel(loopInfo.getExitPoint());
builder.loadUnit(expression);
builder.exitLexicalScope(expression);
}
@@ -957,9 +956,10 @@ public class JetControlFlowProcessor {
}
}
@Nullable
private JetElement getCorrespondingLoop(JetExpressionWithLabel expression) {
String labelName = expression.getLabelName();
JetElement loop;
JetLoopExpression loop;
if (labelName != null) {
JetSimpleNameExpression targetLabel = expression.getTargetLabel();
assert targetLabel != null;
@@ -978,6 +978,12 @@ public class JetControlFlowProcessor {
trace.report(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP.on(expression));
}
}
if (loop != null && loop.getBody() != null
// the faster version of 'isAncestor' check:
&& !loop.getBody().getTextRange().contains(expression.getTextRange())) {
trace.report(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP.on(expression));
return null;
}
return loop;
}
@@ -16,27 +16,41 @@
package org.jetbrains.jet.lang.cfg;
import com.google.common.collect.Sets;
import org.jetbrains.jet.lang.psi.JetElement;
import java.util.Set;
import org.jetbrains.jet.lang.psi.JetLoopExpression;
public class LoopInfo extends BreakableBlockInfo {
private final Label bodyEntryPoint;
private final Label bodyExitPoint;
private final Label conditionEntryPoint;
public LoopInfo(JetElement element, Label entryPoint, Label exitPoint, Label bodyEntryPoint, Label conditionEntryPoint) {
super(element, entryPoint, exitPoint);
public LoopInfo(
JetLoopExpression loopExpression,
Label entryPoint,
Label exitPoint,
Label bodyEntryPoint,
Label bodyExitPoint,
Label conditionEntryPoint
) {
super(loopExpression, entryPoint, exitPoint);
this.bodyEntryPoint = bodyEntryPoint;
this.bodyExitPoint = bodyExitPoint;
this.conditionEntryPoint = conditionEntryPoint;
referablePoints.add(bodyEntryPoint);
referablePoints.add(conditionEntryPoint);
markReferablePoints(bodyEntryPoint, bodyExitPoint, conditionEntryPoint);
}
@Override
public JetLoopExpression getElement() {
return (JetLoopExpression) super.getElement();
}
public Label getBodyEntryPoint() {
return bodyEntryPoint;
}
public Label getBodyExitPoint() {
return bodyExitPoint;
}
public Label getConditionEntryPoint() {
return conditionEntryPoint;
}
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.cfg.pseudocode;
import com.google.common.collect.Sets;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -39,7 +38,7 @@ import java.util.*;
public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAdapter {
private JetControlFlowBuilder builder = null;
private final Stack<BreakableBlockInfo> loopInfo = new Stack<BreakableBlockInfo>();
private final Stack<LoopInfo> loopInfo = new Stack<LoopInfo>();
private final Stack<LexicalScope> lexicalScopes = new Stack<LexicalScope>();
private final Map<JetElement, BreakableBlockInfo> elementToBlockInfo = new HashMap<JetElement, BreakableBlockInfo>();
private int labelCount = 0;
@@ -143,33 +142,40 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
return pseudocode.createLabel("L" + labelCount++ + " [" + name + "]");
}
@NotNull
@Override
public final LoopInfo enterLoop(@NotNull JetExpression expression, @Nullable Label loopExitPoint, Label conditionEntryPoint) {
public final LoopInfo enterLoop(@NotNull JetLoopExpression expression) {
Label loopEntryLabel = createUnboundLabel("loop entry point");
bindLabel(loopEntryLabel);
LoopInfo blockInfo = new LoopInfo(
expression,
loopEntryLabel,
loopExitPoint != null ? loopExitPoint : createUnboundLabel("loop exit point"),
createUnboundLabel("loop exit point"),
createUnboundLabel("body entry point"),
conditionEntryPoint != null ? conditionEntryPoint : createUnboundLabel("condition entry point"));
loopInfo.push(blockInfo);
createUnboundLabel("body exit point"),
createUnboundLabel("condition entry point"));
elementToBlockInfo.put(expression, blockInfo);
allBlocks.push(blockInfo);
pseudocode.recordLoopInfo(expression, blockInfo);
return blockInfo;
}
@Override
public final void exitLoop(@NotNull JetExpression expression) {
BreakableBlockInfo info = loopInfo.pop();
elementToBlockInfo.remove(expression);
allBlocks.pop();
bindLabel(info.getExitPoint());
public void enterLoopBody(@NotNull JetLoopExpression expression) {
LoopInfo info = (LoopInfo) elementToBlockInfo.get(expression);
bindLabel(info.getBodyEntryPoint());
loopInfo.push(info);
allBlocks.push(info);
}
@Override
public JetElement getCurrentLoop() {
public final void exitLoopBody(@NotNull JetLoopExpression expression) {
LoopInfo info = loopInfo.pop();
elementToBlockInfo.remove(expression);
allBlocks.pop();
bindLabel(info.getBodyExitPoint());
}
@Override
public JetLoopExpression getCurrentLoop() {
return loopInfo.empty() ? null : loopInfo.peek().getElement();
}
@@ -101,8 +101,7 @@ public class PseudocodeImpl implements Pseudocode {
private Set<LocalFunctionDeclarationInstruction> localDeclarations = null;
//todo getters
private final Map<JetElement, Instruction> representativeInstructions = new HashMap<JetElement, Instruction>();
private final Map<JetExpression, LoopInfo> loopInfo = Maps.newHashMap();
private final List<PseudocodeLabel> labels = new ArrayList<PseudocodeLabel>();
private final JetElement correspondingElement;
@@ -245,10 +244,6 @@ public class PseudocodeImpl implements Pseudocode {
}
}
/*package*/ void recordLoopInfo(JetExpression expression, LoopInfo blockInfo) {
loopInfo.put(expression, blockInfo);
}
@Override
@NotNull
public SubroutineExitInstruction getExitInstruction() {
@@ -21,13 +21,13 @@ L0:
2 mark({ for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue } }) INIT: in: {numbers=ID} out: {numbers=ID} USE: in: {numbers=READ} out: {numbers=READ}
3 r(numbers) -> <v1> USE: in: {} out: {numbers=READ}
v(i) INIT: in: {numbers=ID} out: {i=D, numbers=ID}
L3 ['for' loop condition entry point]:
jmp?(L2 ['for' loop exit point]) INIT: in: {i=D, numbers=ID} out: {i=D, numbers=ID}
L4 [loop entry point]:
L5 [body entry point]:
L2 [loop entry point]:
L6 [condition entry point]:
jmp?(L3 [loop exit point]) INIT: in: {i=D, numbers=ID} out: {i=D, numbers=ID}
magic[LOOP_RANGE_ITERATION](numbers|<v1>) -> <v2>
w(i|<v2>) INIT: in: {i=D, numbers=ID} out: {i=ID, numbers=ID}
mark(for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID} USE: in: {} out: {}
L4 [body entry point]:
4 mark({ val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue })
v(val b: Boolean) INIT: in: {i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID}
mark(if (1 < 2) { b = false } else { b = true }) INIT: in: {b=D, i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID}
@@ -35,23 +35,24 @@ L5 [body entry point]:
r(2) -> <v4>
mark(1 < 2)
call(1 < 2, compareTo|<v3>, <v4>) -> <v5>
jf(L6 [else branch]|<v5>)
jf(L7 [else branch]|<v5>)
5 mark({ b = false })
r(false) -> <v6> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
w(b|<v6>) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
4 jmp(L7 ['if' expression result]) INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=READ}
L6 [else branch]:
4 jmp(L8 ['if' expression result]) INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=READ}
L7 [else branch]:
5 mark({ b = true }) INIT: in: {b=D, i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID}
r(true) -> <v8> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
w(b|<v8>) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
L7 ['if' expression result]:
L8 ['if' expression result]:
4 merge(if (1 < 2) { b = false } else { b = true }|!<v7>, !<v9>) -> <v10> INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=READ}
r(b) -> <v11> USE: in: {} out: {b=READ}
mark(use(b))
call(use(b), use|<v11>) -> <v12>
jmp(L3 ['for' loop condition entry point]) USE: in: {} out: {}
- 3 jmp?(L4 [loop entry point])
L2 ['for' loop exit point]:
jmp(L6 [condition entry point]) USE: in: {} out: {}
- 3 jmp(L2 [loop entry point])
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) INIT: in: {i=D, numbers=ID} out: {i=D, numbers=ID}
L1:
1 <END> INIT: in: {numbers=ID} out: {numbers=ID}
@@ -76,4 +77,4 @@ error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {}
=====================
=====================
@@ -19,7 +19,8 @@ L4 [body entry point]:
v(var a = 2)
r(2) -> <v1>
w(a|<v1>)
L5 [condition entry point]:
L5 [body exit point]:
L6 [condition entry point]:
r(a) -> <v2>
r(0) -> <v3>
mark(a > 0)
@@ -17,19 +17,20 @@ L0:
mark(1..10)
call(1..10, rangeTo|<v1>, <v2>) -> <v3>
v(i) INIT: in: {} out: {i=D}
L3 ['for' loop condition entry point]:
jmp?(L2 ['for' loop exit point]) INIT: in: {i=D} out: {i=D}
L4 [loop entry point]:
L5 [body entry point]:
L2 [loop entry point]:
L6 [condition entry point]:
jmp?(L3 [loop exit point]) INIT: in: {i=D} out: {i=D}
magic[LOOP_RANGE_ITERATION](1..10|<v3>) -> <v4>
w(i|<v4>) INIT: in: {i=D} out: {i=ID}
mark(for (i in 1..10) { val a = i }) INIT: in: {i=ID} out: {i=ID}
L4 [body entry point]:
4 mark({ val a = i })
v(val a = i) INIT: in: {i=ID} out: {a=D, i=ID}
r(i) -> <v5> INIT: in: {a=D, i=ID} out: {a=D, i=ID}
w(a|<v5>) INIT: in: {a=D, i=ID} out: {a=ID, i=ID}
3 jmp?(L4 [loop entry point]) INIT: in: {i=ID} out: {i=ID} USE: in: {i=READ} out: {i=READ}
L2 ['for' loop exit point]:
3 jmp(L2 [loop entry point]) INIT: in: {i=ID} out: {i=ID} USE: in: {i=READ} out: {i=READ}
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) INIT: in: {i=D} out: {i=D}
2 mark("after") INIT: in: {} out: {}
r("after") -> <v6>
@@ -39,4 +40,4 @@ error:
<ERROR>
sink:
<SINK> USE: in: {} out: {}
=====================
=====================
@@ -13,7 +13,7 @@ L0:
mark("before")
r("before") -> <v0>
L2 [loop entry point]:
L5 [condition entry point]:
L6 [condition entry point]:
r(true) -> <v1>
mark(while (true) { val a: Int })
magic[VALUE_CONSUMER](true|<v1>) -> <v2>
@@ -22,6 +22,7 @@ L4 [body entry point]:
v(val a: Int) INIT: in: {} out: {a=D}
2 jmp(L2 [loop entry point]) INIT: in: {} out: {} USE: in: {} out: {}
L3 [loop exit point]:
L5 [body exit point]:
- read (Unit)
- mark("after")
- r("after") -> <v3>
@@ -15,22 +15,23 @@ L0:
2 mark({ for (e in c) { { break } } })
3 r(c) -> <v1>
v(e)
L3 ['for' loop condition entry point]:
jmp?(L2 ['for' loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](c|<v1>) -> <v2>]
L4 [loop entry point]:
L5 [body entry point]:
magic[LOOP_RANGE_ITERATION](c|<v1>) -> <v2> PREV:[jmp?(L2 ['for' loop exit point]), jmp?(L4 [loop entry point])]
L2 [loop entry point]:
L6 [condition entry point]:
jmp?(L3 [loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](c|<v1>) -> <v2>] PREV:[v(e), jmp(L2 [loop entry point])]
magic[LOOP_RANGE_ITERATION](c|<v1>) -> <v2>
w(e|<v2>)
mark(for (e in c) { { break } })
L4 [body entry point]:
4 mark({ { break } })
mark({ break })
jmp?(L6 [after local declaration]) NEXT:[r({ break }) -> <v3>, d({ break })]
jmp?(L7 [after local declaration]) NEXT:[r({ break }) -> <v3>, d({ break })]
d({ break }) NEXT:[<SINK>]
L6 [after local declaration]:
r({ break }) -> <v3> PREV:[jmp?(L6 [after local declaration])]
3 jmp?(L4 [loop entry point]) NEXT:[magic[LOOP_RANGE_ITERATION](c|<v1>) -> <v2>, read (Unit)]
L2 ['for' loop exit point]:
read (Unit) PREV:[jmp?(L2 ['for' loop exit point]), jmp(L2 ['for' loop exit point]), jmp?(L4 [loop entry point])]
L7 [after local declaration]:
r({ break }) -> <v3> PREV:[jmp?(L7 [after local declaration])]
3 jmp(L2 [loop entry point]) NEXT:[jmp?(L3 [loop exit point])]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jmp?(L3 [loop exit point]), jmp(L3 [loop exit point])]
L1:
1 <END> NEXT:[<SINK>]
error:
@@ -43,15 +44,15 @@ sink:
break
}
---------------------
L7:
L8:
5 <START>
6 mark(break)
jmp(L2 ['for' loop exit point]) NEXT:[read (Unit)]
- 5 ret(*|!<v0>) L8 PREV:[]
L8:
<END> NEXT:[<SINK>] PREV:[]
jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- 5 ret(*|!<v0>) L9 PREV:[]
L9:
<END> NEXT:[<SINK>] PREV:[]
error:
<ERROR> PREV:[]
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -260,14 +260,14 @@ L0:
2 mark({ @l while(true) { try { 1 if (2 > 3) { break @l } } finally { 2 } } })
mark(@l while(true) { try { 1 if (2 > 3) { break @l } } finally { 2 } })
L2 [loop entry point]:
L5 [condition entry point]:
L6 [condition entry point]:
r(true) -> <v0> PREV:[mark(@l while(true) { try { 1 if (2 > 3) { break @l } } finally { 2 } }), jmp(L2 [loop entry point])]
mark(while(true) { try { 1 if (2 > 3) { break @l } } finally { 2 } })
magic[VALUE_CONSUMER](true|<v0>) -> <v1>
L4 [body entry point]:
3 mark({ try { 1 if (2 > 3) { break @l } } finally { 2 } })
mark(try { 1 if (2 > 3) { break @l } } finally { 2 })
jmp?(L6 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { break @l } })]
jmp?(L7 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { break @l } })]
4 mark({ 1 if (2 > 3) { break @l } })
r(1) -> <v2>
mark(if (2 > 3) { break @l })
@@ -275,29 +275,30 @@ L4 [body entry point]:
r(3) -> <v4>
mark(2 > 3)
call(2 > 3, compareTo|<v3>, <v4>) -> <v5>
jf(L7 [else branch]|<v5>) NEXT:[read (Unit), mark({ break @l })]
jf(L8 [else branch]|<v5>) NEXT:[read (Unit), mark({ break @l })]
5 mark({ break @l })
L8 [start finally]:
L9 [start finally]:
6 mark({ 2 })
r(2) -> <v6>
L9 [finish finally]:
L10 [finish finally]:
5 jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- 4 jmp(L10 ['if' expression result]) NEXT:[merge(if (2 > 3) { break @l }|!<v7>) -> <v8>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v5>)]
L10 ['if' expression result]:
- 4 jmp(L11 ['if' expression result]) NEXT:[merge(if (2 > 3) { break @l }|!<v7>) -> <v8>] PREV:[]
L8 [else branch]:
read (Unit) PREV:[jf(L8 [else branch]|<v5>)]
L11 ['if' expression result]:
merge(if (2 > 3) { break @l }|!<v7>) -> <v8>
3 jmp(L11 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L6 [onExceptionToFinallyBlock]:
6 mark({ 2 }) PREV:[jmp?(L6 [onExceptionToFinallyBlock])]
3 jmp(L12 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L7 [onExceptionToFinallyBlock]:
6 mark({ 2 }) PREV:[jmp?(L7 [onExceptionToFinallyBlock])]
r(2) -> <v6>
3 jmp(error) NEXT:[<ERROR>]
L11 [skipFinallyToErrorBlock]:
6 mark({ 2 }) PREV:[jmp(L11 [skipFinallyToErrorBlock])]
L12 [skipFinallyToErrorBlock]:
6 mark({ 2 }) PREV:[jmp(L12 [skipFinallyToErrorBlock])]
r(2) -> <v6>
3 merge(try { 1 if (2 > 3) { break @l } } finally { 2 }|<v8>) -> <v9>
2 jmp(L2 [loop entry point]) NEXT:[r(true) -> <v0>]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jmp(L3 [loop exit point])]
L1:
1 <END> NEXT:[<SINK>]
@@ -329,7 +330,7 @@ L0:
3 mark({ @l while(true) { 1 if (2 > 3) { break @l } } 5 })
mark(@l while(true) { 1 if (2 > 3) { break @l } })
L3 [loop entry point]:
L6 [condition entry point]:
L7 [condition entry point]:
r(true) -> <v0> PREV:[mark(@l while(true) { 1 if (2 > 3) { break @l } }), jmp(L3 [loop entry point])]
mark(while(true) { 1 if (2 > 3) { break @l } })
magic[VALUE_CONSUMER](true|<v0>) -> <v1>
@@ -341,27 +342,28 @@ L5 [body entry point]:
r(3) -> <v4>
mark(2 > 3)
call(2 > 3, compareTo|<v3>, <v4>) -> <v5>
jf(L7 [else branch]|<v5>) NEXT:[read (Unit), mark({ break @l })]
jf(L8 [else branch]|<v5>) NEXT:[read (Unit), mark({ break @l })]
5 mark({ break @l })
jmp(L4 [loop exit point]) NEXT:[read (Unit)]
- 4 jmp(L8 ['if' expression result]) NEXT:[merge(if (2 > 3) { break @l }|!<v6>) -> <v7>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v5>)]
L8 ['if' expression result]:
- 4 jmp(L9 ['if' expression result]) NEXT:[merge(if (2 > 3) { break @l }|!<v6>) -> <v7>] PREV:[]
L8 [else branch]:
read (Unit) PREV:[jf(L8 [else branch]|<v5>)]
L9 ['if' expression result]:
merge(if (2 > 3) { break @l }|!<v6>) -> <v7>
3 jmp(L3 [loop entry point]) NEXT:[r(true) -> <v0>]
L4 [loop exit point]:
L6 [body exit point]:
read (Unit) PREV:[jmp(L4 [loop exit point])]
r(5) -> <v9>
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
2 jmp(L10 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]:
L10 [start finally]:
L11 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2) -> <v10>
L11 [finish finally]:
L12 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L9 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L9 [skipFinallyToErrorBlock])]
L10 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L10 [skipFinallyToErrorBlock])]
r(2) -> <v10>
2 merge(try { @l while(true) { 1 if (2 > 3) { break @l } } 5 } finally { 2 }|<v9>) -> <v11>
L1:
@@ -393,7 +395,7 @@ L0:
3 mark({ @l while(true) { 1 if (2 > 3) { break @l } } })
mark(@l while(true) { 1 if (2 > 3) { break @l } })
L3 [loop entry point]:
L6 [condition entry point]:
L7 [condition entry point]:
r(true) -> <v0> PREV:[mark(@l while(true) { 1 if (2 > 3) { break @l } }), jmp(L3 [loop entry point])]
mark(while(true) { 1 if (2 > 3) { break @l } })
magic[VALUE_CONSUMER](true|<v0>) -> <v1>
@@ -405,26 +407,27 @@ L5 [body entry point]:
r(3) -> <v4>
mark(2 > 3)
call(2 > 3, compareTo|<v3>, <v4>) -> <v5>
jf(L7 [else branch]|<v5>) NEXT:[read (Unit), mark({ break @l })]
jf(L8 [else branch]|<v5>) NEXT:[read (Unit), mark({ break @l })]
5 mark({ break @l })
jmp(L4 [loop exit point]) NEXT:[read (Unit)]
- 4 jmp(L8 ['if' expression result]) NEXT:[merge(if (2 > 3) { break @l }|!<v6>) -> <v7>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v5>)]
L8 ['if' expression result]:
- 4 jmp(L9 ['if' expression result]) NEXT:[merge(if (2 > 3) { break @l }|!<v6>) -> <v7>] PREV:[]
L8 [else branch]:
read (Unit) PREV:[jf(L8 [else branch]|<v5>)]
L9 ['if' expression result]:
merge(if (2 > 3) { break @l }|!<v6>) -> <v7>
3 jmp(L3 [loop entry point]) NEXT:[r(true) -> <v0>]
L4 [loop exit point]:
L6 [body exit point]:
read (Unit) PREV:[jmp(L4 [loop exit point])]
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
2 jmp(L10 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]:
L10 [start finally]:
L11 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2) -> <v9>
L11 [finish finally]:
L12 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L9 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L9 [skipFinallyToErrorBlock])]
L10 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L10 [skipFinallyToErrorBlock])]
r(2) -> <v9>
2 merge(try { @l while(true) { 1 if (2 > 3) { break @l } } } finally { 2 }|!<v8>) -> <v10>
L1:
@@ -460,16 +463,16 @@ L0:
mark(1..a)
call(1..a, rangeTo|<v1>, <v2>) -> <v3>
v(i)
L3 ['for' loop condition entry point]:
jmp?(L2 ['for' loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>] PREV:[v(i), jmp(L3 ['for' loop condition entry point])]
L4 [loop entry point]:
L5 [body entry point]:
magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4> PREV:[jmp?(L2 ['for' loop exit point]), jmp?(L4 [loop entry point])]
L2 [loop entry point]:
L6 [condition entry point]:
jmp?(L3 [loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>] PREV:[v(i), jmp(L6 [condition entry point]), jmp(L2 [loop entry point])]
magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>
w(i|<v4>)
mark(for (i in 1..a) { try { 1 if (2 > 3) { continue @l } } finally { 2 } })
L4 [body entry point]:
4 mark({ try { 1 if (2 > 3) { continue @l } } finally { 2 } })
mark(try { 1 if (2 > 3) { continue @l } } finally { 2 })
jmp?(L6 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { continue @l } })]
jmp?(L7 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { continue @l } })]
5 mark({ 1 if (2 > 3) { continue @l } })
r(1) -> <v5>
mark(if (2 > 3) { continue @l })
@@ -477,30 +480,31 @@ L5 [body entry point]:
r(3) -> <v7>
mark(2 > 3)
call(2 > 3, compareTo|<v6>, <v7>) -> <v8>
jf(L7 [else branch]|<v8>) NEXT:[read (Unit), mark({ continue @l })]
jf(L8 [else branch]|<v8>) NEXT:[read (Unit), mark({ continue @l })]
6 mark({ continue @l })
L8 [start finally]:
L9 [start finally]:
7 mark({ 2 })
r(2) -> <v9>
L9 [finish finally]:
6 jmp(L3 ['for' loop condition entry point]) NEXT:[jmp?(L2 ['for' loop exit point])]
- 5 jmp(L10 ['if' expression result]) NEXT:[merge(if (2 > 3) { continue @l }|!<v10>) -> <v11>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v8>)]
L10 ['if' expression result]:
L10 [finish finally]:
6 jmp(L6 [condition entry point]) NEXT:[jmp?(L3 [loop exit point])]
- 5 jmp(L11 ['if' expression result]) NEXT:[merge(if (2 > 3) { continue @l }|!<v10>) -> <v11>] PREV:[]
L8 [else branch]:
read (Unit) PREV:[jf(L8 [else branch]|<v8>)]
L11 ['if' expression result]:
merge(if (2 > 3) { continue @l }|!<v10>) -> <v11>
4 jmp(L11 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L6 [onExceptionToFinallyBlock]:
7 mark({ 2 }) PREV:[jmp?(L6 [onExceptionToFinallyBlock])]
4 jmp(L12 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L7 [onExceptionToFinallyBlock]:
7 mark({ 2 }) PREV:[jmp?(L7 [onExceptionToFinallyBlock])]
r(2) -> <v9>
4 jmp(error) NEXT:[<ERROR>]
L11 [skipFinallyToErrorBlock]:
7 mark({ 2 }) PREV:[jmp(L11 [skipFinallyToErrorBlock])]
L12 [skipFinallyToErrorBlock]:
7 mark({ 2 }) PREV:[jmp(L12 [skipFinallyToErrorBlock])]
r(2) -> <v9>
4 merge(try { 1 if (2 > 3) { continue @l } } finally { 2 }|<v11>) -> <v12>
3 jmp?(L4 [loop entry point]) NEXT:[magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>, read (Unit)]
L2 ['for' loop exit point]:
read (Unit) PREV:[jmp?(L2 ['for' loop exit point]), jmp?(L4 [loop entry point])]
3 jmp(L2 [loop entry point]) NEXT:[jmp?(L3 [loop exit point])]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jmp?(L3 [loop exit point])]
L1:
1 <END> NEXT:[<SINK>]
error:
@@ -538,13 +542,13 @@ L0:
mark(1..a)
call(1..a, rangeTo|<v1>, <v2>) -> <v3>
v(i)
L4 ['for' loop condition entry point]:
jmp?(L3 ['for' loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>] PREV:[v(i), jmp(L4 ['for' loop condition entry point])]
L5 [loop entry point]:
L6 [body entry point]:
magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4> PREV:[jmp?(L3 ['for' loop exit point]), jmp?(L5 [loop entry point])]
L3 [loop entry point]:
L7 [condition entry point]:
jmp?(L4 [loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>] PREV:[v(i), jmp(L7 [condition entry point]), jmp(L3 [loop entry point])]
magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>
w(i|<v4>)
mark(for (i in 1..a) { 1 if (2 > 3) { continue @l } })
L5 [body entry point]:
5 mark({ 1 if (2 > 3) { continue @l } })
r(1) -> <v5>
mark(if (2 > 3) { continue @l })
@@ -552,27 +556,28 @@ L6 [body entry point]:
r(3) -> <v7>
mark(2 > 3)
call(2 > 3, compareTo|<v6>, <v7>) -> <v8>
jf(L7 [else branch]|<v8>) NEXT:[read (Unit), mark({ continue @l })]
jf(L8 [else branch]|<v8>) NEXT:[read (Unit), mark({ continue @l })]
6 mark({ continue @l })
jmp(L4 ['for' loop condition entry point]) NEXT:[jmp?(L3 ['for' loop exit point])]
- 5 jmp(L8 ['if' expression result]) NEXT:[merge(if (2 > 3) { continue @l }|!<v9>) -> <v10>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v8>)]
L8 ['if' expression result]:
jmp(L7 [condition entry point]) NEXT:[jmp?(L4 [loop exit point])]
- 5 jmp(L9 ['if' expression result]) NEXT:[merge(if (2 > 3) { continue @l }|!<v9>) -> <v10>] PREV:[]
L8 [else branch]:
read (Unit) PREV:[jf(L8 [else branch]|<v8>)]
L9 ['if' expression result]:
merge(if (2 > 3) { continue @l }|!<v9>) -> <v10>
4 jmp?(L5 [loop entry point]) NEXT:[magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>, read (Unit)]
L3 ['for' loop exit point]:
read (Unit) PREV:[jmp?(L3 ['for' loop exit point]), jmp?(L5 [loop entry point])]
4 jmp(L3 [loop entry point]) NEXT:[jmp?(L4 [loop exit point])]
L4 [loop exit point]:
L6 [body exit point]:
read (Unit) PREV:[jmp?(L4 [loop exit point])]
3 r(5) -> <v12>
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
2 jmp(L10 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]:
L10 [start finally]:
L11 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2) -> <v13>
L11 [finish finally]:
L12 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L9 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L9 [skipFinallyToErrorBlock])]
L10 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L10 [skipFinallyToErrorBlock])]
r(2) -> <v13>
2 merge(try { @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } 5 } finally { 2 }|<v12>) -> <v14>
L1:
@@ -611,13 +616,13 @@ L0:
mark(1..a)
call(1..a, rangeTo|<v1>, <v2>) -> <v3>
v(i)
L4 ['for' loop condition entry point]:
jmp?(L3 ['for' loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>] PREV:[v(i), jmp(L4 ['for' loop condition entry point])]
L5 [loop entry point]:
L6 [body entry point]:
magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4> PREV:[jmp?(L3 ['for' loop exit point]), jmp?(L5 [loop entry point])]
L3 [loop entry point]:
L7 [condition entry point]:
jmp?(L4 [loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>] PREV:[v(i), jmp(L7 [condition entry point]), jmp(L3 [loop entry point])]
magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>
w(i|<v4>)
mark(for (i in 1..a) { 1 if (2 > 3) { continue @l } })
L5 [body entry point]:
5 mark({ 1 if (2 > 3) { continue @l } })
r(1) -> <v5>
mark(if (2 > 3) { continue @l })
@@ -625,26 +630,27 @@ L6 [body entry point]:
r(3) -> <v7>
mark(2 > 3)
call(2 > 3, compareTo|<v6>, <v7>) -> <v8>
jf(L7 [else branch]|<v8>) NEXT:[read (Unit), mark({ continue @l })]
jf(L8 [else branch]|<v8>) NEXT:[read (Unit), mark({ continue @l })]
6 mark({ continue @l })
jmp(L4 ['for' loop condition entry point]) NEXT:[jmp?(L3 ['for' loop exit point])]
- 5 jmp(L8 ['if' expression result]) NEXT:[merge(if (2 > 3) { continue @l }|!<v9>) -> <v10>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v8>)]
L8 ['if' expression result]:
jmp(L7 [condition entry point]) NEXT:[jmp?(L4 [loop exit point])]
- 5 jmp(L9 ['if' expression result]) NEXT:[merge(if (2 > 3) { continue @l }|!<v9>) -> <v10>] PREV:[]
L8 [else branch]:
read (Unit) PREV:[jf(L8 [else branch]|<v8>)]
L9 ['if' expression result]:
merge(if (2 > 3) { continue @l }|!<v9>) -> <v10>
4 jmp?(L5 [loop entry point]) NEXT:[magic[LOOP_RANGE_ITERATION](1..a|<v3>) -> <v4>, read (Unit)]
L3 ['for' loop exit point]:
read (Unit) PREV:[jmp?(L3 ['for' loop exit point]), jmp?(L5 [loop entry point])]
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
4 jmp(L3 [loop entry point]) NEXT:[jmp?(L4 [loop exit point])]
L4 [loop exit point]:
L6 [body exit point]:
read (Unit) PREV:[jmp?(L4 [loop exit point])]
2 jmp(L10 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]:
L10 [start finally]:
L11 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2) -> <v12>
L11 [finish finally]:
L12 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L9 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L9 [skipFinallyToErrorBlock])]
L10 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L10 [skipFinallyToErrorBlock])]
r(2) -> <v12>
2 merge(try { @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } } finally { 2 }|!<v11>) -> <v13>
L1:
@@ -973,4 +979,4 @@ error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================
@@ -141,67 +141,68 @@ L0:
1 <START>
2 mark({ while (cond()) { try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } } })
L2 [loop entry point]:
L5 [condition entry point]:
mark(cond()) PREV:[mark({ while (cond()) { try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } } }), jmp(L5 [condition entry point]), jmp(L5 [condition entry point])]
L6 [condition entry point]:
mark(cond()) PREV:[mark({ while (cond()) { try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } } }), jmp(L6 [condition entry point]), jmp(L6 [condition entry point])]
call(cond(), cond) -> <v0>
mark(while (cond()) { try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } })
jf(L3 [loop exit point]|<v0>) NEXT:[read (Unit), mark({ try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } })]
L4 [body entry point]:
3 mark({ try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue } })
mark(try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue })
jmp?(L6 [onException]) NEXT:[jmp?(L9 [catch 0]), jmp?(L7 [onExceptionToFinallyBlock])]
jmp?(L7 [onExceptionToFinallyBlock]) NEXT:[mark({ if (cond()) return else continue }), mark({ doSmth() })]
jmp?(L7 [onException]) NEXT:[jmp?(L10 [catch 0]), jmp?(L8 [onExceptionToFinallyBlock])]
jmp?(L8 [onExceptionToFinallyBlock]) NEXT:[mark({ if (cond()) return else continue }), mark({ doSmth() })]
4 mark({ doSmth() })
mark(doSmth())
call(doSmth(), doSmth) -> <v1>
3 jmp(L8 [afterCatches]) NEXT:[jmp(L10 [skipFinallyToErrorBlock])]
L6 [onException]:
jmp?(L9 [catch 0]) NEXT:[v(e: Exception), v(e: NullPointerException)] PREV:[jmp?(L6 [onException])]
3 jmp(L9 [afterCatches]) NEXT:[jmp(L11 [skipFinallyToErrorBlock])]
L7 [onException]:
jmp?(L10 [catch 0]) NEXT:[v(e: Exception), v(e: NullPointerException)] PREV:[jmp?(L7 [onException])]
4 v(e: NullPointerException)
magic[FAKE_INITIALIZER](e: NullPointerException) -> <v2>
w(e|<v2>)
5 mark({ doSmth1() })
mark(doSmth1())
call(doSmth1(), doSmth1) -> <v3>
4 jmp(L8 [afterCatches]) NEXT:[jmp(L10 [skipFinallyToErrorBlock])]
L9 [catch 0]:
v(e: Exception) PREV:[jmp?(L9 [catch 0])]
4 jmp(L9 [afterCatches]) NEXT:[jmp(L11 [skipFinallyToErrorBlock])]
L10 [catch 0]:
v(e: Exception) PREV:[jmp?(L10 [catch 0])]
magic[FAKE_INITIALIZER](e: Exception) -> <v4>
w(e|<v4>)
5 mark({ doSmth2() })
mark(doSmth2())
call(doSmth2(), doSmth2) -> <v5>
4 jmp(L8 [afterCatches])
L8 [afterCatches]:
3 jmp(L10 [skipFinallyToErrorBlock]) NEXT:[mark({ if (cond()) return else continue })] PREV:[jmp(L8 [afterCatches]), jmp(L8 [afterCatches]), jmp(L8 [afterCatches])]
L7 [onExceptionToFinallyBlock]:
L11 [start finally]:
4 mark({ if (cond()) return else continue }) PREV:[jmp?(L7 [onExceptionToFinallyBlock])]
4 jmp(L9 [afterCatches])
L9 [afterCatches]:
3 jmp(L11 [skipFinallyToErrorBlock]) NEXT:[mark({ if (cond()) return else continue })] PREV:[jmp(L9 [afterCatches]), jmp(L9 [afterCatches]), jmp(L9 [afterCatches])]
L8 [onExceptionToFinallyBlock]:
L12 [start finally]:
4 mark({ if (cond()) return else continue }) PREV:[jmp?(L8 [onExceptionToFinallyBlock])]
mark(if (cond()) return else continue)
mark(cond())
call(cond(), cond) -> <v6>
jf(L12 [else branch]|<v6>) NEXT:[jmp(L5 [condition entry point]), ret L1]
jf(L13 [else branch]|<v6>) NEXT:[jmp(L6 [condition entry point]), ret L1]
ret L1 NEXT:[<END>]
- jmp(L13 ['if' expression result]) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
L12 [else branch]:
jmp(L5 [condition entry point]) NEXT:[mark(cond())] PREV:[jf(L12 [else branch]|<v6>)]
L13 ['if' expression result]:
- jmp(L14 ['if' expression result]) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
L13 [else branch]:
jmp(L6 [condition entry point]) NEXT:[mark(cond())] PREV:[jf(L13 [else branch]|<v6>)]
L14 ['if' expression result]:
- merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9> PREV:[]
L14 [finish finally]:
L15 [finish finally]:
- 3 jmp(error) NEXT:[<ERROR>] PREV:[]
L10 [skipFinallyToErrorBlock]:
4 mark({ if (cond()) return else continue }) PREV:[jmp(L10 [skipFinallyToErrorBlock])]
L11 [skipFinallyToErrorBlock]:
4 mark({ if (cond()) return else continue }) PREV:[jmp(L11 [skipFinallyToErrorBlock])]
mark(if (cond()) return else continue)
mark(cond())
call(cond(), cond) -> <v6>
jf(copy L12 [else branch]|<v6>) NEXT:[jmp(L5 [condition entry point]), ret L1]
jf(copy L13 [else branch]|<v6>) NEXT:[jmp(L6 [condition entry point]), ret L1]
ret L1 NEXT:[<END>]
- jmp(copy L13 ['if' expression result]) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
jmp(L5 [condition entry point]) NEXT:[mark(cond())] PREV:[jf(copy L12 [else branch]|<v6>)]
- jmp(copy L14 ['if' expression result]) NEXT:[merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9>] PREV:[]
jmp(L6 [condition entry point]) NEXT:[mark(cond())] PREV:[jf(copy L13 [else branch]|<v6>)]
- merge(if (cond()) return else continue|!<v7>, !<v8>) -> <v9> PREV:[]
- 3 merge(try { doSmth() } catch (e: NullPointerException) { doSmth1() } catch (e: Exception) { doSmth2() } finally { if (cond()) return else continue }|<v1>, <v3>, <v5>) -> <v10> PREV:[]
- 2 jmp(L2 [loop entry point]) NEXT:[mark(cond())] PREV:[]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jf(L3 [loop exit point]|<v0>)]
L1:
1 <END> NEXT:[<SINK>] PREV:[ret L1, ret L1, read (Unit)]
@@ -259,7 +260,7 @@ L3 [onExceptionToFinallyBlock]:
L7 [start finally]:
3 mark({ while (cond()); }) PREV:[jmp?(L3 [onExceptionToFinallyBlock])]
L8 [loop entry point]:
L11 [condition entry point]:
L12 [condition entry point]:
mark(cond()) PREV:[mark({ while (cond()); }), jmp(L8 [loop entry point])]
call(cond(), cond) -> <v5>
mark(while (cond()))
@@ -267,8 +268,9 @@ L11 [condition entry point]:
L10 [body entry point]:
jmp(L8 [loop entry point]) NEXT:[mark(cond())]
L9 [loop exit point]:
L11 [body exit point]:
read (Unit) PREV:[jf(L9 [loop exit point]|<v5>)]
L12 [finish finally]:
L13 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L6 [skipFinallyToErrorBlock]:
3 mark({ while (cond()); }) PREV:[jmp(L6 [skipFinallyToErrorBlock])]
@@ -13,20 +13,21 @@ L0:
mark(1..2)
call(1..2, rangeTo|<v0>, <v1>) -> <v2>
v(i)
L3 ['for' loop condition entry point]:
jmp?(L2 ['for' loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..2|<v2>) -> <v3>]
L4 [loop entry point]:
L5 [body entry point]:
magic[LOOP_RANGE_ITERATION](1..2|<v2>) -> <v3> PREV:[jmp?(L2 ['for' loop exit point]), jmp?(L4 [loop entry point])]
L2 [loop entry point]:
L6 [condition entry point]:
jmp?(L3 [loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..2|<v2>) -> <v3>] PREV:[v(i), jmp(L2 [loop entry point])]
magic[LOOP_RANGE_ITERATION](1..2|<v2>) -> <v3>
w(i|<v3>)
mark(for (i in 1..2) { doSmth(i) })
L4 [body entry point]:
4 mark({ doSmth(i) })
r(i) -> <v4>
mark(doSmth(i))
call(doSmth(i), doSmth|<v4>) -> <v5>
3 jmp?(L4 [loop entry point]) NEXT:[magic[LOOP_RANGE_ITERATION](1..2|<v2>) -> <v3>, read (Unit)]
L2 ['for' loop exit point]:
read (Unit) PREV:[jmp?(L2 ['for' loop exit point]), jmp?(L4 [loop entry point])]
3 jmp(L2 [loop entry point]) NEXT:[jmp?(L3 [loop exit point])]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jmp?(L3 [loop exit point])]
L1:
1 <END> NEXT:[<SINK>]
error:
@@ -50,4 +51,4 @@ error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================
@@ -9,7 +9,7 @@ L0:
1 <START>
2 mark({ while(0 > 1) { 2 } })
L2 [loop entry point]:
L5 [condition entry point]:
L6 [condition entry point]:
r(0) -> <v0> PREV:[mark({ while(0 > 1) { 2 } }), jmp(L2 [loop entry point])]
r(1) -> <v1>
mark(0 > 1)
@@ -21,6 +21,7 @@ L4 [body entry point]:
r(2) -> <v3>
2 jmp(L2 [loop entry point]) NEXT:[r(0) -> <v0>]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jf(L3 [loop exit point]|<v2>)]
L1:
1 <END> NEXT:[<SINK>]
@@ -43,7 +44,8 @@ L2 [loop entry point]:
L4 [body entry point]:
mark({return})
ret L1 NEXT:[<END>]
L5 [condition entry point]:
L5 [body exit point]:
L6 [condition entry point]:
- r(0) -> <v1> PREV:[]
- r(1) -> <v2> PREV:[]
- mark(0 > 1) PREV:[]
@@ -18,15 +18,16 @@ L4 [body entry point]:
mark({ if (b) break; continue; }) PREV:[mark(do { if (b) break; continue; } while (true)), jt(L2 [loop entry point]|<v5>)]
mark(if (b) break)
r(b) -> <v1>
jf(L6 [else branch]|<v1>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jf(L7 [else branch]|<v1>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- jmp(L7 ['if' expression result]) NEXT:[merge(if (b) break|!<v2>) -> <v3>] PREV:[]
L6 [else branch]:
read (Unit) PREV:[jf(L6 [else branch]|<v1>)]
L7 ['if' expression result]:
- jmp(L8 ['if' expression result]) NEXT:[merge(if (b) break|!<v2>) -> <v3>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v1>)]
L8 ['if' expression result]:
merge(if (b) break|!<v2>) -> <v3>
jmp(L5 [condition entry point])
L5 [condition entry point]:
jmp(L6 [condition entry point])
L5 [body exit point]:
L6 [condition entry point]:
r(true) -> <v5>
jt(L2 [loop entry point]|<v5>) NEXT:[read (Unit), mark({ if (b) break; continue; })]
L3 [loop exit point]:
@@ -17,31 +17,32 @@ L0:
mark(1..10)
call(1..10, rangeTo|<v1>, <v2>) -> <v3>
v(i)
L3 ['for' loop condition entry point]:
jmp?(L2 ['for' loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..10|<v3>) -> <v4>] PREV:[v(i), jmp(L3 ['for' loop condition entry point])]
L4 [loop entry point]:
L5 [body entry point]:
L2 [loop entry point]:
L6 [condition entry point]:
jmp?(L3 [loop exit point]) NEXT:[read (Unit), magic[LOOP_RANGE_ITERATION](1..10|<v3>) -> <v4>] PREV:[v(i), jmp(L6 [condition entry point])]
magic[LOOP_RANGE_ITERATION](1..10|<v3>) -> <v4>
w(i|<v4>)
mark(for (i in 1..10) { if (b) break; continue; })
L4 [body entry point]:
4 mark({ if (b) break; continue; })
mark(if (b) break)
r(b) -> <v5>
jf(L6 [else branch]|<v5>) NEXT:[read (Unit), jmp(L2 ['for' loop exit point])]
jmp(L2 ['for' loop exit point]) NEXT:[read (Unit)]
- jmp(L7 ['if' expression result]) NEXT:[merge(if (b) break|!<v6>) -> <v7>] PREV:[]
L6 [else branch]:
read (Unit) PREV:[jf(L6 [else branch]|<v5>)]
L7 ['if' expression result]:
jf(L7 [else branch]|<v5>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- jmp(L8 ['if' expression result]) NEXT:[merge(if (b) break|!<v6>) -> <v7>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v5>)]
L8 ['if' expression result]:
merge(if (b) break|!<v6>) -> <v7>
jmp(L3 ['for' loop condition entry point]) NEXT:[jmp?(L2 ['for' loop exit point])]
- 3 jmp?(L4 [loop entry point]) NEXT:[magic[LOOP_RANGE_ITERATION](1..10|<v3>) -> <v4>, read (Unit)] PREV:[]
L2 ['for' loop exit point]:
read (Unit) PREV:[jmp?(L2 ['for' loop exit point]), jmp(L2 ['for' loop exit point])]
jmp(L6 [condition entry point]) NEXT:[jmp?(L3 [loop exit point])]
- 3 jmp(L2 [loop entry point]) NEXT:[jmp?(L3 [loop exit point])] PREV:[]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jmp?(L3 [loop exit point]), jmp(L3 [loop exit point])]
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================
@@ -13,24 +13,25 @@ L0:
w(b|<v0>)
2 mark({ while (true) { if (b) break; continue; } })
L2 [loop entry point]:
L5 [condition entry point]:
r(true) -> <v1> PREV:[mark({ while (true) { if (b) break; continue; } }), jmp(L5 [condition entry point])]
L6 [condition entry point]:
r(true) -> <v1> PREV:[mark({ while (true) { if (b) break; continue; } }), jmp(L6 [condition entry point])]
mark(while (true) { if (b) break; continue; })
magic[VALUE_CONSUMER](true|<v1>) -> <v2>
L4 [body entry point]:
3 mark({ if (b) break; continue; })
mark(if (b) break)
r(b) -> <v3>
jf(L6 [else branch]|<v3>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jf(L7 [else branch]|<v3>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- jmp(L7 ['if' expression result]) NEXT:[merge(if (b) break|!<v4>) -> <v5>] PREV:[]
L6 [else branch]:
read (Unit) PREV:[jf(L6 [else branch]|<v3>)]
L7 ['if' expression result]:
- jmp(L8 ['if' expression result]) NEXT:[merge(if (b) break|!<v4>) -> <v5>] PREV:[]
L7 [else branch]:
read (Unit) PREV:[jf(L7 [else branch]|<v3>)]
L8 ['if' expression result]:
merge(if (b) break|!<v4>) -> <v5>
jmp(L5 [condition entry point]) NEXT:[r(true) -> <v1>]
jmp(L6 [condition entry point]) NEXT:[r(true) -> <v1>]
- 2 jmp(L2 [loop entry point]) NEXT:[r(true) -> <v1>] PREV:[]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jmp(L3 [loop exit point])]
L1:
1 <END> NEXT:[<SINK>]
@@ -38,4 +39,4 @@ error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
=====================
@@ -0,0 +1,34 @@
fun test() {
@l for (i in if (true) 1..10 else <!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue@l<!>) {}
for (i in if (true) 1..10 else <!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>) {}
while (<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break<!>) {}
@l while (<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break@l<!>) {}
do {} while (<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>)
@l do {} while (<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue@l<!>)
//KT-5704
var i = 0
while (if(i++ == 10) <!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break<!> else <!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>) {}
}
fun test2(b: Boolean) {
while (b) {
<!UNREACHABLE_CODE!>while (<!>break<!UNREACHABLE_CODE!>) {}<!>
}
do {
<!UNREACHABLE_CODE!>while (<!>continue<!UNREACHABLE_CODE!>) {}<!>
} while (b)
while (b) {
do {} while (break)
}
for (i in 1..10) {
for (j in if (true) 1..10 else continue) {
}
}
}
@@ -1202,6 +1202,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.kt");
}
@TestMetadata("breakOrContinueInLoopCondition.kt")
public void testBreakOrContinueInLoopCondition() throws Exception {
doTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/breakOrContinueInLoopCondition.kt");
}
@TestMetadata("checkInnerLocalDeclarations.kt")
public void testCheckInnerLocalDeclarations() throws Exception {
doTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/checkInnerLocalDeclarations.kt");
@@ -56,17 +56,6 @@ fun forReturn(b: Boolean): String {
}
fun box(): String {
var i = 0
// KT-5704 'while' detected as unreachable though loop is running
// TODO Remove or uncomment when issue will be fixed
//while(if (++i==10) break else continue) {}
//assertEquals(10, i)
i = 0
do { i++ } while(if (++i==10) break else continue)
assertEquals(10, i)
assertEquals(":whileReturn:", whileReturn())
assertEquals("AA:return:", global)