mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
Extract logical not expression
This commit is contained in:
@@ -1887,6 +1887,22 @@ open class KotlinFileExtractor(
|
||||
}
|
||||
}
|
||||
|
||||
fun unaryopReceiver(id: Label<out DbExpr>, receiver: IrExpression?, receiverDescription: String) {
|
||||
val locId = tw.getLocation(c)
|
||||
tw.writeHasLocation(id, locId)
|
||||
tw.writeCallableEnclosingExpr(id, callable)
|
||||
tw.writeStatementEnclosingExpr(id, enclosingStmt)
|
||||
|
||||
if(receiver == null) {
|
||||
logger.errorElement("$receiverDescription not found", c)
|
||||
} else {
|
||||
extractExpressionExpr(receiver, callable, id, 0, enclosingStmt)
|
||||
}
|
||||
if(c.valueArgumentsCount > 0) {
|
||||
logger.errorElement("Extra arguments found", c)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the lhs of a binary op from this call's dispatch receiver, and the rhs from its sole argument.
|
||||
*/
|
||||
@@ -1894,6 +1910,10 @@ open class KotlinFileExtractor(
|
||||
binopReceiver(id, c.dispatchReceiver, "Dispatch receiver")
|
||||
}
|
||||
|
||||
fun unaryopDisp(id: Label<out DbExpr>) {
|
||||
unaryopReceiver(id, c.dispatchReceiver, "Dispatch receiver")
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the lhs of a binary op from this call's extension receiver, and the rhs from its sole argument.
|
||||
*/
|
||||
@@ -2003,6 +2023,13 @@ open class KotlinFileExtractor(
|
||||
tw.writeExprsKotlinType(id, type.kotlinResult.id)
|
||||
binOp(id, dr, callable, enclosingStmt)
|
||||
}
|
||||
isFunction(target, "kotlin", "Boolean", "not") -> {
|
||||
val id = tw.getFreshIdLabel<DbLognotexpr>()
|
||||
val type = useType(c.type)
|
||||
tw.writeExprs_lognotexpr(id, type.javaResult.id, parent, idx)
|
||||
tw.writeExprsKotlinType(id, type.kotlinResult.id)
|
||||
unaryopDisp(id)
|
||||
}
|
||||
// We need to handle all the builtin operators defines in BuiltInOperatorNames in
|
||||
// compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt
|
||||
// as they can't be extracted as external dependencies.
|
||||
|
||||
Reference in New Issue
Block a user