[Native] Replace consequence line and column calls with a single one
This commit is contained in:
+4
-2
@@ -64,7 +64,8 @@ private class PerformByIrFilePhase<Context : CommonBackendContext>(
|
|||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
CodegenUtil.reportBackendException(e, "IR lowering", irFile.fileEntry.name) { offset ->
|
CodegenUtil.reportBackendException(e, "IR lowering", irFile.fileEntry.name) { offset ->
|
||||||
irFile.fileEntry.takeIf { it.supportsDebugInfo }?.let {
|
irFile.fileEntry.takeIf { it.supportsDebugInfo }?.let {
|
||||||
it.getLineNumber(offset) to it.getColumnNumber(offset)
|
val (line, column) = it.getLineAndColumnNumbers(offset)
|
||||||
|
line to column
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,8 @@ private class PerformByIrFilePhase<Context : CommonBackendContext>(
|
|||||||
thrownFromThread.get()?.let { (e, irFile) ->
|
thrownFromThread.get()?.let { (e, irFile) ->
|
||||||
CodegenUtil.reportBackendException(e, "Experimental parallel IR backend", irFile.fileEntry.name) { offset ->
|
CodegenUtil.reportBackendException(e, "Experimental parallel IR backend", irFile.fileEntry.name) { offset ->
|
||||||
irFile.fileEntry.takeIf { it.supportsDebugInfo }?.let {
|
irFile.fileEntry.takeIf { it.supportsDebugInfo }?.let {
|
||||||
it.getLineNumber(offset) to it.getColumnNumber(offset)
|
val (line, column) = it.getLineAndColumnNumbers(offset)
|
||||||
|
line to column
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -12,7 +12,8 @@ import org.jetbrains.kotlin.ir.IrFileEntry
|
|||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin
|
import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsStatementOrigins
|
import org.jetbrains.kotlin.ir.backend.js.JsStatementOrigins
|
||||||
import org.jetbrains.kotlin.ir.backend.js.lower.*
|
import org.jetbrains.kotlin.ir.backend.js.lower.isBoxParameter
|
||||||
|
import org.jetbrains.kotlin.ir.backend.js.lower.isEs6ConstructorReplacement
|
||||||
import org.jetbrains.kotlin.ir.backend.js.sourceMapsInfo
|
import org.jetbrains.kotlin.ir.backend.js.sourceMapsInfo
|
||||||
import org.jetbrains.kotlin.ir.backend.js.utils.*
|
import org.jetbrains.kotlin.ir.backend.js.utils.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
@@ -618,8 +619,7 @@ inline fun IrElement.getSourceLocation(fileEntry: IrFileEntry, offsetSelector: I
|
|||||||
if (startOffset == UNDEFINED_OFFSET || endOffset == UNDEFINED_OFFSET) return null
|
if (startOffset == UNDEFINED_OFFSET || endOffset == UNDEFINED_OFFSET) return null
|
||||||
val path = fileEntry.name
|
val path = fileEntry.name
|
||||||
val offset = offsetSelector()
|
val offset = offsetSelector()
|
||||||
val startLine = fileEntry.getLineNumber(offset)
|
val (startLine, startColumn) = fileEntry.getLineAndColumnNumbers(offset)
|
||||||
val startColumn = fileEntry.getColumnNumber(offset)
|
|
||||||
return JsLocation(path, startLine, startColumn)
|
return JsLocation(path, startLine, startColumn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.wasm.ir2wasm
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.IrFileEntry
|
import org.jetbrains.kotlin.ir.IrFileEntry
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
|
||||||
import org.jetbrains.kotlin.wasm.ir.WasmExpressionBuilder
|
import org.jetbrains.kotlin.wasm.ir.WasmExpressionBuilder
|
||||||
import org.jetbrains.kotlin.wasm.ir.source.location.SourceLocation
|
import org.jetbrains.kotlin.wasm.ir.source.location.SourceLocation
|
||||||
|
|
||||||
@@ -15,8 +14,7 @@ fun IrElement.getSourceLocation(fileEntry: IrFileEntry?): SourceLocation {
|
|||||||
if (fileEntry == null) return SourceLocation.NoLocation("fileEntry is null")
|
if (fileEntry == null) return SourceLocation.NoLocation("fileEntry is null")
|
||||||
|
|
||||||
val path = fileEntry.name
|
val path = fileEntry.name
|
||||||
val startLine = fileEntry.getLineNumber(startOffset)
|
val (startLine, startColumn) = fileEntry.getLineAndColumnNumbers(startOffset)
|
||||||
val startColumn = fileEntry.getColumnNumber(startOffset)
|
|
||||||
|
|
||||||
if (startLine < 0 || startColumn < 0) return SourceLocation.NoLocation("startLine or startColumn < 0")
|
if (startLine < 0 || startColumn < 0) return SourceLocation.NoLocation("startLine or startColumn < 0")
|
||||||
|
|
||||||
|
|||||||
@@ -55,14 +55,17 @@ abstract class AbstractIrFileEntry : IrFileEntry {
|
|||||||
return LineAndColumn(lineNumber, columnNumber)
|
return LineAndColumn(lineNumber, columnNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSourceRangeInfo(beginOffset: Int, endOffset: Int): SourceRangeInfo =
|
override fun getSourceRangeInfo(beginOffset: Int, endOffset: Int): SourceRangeInfo {
|
||||||
SourceRangeInfo(
|
val (startLineNumber, startColumnNumber) = getLineAndColumnNumbers(beginOffset)
|
||||||
|
val (endLineNumber, endColumnNumber) = getLineAndColumnNumbers(endOffset)
|
||||||
|
return SourceRangeInfo(
|
||||||
filePath = name,
|
filePath = name,
|
||||||
startOffset = beginOffset,
|
startOffset = beginOffset,
|
||||||
startLineNumber = getLineNumber(beginOffset),
|
startLineNumber = startLineNumber,
|
||||||
startColumnNumber = getColumnNumber(beginOffset),
|
startColumnNumber = startColumnNumber,
|
||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
endLineNumber = getLineNumber(endOffset),
|
endLineNumber = endLineNumber,
|
||||||
endColumnNumber = getColumnNumber(endOffset)
|
endColumnNumber = endColumnNumber
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-6
@@ -65,12 +65,15 @@ object PartialLinkageUtils {
|
|||||||
data class IrBased(private val file: IrFile) : File {
|
data class IrBased(private val file: IrFile) : File {
|
||||||
override val module = Module.Real(file.module.name)
|
override val module = Module.Real(file.module.name)
|
||||||
|
|
||||||
override fun computeLocationForOffset(offset: Int) = PartialLinkageLogger.Location(
|
override fun computeLocationForOffset(offset: Int): PartialLinkageLogger.Location {
|
||||||
moduleName = module.name,
|
val (line, column) = file.fileEntry.getLineAndColumnNumbers(offset)
|
||||||
filePath = file.fileEntry.name,
|
return PartialLinkageLogger.Location(
|
||||||
lineNumber = if (offset == UNDEFINED_OFFSET) UNDEFINED_LINE_NUMBER else file.fileEntry.getLineNumber(offset) + 1, // since humans count from 1, not 0
|
moduleName = module.name,
|
||||||
columnNumber = if (offset == UNDEFINED_OFFSET) UNDEFINED_COLUMN_NUMBER else file.fileEntry.getColumnNumber(offset) + 1
|
filePath = file.fileEntry.name,
|
||||||
)
|
lineNumber = if (offset == UNDEFINED_OFFSET) UNDEFINED_LINE_NUMBER else line + 1, // since humans count from 1, not 0
|
||||||
|
columnNumber = if (offset == UNDEFINED_OFFSET) UNDEFINED_COLUMN_NUMBER else column + 1
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LazyIrBased(packageFragmentDescriptor: PackageFragmentDescriptor) : File {
|
class LazyIrBased(packageFragmentDescriptor: PackageFragmentDescriptor) : File {
|
||||||
|
|||||||
+11
-6
@@ -6,16 +6,20 @@
|
|||||||
package org.jetbrains.kotlin.backend.konan.llvm
|
package org.jetbrains.kotlin.backend.konan.llvm
|
||||||
|
|
||||||
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.cValuesOf
|
||||||
|
import kotlinx.cinterop.memScoped
|
||||||
|
import kotlinx.cinterop.toCValues
|
||||||
|
import kotlinx.cinterop.toKString
|
||||||
import llvm.*
|
import llvm.*
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.MemoryModel
|
||||||
|
import org.jetbrains.kotlin.backend.konan.NativeGenerationState
|
||||||
|
import org.jetbrains.kotlin.backend.konan.RuntimeNames
|
||||||
import org.jetbrains.kotlin.backend.konan.cgen.CBridgeOrigin
|
import org.jetbrains.kotlin.backend.konan.cgen.CBridgeOrigin
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.ClassGlobalHierarchyInfo
|
import org.jetbrains.kotlin.backend.konan.descriptors.ClassGlobalHierarchyInfo
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
import org.jetbrains.kotlin.backend.konan.ir.isAny
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.ThreadState.Native
|
import org.jetbrains.kotlin.backend.konan.llvm.ThreadState.Native
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.ThreadState.Runnable
|
import org.jetbrains.kotlin.backend.konan.llvm.ThreadState.Runnable
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.objc.*
|
import org.jetbrains.kotlin.backend.konan.llvm.objc.ObjCDataGenerator
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.objcinterop.*
|
import org.jetbrains.kotlin.ir.objcinterop.*
|
||||||
@@ -343,7 +347,8 @@ private fun CodeGenerator.getVirtualFunctionTrampolineImpl(irFunction: IrSimpleF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Suppress("UNCHECKED_CAST") val location = diFunctionScope?.let {
|
@Suppress("UNCHECKED_CAST") val location = diFunctionScope?.let {
|
||||||
LocationInfo(it as DIScopeOpaqueRef, file.fileEntry.line(offset!!), file.fileEntry.column(offset))
|
val (line, column) = file.fileEntry.lineAndColumn(offset!!)
|
||||||
|
LocationInfo(it as DIScopeOpaqueRef, line, column)
|
||||||
}
|
}
|
||||||
generateFunction(this, proto, needSafePoint = false, startLocation = location, endLocation = location) {
|
generateFunction(this, proto, needSafePoint = false, startLocation = location, endLocation = location) {
|
||||||
val args = proto.signature.parameterTypes.indices.map { param(it) }
|
val args = proto.signature.parameterTypes.indices.map { param(it) }
|
||||||
|
|||||||
+6
-3
@@ -259,7 +259,7 @@ internal class DebugInfo(override val generationState: NativeGenerationState) :
|
|||||||
/**
|
/**
|
||||||
* File entry starts offsets from zero while dwarf number lines/column starting from 1.
|
* File entry starts offsets from zero while dwarf number lines/column starting from 1.
|
||||||
*/
|
*/
|
||||||
private val NO_SOURCE_FILE = "no source file"
|
private const val NO_SOURCE_FILE = "no source file"
|
||||||
private fun IrFileEntry.location(offset: Int, offsetToNumber: (Int) -> Int): Int {
|
private fun IrFileEntry.location(offset: Int, offsetToNumber: (Int) -> Int): Int {
|
||||||
// Part "name.isEmpty() || name == NO_SOURCE_FILE" is an awful hack, @minamoto, please fix properly.
|
// Part "name.isEmpty() || name == NO_SOURCE_FILE" is an awful hack, @minamoto, please fix properly.
|
||||||
if (offset == UNDEFINED_OFFSET) return 0
|
if (offset == UNDEFINED_OFFSET) return 0
|
||||||
@@ -270,9 +270,12 @@ private fun IrFileEntry.location(offset: Int, offsetToNumber: (Int) -> Int): Int
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun IrFileEntry.line(offset: Int) = location(offset, this::getLineNumber)
|
internal fun IrFileEntry.lineAndColumn(offset: Int): Pair<Int, Int> {
|
||||||
|
val (line, column) = this.getLineAndColumnNumbers(offset)
|
||||||
|
return location(offset) { line } to location(offset) { column }
|
||||||
|
}
|
||||||
|
|
||||||
internal fun IrFileEntry.column(offset: Int) = location(offset, this::getColumnNumber)
|
internal fun IrFileEntry.line(offset: Int) = location(offset, this::getLineNumber)
|
||||||
|
|
||||||
internal data class FileAndFolder(val file: String, val folder: String) {
|
internal data class FileAndFolder(val file: String, val folder: String) {
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+23
-17
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.konan.llvm
|
|||||||
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import llvm.*
|
import llvm.*
|
||||||
import org.jetbrains.kotlin.ir.util.inlineFunction
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.isUnconditional
|
import org.jetbrains.kotlin.backend.common.ir.isUnconditional
|
||||||
import org.jetbrains.kotlin.backend.common.lower.coroutines.getOrCreateFunctionWithContinuationStub
|
import org.jetbrains.kotlin.backend.common.lower.coroutines.getOrCreateFunctionWithContinuationStub
|
||||||
import org.jetbrains.kotlin.backend.common.lower.inline.INLINED_FUNCTION_ARGUMENTS
|
import org.jetbrains.kotlin.backend.common.lower.inline.INLINED_FUNCTION_ARGUMENTS
|
||||||
@@ -28,10 +27,10 @@ import org.jetbrains.kotlin.ir.IrStatement
|
|||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.ir.objcinterop.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.objcinterop.*
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||||
@@ -781,7 +780,12 @@ internal class CodeGeneratorVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val fileScope = (fileScope() as? FileScope)
|
private val fileScope = (fileScope() as? FileScope)
|
||||||
override fun location(offset: Int) = scope?.let { scope -> fileScope?.let{LocationInfo(scope, it.file.fileEntry.line(offset), it.file.fileEntry.column(offset)) } }
|
override fun location(offset: Int) = scope?.let { scope ->
|
||||||
|
fileScope?.let {
|
||||||
|
val (line, column) = it.file.fileEntry.lineAndColumn(offset)
|
||||||
|
LocationInfo(scope, line, column)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun scope() = scope
|
override fun scope() = scope
|
||||||
|
|
||||||
@@ -909,12 +913,12 @@ internal class CodeGeneratorVisitor(
|
|||||||
verifyModule(llvm.module, "${ir2string(declaration.parent)}::${ir2string(declaration)}")
|
verifyModule(llvm.module, "${ir2string(declaration.parent)}::${ir2string(declaration)}")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrFunction.location(start: Boolean) =
|
private fun IrFunction.location(start: Boolean): LocationInfo? {
|
||||||
if (context.shouldContainLocationDebugInfo() && startOffset != UNDEFINED_OFFSET) LocationInfo(
|
if (!context.shouldContainLocationDebugInfo() || startOffset == UNDEFINED_OFFSET) return null
|
||||||
scope = scope()!!,
|
|
||||||
line = if (start) startLine() else endLine(),
|
val (line, column) = if (start) startLineAndColumn() else endLineAndColumn()
|
||||||
column = if (start) startColumn() else endColumn())
|
return LocationInfo(scope = scope()!!, line = line, column = column)
|
||||||
else null
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
|
|
||||||
@@ -2115,7 +2119,8 @@ internal class CodeGeneratorVisitor(
|
|||||||
return if (returnableBlock.inlineFunction != null) {
|
return if (returnableBlock.inlineFunction != null) {
|
||||||
val diScope = functionScope ?: return null
|
val diScope = functionScope ?: return null
|
||||||
val inlinedAt = outerContext.location(returnableBlock.startOffset) ?: return null
|
val inlinedAt = outerContext.location(returnableBlock.startOffset) ?: return null
|
||||||
LocationInfo(diScope, file.fileEntry.line(offset), file.fileEntry.column(offset), inlinedAt)
|
val (line, column) = file.fileEntry.lineAndColumn(offset)
|
||||||
|
LocationInfo(diScope, line, column, inlinedAt)
|
||||||
} else {
|
} else {
|
||||||
outerContext.location(offset)
|
outerContext.location(offset)
|
||||||
}
|
}
|
||||||
@@ -2128,7 +2133,8 @@ internal class CodeGeneratorVisitor(
|
|||||||
if (!context.shouldContainLocationDebugInfo() || returnableBlock.startOffset == UNDEFINED_OFFSET)
|
if (!context.shouldContainLocationDebugInfo() || returnableBlock.startOffset == UNDEFINED_OFFSET)
|
||||||
return@lazy null
|
return@lazy null
|
||||||
val lexicalBlockFile = DICreateLexicalBlockFile(debugInfo.builder, functionScope()!!.scope(), super.file.diFileScope())
|
val lexicalBlockFile = DICreateLexicalBlockFile(debugInfo.builder, functionScope()!!.scope(), super.file.diFileScope())
|
||||||
DICreateLexicalBlock(debugInfo.builder, lexicalBlockFile, super.file.diFileScope(), returnableBlock.startLine(), returnableBlock.startColumn())!!
|
val (line, column) = returnableBlock.startLineAndColumn()
|
||||||
|
DICreateLexicalBlock(debugInfo.builder, lexicalBlockFile, super.file.diFileScope(), line, column)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun scope() = scope
|
override fun scope() = scope
|
||||||
@@ -2140,7 +2146,10 @@ internal class CodeGeneratorVisitor(
|
|||||||
private open inner class FileScope(val file: IrFile) : InnerScopeImpl() {
|
private open inner class FileScope(val file: IrFile) : InnerScopeImpl() {
|
||||||
override fun fileScope(): CodeContext? = this
|
override fun fileScope(): CodeContext? = this
|
||||||
|
|
||||||
override fun location(offset: Int) = scope()?.let { LocationInfo(it, file.fileEntry.line(offset), file.fileEntry.column(offset)) }
|
override fun location(offset: Int) = scope()?.let {
|
||||||
|
val (line, column) = file.fileEntry.lineAndColumn(offset)
|
||||||
|
LocationInfo(it, line, column)
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
private val scope by lazy {
|
private val scope by lazy {
|
||||||
@@ -2271,13 +2280,10 @@ internal class CodeGeneratorVisitor(
|
|||||||
private fun IrElement.startLine() = file().fileEntry.line(this.startOffset)
|
private fun IrElement.startLine() = file().fileEntry.line(this.startOffset)
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
private fun IrElement.startColumn() = file().fileEntry.column(this.startOffset)
|
private fun IrElement.startLineAndColumn() = file().fileEntry.lineAndColumn(this.startOffset)
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
private fun IrElement.endLine() = file().fileEntry.line(this.endOffset)
|
private fun IrElement.endLineAndColumn() = file().fileEntry.lineAndColumn(this.endOffset)
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
|
||||||
private fun IrElement.endColumn() = file().fileEntry.column(this.endOffset)
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------//
|
//-------------------------------------------------------------------------//
|
||||||
private fun debugFieldDeclaration(expression: IrField) {
|
private fun debugFieldDeclaration(expression: IrField) {
|
||||||
|
|||||||
+6
-13
@@ -4,9 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.kotlin.backend.konan.llvm.coverage
|
package org.jetbrains.kotlin.backend.konan.llvm.coverage
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.column
|
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.line
|
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.computeSymbolName
|
import org.jetbrains.kotlin.backend.konan.llvm.computeSymbolName
|
||||||
|
import org.jetbrains.kotlin.backend.konan.llvm.lineAndColumn
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
@@ -25,17 +24,11 @@ class Region(
|
|||||||
val file: IrFile,
|
val file: IrFile,
|
||||||
val kind: RegionKind
|
val kind: RegionKind
|
||||||
) {
|
) {
|
||||||
val startLine: Int
|
val startLineAndColumn: Pair<Int, Int>
|
||||||
get() = file.fileEntry.line(startOffset)
|
get() = file.fileEntry.lineAndColumn(startOffset)
|
||||||
|
|
||||||
val startColumn: Int
|
val endLineAndColumn: Pair<Int, Int>
|
||||||
get() = file.fileEntry.column(startOffset)
|
get() = file.fileEntry.lineAndColumn(endOffset)
|
||||||
|
|
||||||
val endLine: Int
|
|
||||||
get() = file.fileEntry.line(endOffset)
|
|
||||||
|
|
||||||
val endColumn: Int
|
|
||||||
get() = file.fileEntry.column(endOffset)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromIr(irElement: IrElement, irFile: IrFile, kind: RegionKind = RegionKind.Code) =
|
fun fromIr(irElement: IrElement, irFile: IrFile, kind: RegionKind = RegionKind.Code) =
|
||||||
@@ -48,7 +41,7 @@ class Region(
|
|||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
val expansion = (kind as? RegionKind.Expansion)?.let { " expand to " + it.expandedFile.name } ?: ""
|
val expansion = (kind as? RegionKind.Expansion)?.let { " expand to " + it.expandedFile.name } ?: ""
|
||||||
return "${file.name}$expansion: ${kind::class.simpleName} $startLine, $startColumn -> $endLine, $endColumn"
|
return "${file.name}$expansion: ${kind::class.simpleName} $startLineAndColumn -> $endLineAndColumn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-6
@@ -6,9 +6,7 @@ package org.jetbrains.kotlin.backend.konan.llvm.coverage
|
|||||||
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import llvm.*
|
import llvm.*
|
||||||
import org.jetbrains.kotlin.backend.konan.Context
|
|
||||||
import org.jetbrains.kotlin.backend.konan.NativeGenerationState
|
import org.jetbrains.kotlin.backend.konan.NativeGenerationState
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.name
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.declarations.path
|
import org.jetbrains.kotlin.ir.declarations.path
|
||||||
import org.jetbrains.kotlin.konan.file.File
|
import org.jetbrains.kotlin.konan.file.File
|
||||||
@@ -20,11 +18,14 @@ private fun RegionKind.toLLVMCoverageRegionKind(): LLVMCoverageRegionKind = when
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun LLVMCoverageRegion.populateFrom(region: Region, regionId: Int, filesIndex: Map<IrFile, Int>) = apply {
|
private fun LLVMCoverageRegion.populateFrom(region: Region, regionId: Int, filesIndex: Map<IrFile, Int>) = apply {
|
||||||
|
val (lineStart, columnStart) = region.startLineAndColumn
|
||||||
|
val (lineEnd, columnEnd) = region.endLineAndColumn
|
||||||
|
|
||||||
fileId = filesIndex.getValue(region.file)
|
fileId = filesIndex.getValue(region.file)
|
||||||
lineStart = region.startLine
|
this.lineStart = lineStart
|
||||||
columnStart = region.startColumn
|
this.columnStart = columnStart
|
||||||
lineEnd = region.endLine
|
this.lineEnd = lineEnd
|
||||||
columnEnd = region.endColumn
|
this.columnEnd = columnEnd
|
||||||
counterId = regionId
|
counterId = regionId
|
||||||
kind = region.kind.toLLVMCoverageRegionKind()
|
kind = region.kind.toLLVMCoverageRegionKind()
|
||||||
expandedFileId = if (region.kind is RegionKind.Expansion) filesIndex.getValue(region.kind.expandedFile) else 0
|
expandedFileId = if (region.kind is RegionKind.Expansion) filesIndex.getValue(region.kind.expandedFile) else 0
|
||||||
|
|||||||
Reference in New Issue
Block a user