mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Kotlin: extract unary plus and minus operators
This commit is contained in:
@@ -2094,7 +2094,7 @@ open class KotlinFileExtractor(
|
||||
id
|
||||
}
|
||||
else -> {
|
||||
logger.errorElement("Unhandled target name: $targetName", c)
|
||||
logger.errorElement("Unhandled binary target name: $targetName", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -2130,10 +2130,29 @@ open class KotlinFileExtractor(
|
||||
tw.writeExprsKotlinType(id, type.kotlinResult.id)
|
||||
unaryopDisp(id)
|
||||
}
|
||||
isNumericFunction(target, "inv") -> {
|
||||
val id = tw.getFreshIdLabel<DbBitnotexpr>()
|
||||
isNumericFunction(target, listOf("inv", "unaryMinus", "unaryPlus")) -> {
|
||||
val type = useType(c.type)
|
||||
tw.writeExprs_bitnotexpr(id, type.javaResult.id, parent, idx)
|
||||
val id: Label<out DbExpr> = when (val targetName = target.name.asString()) {
|
||||
"inv" -> {
|
||||
val id = tw.getFreshIdLabel<DbBitnotexpr>()
|
||||
tw.writeExprs_bitnotexpr(id, type.javaResult.id, parent, idx)
|
||||
id
|
||||
}
|
||||
"unaryMinus" -> {
|
||||
val id = tw.getFreshIdLabel<DbMinusexpr>()
|
||||
tw.writeExprs_minusexpr(id, type.javaResult.id, parent, idx)
|
||||
id
|
||||
}
|
||||
"unaryPlus" -> {
|
||||
val id = tw.getFreshIdLabel<DbPlusexpr>()
|
||||
tw.writeExprs_plusexpr(id, type.javaResult.id, parent, idx)
|
||||
id
|
||||
}
|
||||
else -> {
|
||||
logger.errorElement("Unhandled unary target name: $targetName", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
tw.writeExprsKotlinType(id, type.kotlinResult.id)
|
||||
unaryopDisp(id)
|
||||
}
|
||||
|
||||
@@ -2866,15 +2866,23 @@ exprs.kt:
|
||||
# 280| 0: [ExprStmt] <Expr>;
|
||||
# 280| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 280| 0: [TypeAccess] Unit
|
||||
# 280| 1: [MinusExpr] -...
|
||||
# 280| 0: [VarAccess] i
|
||||
# 281| 1: [ExprStmt] <Expr>;
|
||||
# 281| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 281| 0: [TypeAccess] Unit
|
||||
# 281| 1: [PlusExpr] +...
|
||||
# 281| 0: [VarAccess] i
|
||||
# 282| 2: [ExprStmt] <Expr>;
|
||||
# 282| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 282| 0: [TypeAccess] Unit
|
||||
# 282| 1: [MinusExpr] -...
|
||||
# 282| 0: [VarAccess] d
|
||||
# 283| 3: [ExprStmt] <Expr>;
|
||||
# 283| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 283| 0: [TypeAccess] Unit
|
||||
# 283| 1: [PlusExpr] +...
|
||||
# 283| 0: [VarAccess] d
|
||||
# 284| 4: [LocalVariableDeclStmt] var ...;
|
||||
# 284| 1: [LocalVariableDeclExpr] i0
|
||||
# 284| 0: [IntegerLiteral] 1
|
||||
|
||||
@@ -1741,14 +1741,22 @@
|
||||
| exprs.kt:279:1:294:1 | Unit | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| exprs.kt:279:16:279:21 | int | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| exprs.kt:279:24:279:32 | double | file://:0:0:0:0 | <none> | TypeAccess |
|
||||
| exprs.kt:280:5:280:6 | -... | exprs.kt:279:1:294:1 | unaryExprs | MinusExpr |
|
||||
| exprs.kt:280:5:280:6 | <implicit coercion to unit> | exprs.kt:279:1:294:1 | unaryExprs | ImplicitCoercionToUnitExpr |
|
||||
| exprs.kt:280:5:280:6 | Unit | exprs.kt:279:1:294:1 | unaryExprs | TypeAccess |
|
||||
| exprs.kt:280:6:280:6 | i | exprs.kt:279:1:294:1 | unaryExprs | VarAccess |
|
||||
| exprs.kt:281:5:281:6 | +... | exprs.kt:279:1:294:1 | unaryExprs | PlusExpr |
|
||||
| exprs.kt:281:5:281:6 | <implicit coercion to unit> | exprs.kt:279:1:294:1 | unaryExprs | ImplicitCoercionToUnitExpr |
|
||||
| exprs.kt:281:5:281:6 | Unit | exprs.kt:279:1:294:1 | unaryExprs | TypeAccess |
|
||||
| exprs.kt:281:6:281:6 | i | exprs.kt:279:1:294:1 | unaryExprs | VarAccess |
|
||||
| exprs.kt:282:5:282:6 | -... | exprs.kt:279:1:294:1 | unaryExprs | MinusExpr |
|
||||
| exprs.kt:282:5:282:6 | <implicit coercion to unit> | exprs.kt:279:1:294:1 | unaryExprs | ImplicitCoercionToUnitExpr |
|
||||
| exprs.kt:282:5:282:6 | Unit | exprs.kt:279:1:294:1 | unaryExprs | TypeAccess |
|
||||
| exprs.kt:282:6:282:6 | d | exprs.kt:279:1:294:1 | unaryExprs | VarAccess |
|
||||
| exprs.kt:283:5:283:6 | +... | exprs.kt:279:1:294:1 | unaryExprs | PlusExpr |
|
||||
| exprs.kt:283:5:283:6 | <implicit coercion to unit> | exprs.kt:279:1:294:1 | unaryExprs | ImplicitCoercionToUnitExpr |
|
||||
| exprs.kt:283:5:283:6 | Unit | exprs.kt:279:1:294:1 | unaryExprs | TypeAccess |
|
||||
| exprs.kt:283:6:283:6 | d | exprs.kt:279:1:294:1 | unaryExprs | VarAccess |
|
||||
| exprs.kt:284:5:284:14 | i0 | exprs.kt:279:1:294:1 | unaryExprs | LocalVariableDeclExpr |
|
||||
| exprs.kt:284:14:284:14 | 1 | exprs.kt:279:1:294:1 | unaryExprs | IntegerLiteral |
|
||||
| exprs.kt:285:5:285:14 | i1 | exprs.kt:279:1:294:1 | unaryExprs | LocalVariableDeclExpr |
|
||||
|
||||
@@ -5,3 +5,7 @@
|
||||
| exprs.kt:196:19:196:20 | ...!! | exprs.kt:196:18:196:18 | x |
|
||||
| exprs.kt:205:20:205:21 | ...!! | exprs.kt:205:19:205:19 | s |
|
||||
| exprs.kt:206:20:206:21 | ...!! | exprs.kt:206:19:206:19 | s |
|
||||
| exprs.kt:280:5:280:6 | -... | exprs.kt:280:6:280:6 | i |
|
||||
| exprs.kt:281:5:281:6 | +... | exprs.kt:281:6:281:6 | i |
|
||||
| exprs.kt:282:5:282:6 | -... | exprs.kt:282:6:282:6 | d |
|
||||
| exprs.kt:283:5:283:6 | +... | exprs.kt:283:6:283:6 | d |
|
||||
|
||||
Reference in New Issue
Block a user