mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Kotlin: Add support for "is" ("instanceof")
This commit is contained in:
@@ -1466,12 +1466,35 @@ class X {
|
||||
tw.writeHasLocation(id, locId)
|
||||
extractExpressionExpr(e.argument, callable, id, 0)
|
||||
}
|
||||
is IrTypeOperatorCall -> {
|
||||
extractTypeOperatorCall(e, callable, parent, idx)
|
||||
}
|
||||
else -> {
|
||||
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrExpression: " + e.javaClass, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun extractTypeOperatorCall(e: IrTypeOperatorCall, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int) {
|
||||
when(e.operator) {
|
||||
IrTypeOperator.INSTANCEOF -> {
|
||||
val id = tw.getFreshIdLabel<DbInstanceofexpr>()
|
||||
val locId = tw.getLocation(e)
|
||||
val type = useType(e.type)
|
||||
tw.writeExprs_instanceofexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
|
||||
tw.writeHasLocation(id, locId)
|
||||
extractExpressionExpr(e.argument, callable, id, 0)
|
||||
val typeArg = useType(e.typeOperand)
|
||||
val typeAccessId = tw.getFreshIdLabel<DbUnannotatedtypeaccess>()
|
||||
tw.writeExprs_unannotatedtypeaccess(typeAccessId, typeArg.javaResult.id, typeArg.kotlinResult.id, id, 1)
|
||||
// TODO: Type access location
|
||||
}
|
||||
else -> {
|
||||
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrTypeOperatorCall: " + e.render(), e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractBreakContinue(
|
||||
e: IrBreakContinue,
|
||||
id: Label<out DbBreakcontinuestmt>
|
||||
@@ -1491,4 +1514,4 @@ class X {
|
||||
|
||||
tw.writeKtBreakContinueTargets(id, loopId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
| exprs.kt:39:5:39:38 | strWithQuote | LocalVariableDeclExpr |
|
||||
| exprs.kt:39:25:39:37 | string " lit | StringLiteral |
|
||||
| exprs.kt:40:5:40:22 | b6 | LocalVariableDeclExpr |
|
||||
| exprs.kt:40:14:40:15 | i1 | VarAccess |
|
||||
| exprs.kt:40:14:40:22 | ...instanceof... | InstanceOfExpr |
|
||||
| exprs.kt:41:5:41:23 | b7 | LocalVariableDeclExpr |
|
||||
| exprs.kt:42:5:42:26 | b8 | LocalVariableDeclExpr |
|
||||
| exprs.kt:43:5:43:35 | str1 | LocalVariableDeclExpr |
|
||||
@@ -72,3 +74,4 @@
|
||||
| exprs.kt:53:9:53:18 | n | VarAccess |
|
||||
| exprs.kt:54:27:54:31 | new C(...) | ClassInstanceExpr |
|
||||
| exprs.kt:54:29:54:30 | 42 | IntegerLiteral |
|
||||
| file://:0:0:0:0 | int | TypeAccess |
|
||||
|
||||
Reference in New Issue
Block a user