Revert "[warnings] g/c some warnings and idea inspections"

This reverts commit 4b12f1c54c.
This commit is contained in:
igotti-google
2018-02-11 11:14:28 +03:00
parent b15c94855e
commit d408b50305
15 changed files with 331 additions and 329 deletions
@@ -67,7 +67,6 @@ fun runTopLevelPhases(konanConfig: KonanConfig, environment: KotlinCoreEnvironme
// Translate AST to high level IR.
val translator = Psi2IrTranslator(Psi2IrConfiguration(false))
val generatorContext = translator.createGeneratorContext(context.moduleDescriptor, bindingContext)
@Suppress("DEPRECATION")
context.psi2IrGeneratorContext = generatorContext
val symbols = KonanSymbols(context, generatorContext.symbolTable)
@@ -40,7 +40,7 @@ internal class KonanLower(val context: Context) {
}
}
private fun lowerModule(irModule: IrModuleFragment) {
fun lowerModule(irModule: IrModuleFragment) {
val phaser = PhaseManager(context)
phaser.phase(KonanPhase.REMOVE_EXPECT_DECLARATIONS) {
@@ -72,12 +72,11 @@ internal class KonanLower(val context: Context) {
irModule.files.forEach(InteropLoweringPart1(context)::lower)
}
@Suppress("DEPRECATION")
irModule.replaceUnboundSymbols(context)
validateIrModule(context, irModule)
}
private fun lowerFile(irFile: IrFile) {
fun lowerFile(irFile: IrFile) {
val phaser = PhaseManager(context)
phaser.phase(KonanPhase.LOWER_STRING_CONCAT) {
@@ -1401,8 +1401,6 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
private fun evaluateConst(value: IrConst<*>): LLVMValueRef {
context.log{"evaluateConst : ${ir2string(value)}"}
/* This suppression against IrConst<String> */
@Suppress("UNCHECKED_CAST")
when (value.kind) {
IrConstKind.Null -> return codegen.kNullObjHeaderPtr
IrConstKind.Boolean -> when (value.value) {
@@ -1414,7 +1412,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
IrConstKind.Short -> return LLVMConstInt(LLVMInt16Type(), (value.value as Short).toLong(), 1)!!
IrConstKind.Int -> return LLVMConstInt(LLVMInt32Type(), (value.value as Int).toLong(), 1)!!
IrConstKind.Long -> return LLVMConstInt(LLVMInt64Type(), value.value as Long, 1)!!
IrConstKind.String -> return evaluateStringConst(value as IrConst<String>)
IrConstKind.String -> return evaluateStringConst(@Suppress("UNCHECKED_CAST") value as IrConst<String>)
IrConstKind.Float -> return LLVMConstRealOfString(LLVMFloatType(), (value.value as Float).toString())!!
IrConstKind.Double -> return LLVMConstRealOfString(LLVMDoubleType(), (value.value as Double).toString())!!
}
@@ -146,10 +146,7 @@ private fun Context.getDeclaredFields(classDescriptor: ClassDescriptor): List<Pr
}
private fun ContextUtils.createClassBodyType(name: String, fields: List<PropertyDescriptor>): LLVMTypeRef {
val fieldTypes = fields.map {
@Suppress("DEPRECATION")
getLLVMType(if (it.isDelegated) context.builtIns.nullableAnyType else it.type)
}
val fieldTypes = fields.map { getLLVMType(if (it.isDelegated) context.builtIns.nullableAnyType else it.type) }
val classType = LLVMStructCreateNamed(LLVMGetModuleContext(context.llvmModule), name)!!
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.types.typeUtil.makeNullable
class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescriptor,
val parentDescriptor: DeclarationDescriptor,
val context: CommonBackendContext) {
context: CommonBackendContext) {
private val descriptorSubstituteMap: MutableMap<DeclarationDescriptor, DeclarationDescriptor> = mutableMapOf()
private var typeSubstitutor: TypeSubstitutor? = null
@@ -276,7 +276,6 @@ class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescriptor,
val oldContainingDeclaration = oldDescriptor.containingDeclaration
val newContainingDeclaration = descriptorSubstituteMap.getOrDefault(oldContainingDeclaration, oldContainingDeclaration) as ClassDescriptor
@Suppress("DEPRECATION")
return PropertyDescriptorImpl.create(
/* containingDeclaration = */ newContainingDeclaration,
/* annotations = */ oldDescriptor.annotations,
@@ -289,7 +288,7 @@ class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescriptor,
/* lateInit = */ oldDescriptor.isLateInit,
/* isConst = */ oldDescriptor.isConst,
/* isExpect = */ oldDescriptor.isExpect,
/* isActual = */ oldDescriptor.isActual,
/* isActual = */ oldDescriptor.isActual,
/* isExternal = */ oldDescriptor.isExternal,
/* isDelegated = */ oldDescriptor.isDelegated
).apply {
@@ -381,7 +380,6 @@ class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescriptor,
//-----------------------------------------------------------------------------//
@Suppress("DEPRECATION")
inner class InlineCopyIr : DeepCopyIrTree() {
override fun mapClassDeclaration (descriptor: ClassDescriptor) = descriptorSubstituteMap.getOrDefault(descriptor, descriptor) as ClassDescriptor
@@ -600,6 +598,8 @@ class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescriptor,
}
}
val context = context
}
class SubstitutedDescriptor(val inlinedFunction: FunctionDescriptor, val descriptor: DeclarationDescriptor)
@@ -635,11 +635,10 @@ class DescriptorSubstitutorForExternalScope(val globalSubstituteMap: MutableMap<
startOffset = oldExpression.startOffset,
endOffset = oldExpression.endOffset,
type = oldExpression.type,
symbol = createFunctionSymbol(newDescriptor),
descriptor = newDescriptor,
calleeDescriptor = newDescriptor,
typeArguments = oldExpression.typeArguments,
origin = oldExpression.origin,
superQualifierSymbol = createClassSymbolOrNull(oldExpression.superQualifier)
superQualifierDescriptor = oldExpression.superQualifier
).apply {
oldExpression.descriptor.valueParameters.forEach {
val valueArgument = oldExpression.getValueArgument(it)
@@ -662,7 +661,7 @@ class DescriptorSubstitutorForExternalScope(val globalSubstituteMap: MutableMap<
if (newDescriptor == oldDescriptor)
return oldExpression
return oldExpression.shallowCopy(oldExpression.origin, createFunctionSymbol(newDescriptor), oldExpression.superQualifierSymbol)
return oldExpression.shallowCopy(oldExpression.origin, newDescriptor, oldExpression.superQualifier)
}
}
@@ -41,7 +41,6 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrMemberAccessExpressionBase
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnableBlockImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
import org.jetbrains.kotlin.ir.symbols.impl.createValueSymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
@@ -348,7 +347,7 @@ private class Inliner(val globalSubstituteMap: MutableMap<DeclarationDescriptor,
val getVal = IrGetValueImpl( // Create new expression, representing access the new variable.
startOffset = currentScope.irElement.startOffset,
endOffset = currentScope.irElement.endOffset,
symbol = createValueSymbol(newVariable.descriptor)
descriptor = newVariable.descriptor
)
substituteMap[parameterDescriptor] = getVal // Parameter will be replaced with the new variable.
}
@@ -32,8 +32,6 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.createValueSymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.name.FqName
@@ -102,7 +100,7 @@ internal class InlineConstructorsTransformation(val context: Context): IrElement
val newThisGetValue = IrGetValueImpl( // Create new expression, representing access the new variable.
startOffset = 0,
endOffset = 0,
symbol = createValueSymbol(thisVariable.descriptor)
descriptor = thisVariable.descriptor
)
val classDescriptor = delegatingCall.descriptor.constructedClass
@@ -121,7 +119,7 @@ internal class InlineConstructorsTransformation(val context: Context): IrElement
statements = newStatements
)
val returnThis = IrReturnImpl(0, 0, createFunctionSymbol(functionDescriptor), block)
val returnThis = IrReturnImpl(0, 0, functionDescriptor, block)
statements.clear()
statements += returnThis
@@ -129,13 +127,12 @@ internal class InlineConstructorsTransformation(val context: Context): IrElement
//-------------------------------------------------------------------------//
private fun generateIrCall(expression: IrDelegatingConstructorCallImpl): IrVariable {
fun generateIrCall(expression: IrDelegatingConstructorCallImpl): IrVariable {
val newExpression = IrCallImpl(
expression.startOffset,
expression.endOffset,
expression.descriptor.returnType,
expression.symbol,
expression.descriptor,
expression.typeArguments,
expression.origin
@@ -146,10 +143,12 @@ internal class InlineConstructorsTransformation(val context: Context): IrElement
}
}
return currentScope!!.scope.createTemporaryVariable( // Create new variable and init it with constructor call.
val newVariable = currentScope!!.scope.createTemporaryVariable( // Create new variable and init it with constructor call.
irExpression = newExpression,
nameHint = newExpression.descriptor.fqNameSafe.toString() + ".this",
isMutable = false)
return newVariable
}
//-------------------------------------------------------------------------//
@@ -93,6 +93,7 @@ internal class ObjCExport(val context: Context) {
}
val file = directory.child("Info.plist")
val bundleExecutable = name
val pkg = context.moduleDescriptor.guessMainPackage() // TODO: consider showing warning if it is root.
val bundleId = pkg.child(Name.identifier(name)).asString()
@@ -103,7 +104,7 @@ internal class ObjCExport(val context: Context) {
else -> error(target)
}
val properties = context.config.platform.configurables as AppleConfigurables
val minimumOsVersion = properties.osVersionMin
val minimumOsVersion = properties.osVersionMin!!
val contents = StringBuilder()
contents.append("""
@@ -112,7 +113,7 @@ internal class ObjCExport(val context: Context) {
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>$name</string>
<string>$bundleExecutable</string>
<key>CFBundleIdentifier</key>
<string>$bundleId</string>
<key>CFBundleInfoDictionaryVersion</key>
@@ -42,8 +42,6 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrGetObjectValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.createValueSymbol
import org.jetbrains.kotlin.ir.util.getArguments
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
@@ -197,7 +195,7 @@ private class ExpressionValuesExtractor(val returnableBlockValues: Map<IrReturna
else -> {
if ((expression.type.isUnit() || expression.type.isNothing())) {
block(IrGetObjectValueImpl(expression.startOffset, expression.endOffset,
expression.type, IrClassSymbolImpl(expression.type.constructor.declarationDescriptor as ClassDescriptor)))
expression.type, (expression.type.constructor.declarationDescriptor as ClassDescriptor)))
}
else TODO(ir2stringWhole(expression))
}
@@ -562,7 +560,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
is IrDelegatingConstructorCall -> {
val thiz = IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET,
createValueSymbol((descriptor as ConstructorDescriptor).constructedClass.thisAsReceiverParameter))
(descriptor as ConstructorDescriptor).constructedClass.thisAsReceiverParameter)
val arguments = listOf(thiz) + value.getArguments().map { it.second }
DataFlowIR.Node.StaticCall(
symbolTable.mapFunction(value.descriptor),
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.backend.konan.optimizations
import org.jetbrains.kotlin.backend.konan.DirectedGraphCondensationBuilder
import org.jetbrains.kotlin.backend.konan.DirectedGraphMultiNode
import org.jetbrains.kotlin.backend.konan.llvm.Lifetime
import org.jetbrains.kotlin.backend.konan.optimizations.*
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
import org.jetbrains.kotlin.ir.IrElement
@@ -161,7 +162,6 @@ internal object EscapeAnalysis {
assignRole(value.node, Role.FIELD_WRITTEN, RoleInfoEntry(node))
}
}
else -> TODO()
}
}
FunctionAnalysisResult(function, nodesRoles)
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.*
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.VersionRequirementTable
import org.jetbrains.kotlin.types.KotlinType
// This class knows how to construct contexts for
// MemberDeserializer to deserialize descriptors declared in IR.
@@ -100,7 +101,12 @@ class LocalDeclarationDeserializer(val rootDescriptor: DeclarationDescriptor) {
contextStack.pop()
}
fun deserializeInlineType(type: ProtoBuf.Type) = typeDeserializer.type(type)
fun deserializeInlineType(type: ProtoBuf.Type): KotlinType {
val result = typeDeserializer.type(type)
return result
}
fun deserializeClass(irProto: KonanIr.KotlinDescriptor): ClassDescriptor {
return DeserializedClassDescriptor(parentContext, irProto.irLocalDeclaration.descriptor.clazz, nameResolver, SourceElement.NO_SOURCE)
@@ -115,8 +121,9 @@ class LocalDeclarationDeserializer(val rootDescriptor: DeclarationDescriptor) {
val proto = irProto.irLocalDeclaration.descriptor.constructor
val isPrimary = !Flags.IS_SECONDARY.get(proto.flags)
val constructor = memberDeserializer.loadConstructor(proto, isPrimary)
return memberDeserializer.loadConstructor(proto, isPrimary)
return constructor
}
fun deserializeProperty(irProto: KonanIr.KotlinDescriptor): VariableDescriptor {
@@ -131,17 +138,18 @@ class LocalDeclarationDeserializer(val rootDescriptor: DeclarationDescriptor) {
}
}
private fun propertyToVariable(property: PropertyDescriptor): LocalVariableDescriptor {
// TODO: Should we transform the getter and the setter too?
@Suppress("DEPRECATION")
return LocalVariableDescriptor(
fun propertyToVariable(property: PropertyDescriptor): LocalVariableDescriptor {
val variable = LocalVariableDescriptor(
property.containingDeclaration,
property.annotations,
property.name,
property.type,
property.isVar,
property.isVar,
property.isDelegated,
SourceElement.NO_SOURCE)
// TODO: Should we transform the getter and the setter too?
return variable
}
}
@@ -97,9 +97,8 @@ internal class LocalDeclarationSerializer(val context: Context, val rootFunction
// serialization to serialize variables for now.
// Need to introduce an extension protobuf message
// and serialize variables directly.
private fun variableAsProperty(variable: VariableDescriptor): PropertyDescriptor {
fun variableAsProperty(variable: VariableDescriptor): PropertyDescriptor {
@Suppress("DEPRECATION")
val isDelegated = when (variable) {
is LocalVariableDescriptor -> variable.isDelegated
is IrTemporaryVariableDescriptor -> false
@@ -55,7 +55,6 @@ internal fun IrModuleFragment.replaceUnboundSymbols(context: Context) {
// Generate missing external stubs:
// TODO: ModuleGenerator::generateUnboundSymbolsAsDependencies(IRModuleFragment) is private function :/
@Suppress("DEPRECATION")
ExternalDependenciesGenerator(symbolTable = context.psi2IrGeneratorContext.symbolTable, irBuiltIns = context.irBuiltIns).generateUnboundSymbolsAsDependencies(this)
// Merge duplicated module and package declarations:
@@ -28,8 +28,7 @@ open class KlibInstall: Exec() {
override fun configure(config: Closure<*>): Task {
val result = super.configure(config)
val konanHomePath = project.findProperty("konan.home") ?: "dist"
val konanHome = project.rootProject.file(konanHomePath)
val konanHome = project.rootProject.file(project.findProperty("konan.home") ?: "dist")
val suffix = if (TargetManager.host == KonanTarget.MINGW) ".bat" else ""
val klibProgram = "$konanHome/bin/klib$suffix"
@@ -44,4 +43,4 @@ open class KlibInstall: Exec() {
}
return result
}
}
}