mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Kotlin: Add support for IrSyntheticBody
I'm not sure it's worth adding an entity to the database for them, although that would allow us to use a 'case' in the dbscheme for the different kinds. There's no QLL support for this info yet.
This commit is contained in:
@@ -459,21 +459,31 @@ open class KotlinFileExtractor(
|
||||
|
||||
fun extractBody(b: IrBody, callable: Label<out DbCallable>) {
|
||||
when(b) {
|
||||
is IrBlockBody -> extractBlockBody(b, callable, callable, 0)
|
||||
else -> logger.warnElement(Severity.ErrorSevere, "Unrecognised IrBody: " + b.javaClass, b)
|
||||
is IrBlockBody -> extractBlockBody(b, callable)
|
||||
is IrSyntheticBody -> extractSyntheticBody(b, callable)
|
||||
else -> {
|
||||
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrBody: " + b.javaClass, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun extractBlockBody(b: IrBlockBody, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
|
||||
fun extractBlockBody(b: IrBlockBody, callable: Label<out DbCallable>) {
|
||||
val id = tw.getFreshIdLabel<DbBlock>()
|
||||
val locId = tw.getLocation(b)
|
||||
tw.writeStmts_block(id, parent, idx, callable)
|
||||
tw.writeStmts_block(id, callable, 0, callable)
|
||||
tw.writeHasLocation(id, locId)
|
||||
for((sIdx, stmt) in b.statements.withIndex()) {
|
||||
extractStatement(stmt, callable, id, sIdx)
|
||||
}
|
||||
}
|
||||
|
||||
fun extractSyntheticBody(b: IrSyntheticBody, callable: Label<out DbCallable>) {
|
||||
when (b.kind) {
|
||||
IrSyntheticBodyKind.ENUM_VALUES -> tw.writeKtSyntheticBody(callable, 1)
|
||||
IrSyntheticBodyKind.ENUM_VALUEOF -> tw.writeKtSyntheticBody(callable, 2)
|
||||
}
|
||||
}
|
||||
|
||||
fun extractVariable(v: IrVariable, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
|
||||
val stmtId = tw.getFreshIdLabel<DbLocalvariabledeclstmt>()
|
||||
val locId = tw.getLocation(v)
|
||||
|
||||
Reference in New Issue
Block a user