IR: fix offsets in irTemporary

The variable generated by IrStatementBuilder.irTemporary doesn't inherit
startOffset and endOffset from the builder. In particular, as a result,
temporary variables generated for elvis operator left operand have
UNDEFINED_OFFSET.

Additionally, ProvisionalFunctionExpressionLowering copies the offsets
of a variable to lowered lambda in the variable initializer. With the
problem described above, this causes invalid debug information in
Kotlin/Native, see KT-49360.

Fix irTemporary by using builder's offsets for the variable.

^KT-49360 Fixed
This commit is contained in:
Svyatoslav Scherbina
2021-11-12 11:45:09 +03:00
committed by Space
parent fb859c0270
commit 2f5706597a
8 changed files with 181 additions and 1 deletions
@@ -0,0 +1,23 @@
@0:0..6:0 FILE fqName:<root> fileName:/postfixIncrementDecrement.kt
@0:0..5:1 FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
@0:11..5:1 BLOCK_BODY
@1:4..13 VAR name:x type:kotlin.Int [var]
@1:12..13 CONST Int type=kotlin.Int value=0
@2:4..13 VAR name:y type:kotlin.Int [var]
@2:12..13 CONST Int type=kotlin.Int value=0
@3:4..5 SET_VAR 'var y: kotlin.Int [var] declared in <root>.test' type=kotlin.Unit origin=EQ
@3:8..11 BLOCK type=kotlin.Int origin=POSTFIX_INCR
@3:8..11 VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Int [val]
@3:8..9 GET_VAR 'var x: kotlin.Int [var] declared in <root>.test' type=kotlin.Int origin=POSTFIX_INCR
@3:8..9 SET_VAR 'var x: kotlin.Int [var] declared in <root>.test' type=kotlin.Unit origin=POSTFIX_INCR
@3:8..11 CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=POSTFIX_INCR
@3:8..11 GET_VAR 'val tmp0: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
@3:8..11 GET_VAR 'val tmp0: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
@4:4..5 SET_VAR 'var y: kotlin.Int [var] declared in <root>.test' type=kotlin.Unit origin=EQ
@4:8..11 BLOCK type=kotlin.Int origin=POSTFIX_DECR
@4:8..11 VAR IR_TEMPORARY_VARIABLE name:tmp1 type:kotlin.Int [val]
@4:8..9 GET_VAR 'var x: kotlin.Int [var] declared in <root>.test' type=kotlin.Int origin=POSTFIX_DECR
@4:8..9 SET_VAR 'var x: kotlin.Int [var] declared in <root>.test' type=kotlin.Unit origin=POSTFIX_DECR
@4:8..11 CALL 'public final fun dec (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=POSTFIX_DECR
@4:8..11 GET_VAR 'val tmp1: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
@4:8..11 GET_VAR 'val tmp1: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null