[FE 1.0] Record USED_AS_EXPRESSION for unreachable CFG nodes
^KT-48708 Fixed
This commit is contained in:
committed by
teamcityserver
parent
8464b15d27
commit
d390f881c8
Generated
+6
@@ -1454,6 +1454,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
|||||||
runTest("compiler/testData/ir/irText/expressions/kt47450.kt");
|
runTest("compiler/testData/ir/irText/expressions/kt47450.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt48708.kt")
|
||||||
|
public void testKt48708() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/irText/expressions/kt48708.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaInCAO.kt")
|
@TestMetadata("lambdaInCAO.kt")
|
||||||
public void testLambdaInCAO() throws Exception {
|
public void testLambdaInCAO() throws Exception {
|
||||||
|
|||||||
+11
-9
@@ -797,15 +797,17 @@ class ControlFlowInformationProviderImpl private constructor(
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Statements
|
// Statements
|
||||||
|
|
||||||
private fun markStatements() = pseudocode.traverse(TraversalOrder.FORWARD) { instruction ->
|
private fun markStatements() {
|
||||||
val value = (instruction as? InstructionWithValue)?.outputValue
|
pseudocode.traverseIncludingDeadCode { instruction ->
|
||||||
val pseudocode = instruction.owner
|
val value = (instruction as? InstructionWithValue)?.outputValue
|
||||||
val usages = pseudocode.getUsages(value)
|
val pseudocode = instruction.owner
|
||||||
val isUsedAsExpression = usages.isNotEmpty()
|
val usages = pseudocode.getUsages(value)
|
||||||
val isUsedAsResultOfLambda = isUsedAsResultOfLambda(usages)
|
val isUsedAsExpression = usages.isNotEmpty()
|
||||||
for (element in pseudocode.getValueElements(value)) {
|
val isUsedAsResultOfLambda = isUsedAsResultOfLambda(usages)
|
||||||
trace.record(USED_AS_EXPRESSION, element, isUsedAsExpression)
|
for (element in pseudocode.getValueElements(value)) {
|
||||||
trace.record(USED_AS_RESULT_OF_LAMBDA, element, isUsedAsResultOfLambda)
|
trace.record(USED_AS_EXPRESSION, element, isUsedAsExpression)
|
||||||
|
trace.record(USED_AS_RESULT_OF_LAMBDA, element, isUsedAsResultOfLambda)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,15 @@ fun <D> Pseudocode.traverse(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Pseudocode.traverseIncludingDeadCode(analyzeInstruction: (Instruction) -> Unit) {
|
||||||
|
for (instruction in instructionsIncludingDeadCode) {
|
||||||
|
if (instruction is LocalFunctionDeclarationInstruction) {
|
||||||
|
instruction.body.traverseIncludingDeadCode(analyzeInstruction)
|
||||||
|
}
|
||||||
|
analyzeInstruction(instruction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun <I : ControlFlowInfo<*, *, *>> Pseudocode.collectData(
|
fun <I : ControlFlowInfo<*, *, *>> Pseudocode.collectData(
|
||||||
traversalOrder: TraversalOrder,
|
traversalOrder: TraversalOrder,
|
||||||
mergeEdges: (Instruction, Collection<I>) -> Edges<I>,
|
mergeEdges: (Instruction, Collection<I>) -> Edges<I>,
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
fun test(b: Boolean) {
|
||||||
|
val x: Int = when {
|
||||||
|
b -> 3
|
||||||
|
else -> { // BLOCK
|
||||||
|
throw Exception()
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
takeInt(x = x)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun takeInt(x: Int) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
FILE fqName:<root> fileName:/kt48708.kt
|
||||||
|
FUN name:test visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.Unit
|
||||||
|
VALUE_PARAMETER name:b index:0 type:kotlin.Boolean
|
||||||
|
BLOCK_BODY
|
||||||
|
VAR name:x type:kotlin.Int [val]
|
||||||
|
WHEN type=kotlin.Int origin=IF
|
||||||
|
BRANCH
|
||||||
|
if: GET_VAR 'b: kotlin.Boolean declared in <root>.test' type=kotlin.Boolean origin=null
|
||||||
|
then: CONST Int type=kotlin.Int value=3
|
||||||
|
BRANCH
|
||||||
|
if: CONST Boolean type=kotlin.Boolean value=true
|
||||||
|
then: BLOCK type=kotlin.Int origin=null
|
||||||
|
THROW type=kotlin.Nothing
|
||||||
|
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.Exception' type=java.lang.Exception origin=null
|
||||||
|
CONST Int type=kotlin.Int value=0
|
||||||
|
CALL 'public final fun takeInt (x: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
|
x: GET_VAR 'val x: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
|
||||||
|
FUN name:takeInt visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Unit
|
||||||
|
VALUE_PARAMETER name:x index:0 type:kotlin.Int
|
||||||
|
BLOCK_BODY
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// ISSUE: KT-48708
|
||||||
|
|
||||||
|
fun test(b: Boolean) {
|
||||||
|
val x = if (b) {
|
||||||
|
3
|
||||||
|
} else {
|
||||||
|
throw Exception()
|
||||||
|
0
|
||||||
|
}
|
||||||
|
takeInt(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun takeInt(x: Int) {}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
fun test(b: Boolean) {
|
||||||
|
val x: Int = when {
|
||||||
|
b -> { // BLOCK
|
||||||
|
3
|
||||||
|
}
|
||||||
|
else -> { // BLOCK
|
||||||
|
throw Exception()
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
takeInt(x = x)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun takeInt(x: Int) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
FILE fqName:<root> fileName:/kt48708.kt
|
||||||
|
FUN name:test visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.Unit
|
||||||
|
VALUE_PARAMETER name:b index:0 type:kotlin.Boolean
|
||||||
|
BLOCK_BODY
|
||||||
|
VAR name:x type:kotlin.Int [val]
|
||||||
|
WHEN type=kotlin.Int origin=IF
|
||||||
|
BRANCH
|
||||||
|
if: GET_VAR 'b: kotlin.Boolean declared in <root>.test' type=kotlin.Boolean origin=null
|
||||||
|
then: BLOCK type=kotlin.Int origin=null
|
||||||
|
CONST Int type=kotlin.Int value=3
|
||||||
|
BRANCH
|
||||||
|
if: CONST Boolean type=kotlin.Boolean value=true
|
||||||
|
then: BLOCK type=kotlin.Int origin=null
|
||||||
|
THROW type=kotlin.Nothing
|
||||||
|
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.Exception' type=java.lang.Exception origin=null
|
||||||
|
CONST Int type=kotlin.Int value=0
|
||||||
|
CALL 'public final fun takeInt (x: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
|
x: GET_VAR 'val x: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
|
||||||
|
FUN name:takeInt visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Unit
|
||||||
|
VALUE_PARAMETER name:x index:0 type:kotlin.Int
|
||||||
|
BLOCK_BODY
|
||||||
Generated
+6
@@ -1454,6 +1454,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
|
|||||||
runTest("compiler/testData/ir/irText/expressions/kt47450.kt");
|
runTest("compiler/testData/ir/irText/expressions/kt47450.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt48708.kt")
|
||||||
|
public void testKt48708() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/irText/expressions/kt48708.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaInCAO.kt")
|
@TestMetadata("lambdaInCAO.kt")
|
||||||
public void testLambdaInCAO() throws Exception {
|
public void testLambdaInCAO() throws Exception {
|
||||||
|
|||||||
@@ -1128,6 +1128,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase {
|
|||||||
runTest("compiler/testData/ir/irText/expressions/kt47450.kt");
|
runTest("compiler/testData/ir/irText/expressions/kt47450.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt48708.kt")
|
||||||
|
public void testKt48708() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/irText/expressions/kt48708.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaInCAO.kt")
|
@TestMetadata("lambdaInCAO.kt")
|
||||||
public void testLambdaInCAO() throws Exception {
|
public void testLambdaInCAO() throws Exception {
|
||||||
runTest("compiler/testData/ir/irText/expressions/lambdaInCAO.kt");
|
runTest("compiler/testData/ir/irText/expressions/lambdaInCAO.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user