mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
Create instance variable initializer block eagerly
Otherwise when the init block is followed by other constructor statements we can get a gap in a BasicBlock's child sequence due to the child init block never getting created at all.
This commit is contained in:
committed by
Ian Lynagh
parent
9fd9894f6a
commit
e24d78ae14
@@ -522,13 +522,14 @@ open class KotlinFileExtractor(
|
||||
return
|
||||
}
|
||||
|
||||
extractDeclInitializers(enclosingClass.declarations, false) {
|
||||
Pair(tw.getFreshIdLabel<DbBlock>().also({
|
||||
tw.writeStmts_block(it, parent.parent, parent.idx, constructorId)
|
||||
val locId = tw.getLocation(enclosingConstructor)
|
||||
tw.writeHasLocation(it, locId)
|
||||
}), constructorId)
|
||||
// Don't make this block lazily since we need to insert something at the given parent.idx position,
|
||||
// and in the case where there are no initializers to emit an empty block is an acceptable filler.
|
||||
val initBlockId = tw.getFreshIdLabel<DbBlock>().also {
|
||||
tw.writeStmts_block(it, parent.parent, parent.idx, constructorId)
|
||||
val locId = tw.getLocation(enclosingConstructor)
|
||||
tw.writeHasLocation(it, locId)
|
||||
}
|
||||
extractDeclInitializers(enclosingClass.declarations, false) { Pair(initBlockId, constructorId) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user