[codegen][debug info] improvement of generation debug info for 'finally' block

This commit is contained in:
Vasily Levchenko
2019-04-16 14:46:33 +03:00
parent 3b1783a48d
commit 3bf3b6a5a3
2 changed files with 5 additions and 7 deletions
@@ -1577,16 +1577,14 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
} }
//-------------------------------------------------------------------------// //-------------------------------------------------------------------------//
val dummyFile = IrFileImpl(NaiveSourceBasedFileEntryImpl("no source file"))
private inner class ReturnableBlockScope(val returnableBlock: IrReturnableBlock) : private inner class ReturnableBlockScope(val returnableBlock: IrReturnableBlock) :
FileScope(returnableBlock.sourceFileSymbol?.owner ?: dummyFile) { FileScope(returnableBlock.sourceFileSymbol?.owner ?: (currentCodeContext.fileScope() as? FileScope)?.file ?: error("returnable block should belong to current file at least") ) {
var bbExit : LLVMBasicBlockRef? = null var bbExit : LLVMBasicBlockRef? = null
var resultPhi : LLVMValueRef? = null var resultPhi : LLVMValueRef? = null
private fun getExit(): LLVMBasicBlockRef { private fun getExit(): LLVMBasicBlockRef {
if (bbExit == null) bbExit = functionGenerationContext.basicBlock("returnable_block_exit", null) if (bbExit == null) bbExit = functionGenerationContext.basicBlock("returnable_block_exit", returnableBlock.startLocation)
return bbExit!! return bbExit!!
} }
@@ -293,13 +293,13 @@ internal class FinallyBlocksLowering(val context: Context): FileLoweringPass, Ir
val returnTypeClassifier = (type as? IrSimpleType)?.classifier val returnTypeClassifier = (type as? IrSimpleType)?.classifier
return when (returnTypeClassifier) { return when (returnTypeClassifier) {
symbols.unit, symbols.nothing -> irBlock(value, null, type) { symbols.unit, symbols.nothing -> irBlock(value, null, type) {
+irReturnableBlock(symbol, type) { +irReturnableBlock(finallyExpression.startOffset, finallyExpression.endOffset, symbol, type) {
+value +value
} }
+copy(finallyExpression) +copy(finallyExpression)
} }
else -> irBlock(value, null, type) { else -> irBlock(value, null, type) {
val tmp = irTemporary(irReturnableBlock(symbol, type) { val tmp = irTemporary(irReturnableBlock(finallyExpression.startOffset, finallyExpression.endOffset, symbol, type) {
+irReturn(symbol, value) +irReturn(symbol, value)
}) })
+copy(finallyExpression) +copy(finallyExpression)
@@ -314,7 +314,7 @@ internal class FinallyBlocksLowering(val context: Context): FileLoweringPass, Ir
fun IrBuilderWithScope.irReturn(target: IrReturnTargetSymbol, value: IrExpression) = fun IrBuilderWithScope.irReturn(target: IrReturnTargetSymbol, value: IrExpression) =
IrReturnImpl(startOffset, endOffset, context.irBuiltIns.nothingType, target, value) IrReturnImpl(startOffset, endOffset, context.irBuiltIns.nothingType, target, value)
private inline fun IrBuilderWithScope.irReturnableBlock(symbol: IrReturnableBlockSymbol, private inline fun IrBuilderWithScope.irReturnableBlock(startOffset: Int, endOffset: Int, symbol: IrReturnableBlockSymbol,
type: IrType, body: IrBlockBuilder.() -> Unit) = type: IrType, body: IrBlockBuilder.() -> Unit) =
IrReturnableBlockImpl(startOffset, endOffset, type, symbol, null, IrReturnableBlockImpl(startOffset, endOffset, type, symbol, null,
IrBlockBuilder(context, scope, startOffset, endOffset, null, type) IrBlockBuilder(context, scope, startOffset, endOffset, null, type)