CFG: break and continue are now handled in the same (safe) way EA-85060 Fixed
(cherry picked from commit eec4b1b)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
d33745b646
commit
ea041661fb
@@ -40,7 +40,7 @@ interface ControlFlowBuilder {
|
||||
fun exitBlockScope(block: KtElement)
|
||||
|
||||
fun getSubroutineExitPoint(labelElement: KtElement): Label?
|
||||
fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label
|
||||
fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label?
|
||||
fun getLoopExitPoint(loop: KtLoopExpression): Label?
|
||||
|
||||
// Declarations
|
||||
|
||||
@@ -127,7 +127,7 @@ abstract class ControlFlowBuilderAdapter : ControlFlowBuilder {
|
||||
return delegateBuilder.getSubroutineExitPoint(labelElement)
|
||||
}
|
||||
|
||||
override fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label {
|
||||
override fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label? {
|
||||
return delegateBuilder.getLoopConditionEntryPoint(loop)
|
||||
}
|
||||
|
||||
|
||||
@@ -806,7 +806,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||
val loop = getCorrespondingLoop(expression)
|
||||
if (loop != null) {
|
||||
if (jumpDoesNotCrossFunctionBoundary(expression, loop)) {
|
||||
builder.jump(builder.getLoopConditionEntryPoint(loop), expression)
|
||||
builder.getLoopConditionEntryPoint(loop)?.let { builder.jump(it, expression) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -166,9 +166,8 @@ class ControlFlowInstructionsGenerator : ControlFlowBuilderAdapter() {
|
||||
override val currentSubroutine: KtElement
|
||||
get() = pseudocode.correspondingElement
|
||||
|
||||
override fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label {
|
||||
val blockInfo = elementToLoopInfo[loop] ?: error("expected LoopInfo for ${loop.text}")
|
||||
return blockInfo.conditionEntryPoint
|
||||
override fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label? {
|
||||
return elementToLoopInfo[loop]?.conditionEntryPoint
|
||||
}
|
||||
|
||||
override fun getLoopExitPoint(loop: KtLoopExpression): Label? {
|
||||
|
||||
Reference in New Issue
Block a user